From 77f143266beb4e42bf8aa6e680fd521a85d5be56 Mon Sep 17 00:00:00 2001 From: ksurl Date: Fri, 3 Dec 2021 16:04:05 -0800 Subject: [PATCH 1/4] add testing for nftables --- test/containers/trafficjam_test/entrypoint.sh | 5 +++++ test/docker-compose-nftables.yml | 8 ++++++++ test/test.bats | 9 +++++++++ 3 files changed, 22 insertions(+) create mode 100644 test/docker-compose-nftables.yml diff --git a/test/containers/trafficjam_test/entrypoint.sh b/test/containers/trafficjam_test/entrypoint.sh index 33589fe..bab3353 100755 --- a/test/containers/trafficjam_test/entrypoint.sh +++ b/test/containers/trafficjam_test/entrypoint.sh @@ -1,4 +1,9 @@ #!/usr/bin/env bash + +#Check for nftables testing +if [ -n $NFTABLES ]; then + ln -s /sbin/xtables-nft-multi /sbin/iptables -f +fi /usr/local/bin/dockerd-entrypoint.sh dockerd & #Wait for docker startup for 60s while ! docker ps; do diff --git a/test/docker-compose-nftables.yml b/test/docker-compose-nftables.yml new file mode 100644 index 0000000..bb58f6b --- /dev/null +++ b/test/docker-compose-nftables.yml @@ -0,0 +1,8 @@ +version: '3.8' +services: + trafficjam_test: + image: trafficjam_test + container_name: trafficjam_test_nftables + environment: + NFTABLES: true + privileged: true \ No newline at end of file diff --git a/test/test.bats b/test/test.bats index 93e8e9f..8e2f377 100644 --- a/test/test.bats +++ b/test/test.bats @@ -19,6 +19,14 @@ docker exec trafficjam_test bats /opt/trafficjam/test/test-dind.bats } +@test "Deploy the non-swarm environment with nftables" { + docker-compose -f "$BATS_TEST_DIRNAME"/docker-compose-nftables.yml up -d +} + +@test "Test the non-swarm environment with nftables" { + docker exec trafficjam_test bats /opt/trafficjam/test/test-dind.bats +} + @test "Deploy the swarm environment" { docker-compose -f "$BATS_TEST_DIRNAME"/docker-compose-swarm.yml up -d docker exec swarm-manager docker swarm init @@ -36,6 +44,7 @@ function teardown_file() { docker-compose -f "$BATS_TEST_DIRNAME"/docker-compose.yml down + docker-compose -f "$BATS_TEST_DIRNAME"/docker-compose-nftables.yml down docker-compose -f "$BATS_TEST_DIRNAME"/docker-compose-swarm.yml down docker image rm --force trafficjam_bats trafficjam_test } From 33d32516dedf25c42a1733f35ff8a2812040efd3 Mon Sep 17 00:00:00 2001 From: ksurl Date: Fri, 3 Dec 2021 16:22:17 -0800 Subject: [PATCH 2/4] fix env string --- test/docker-compose-nftables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/docker-compose-nftables.yml b/test/docker-compose-nftables.yml index bb58f6b..0020da4 100644 --- a/test/docker-compose-nftables.yml +++ b/test/docker-compose-nftables.yml @@ -4,5 +4,5 @@ services: image: trafficjam_test container_name: trafficjam_test_nftables environment: - NFTABLES: true + NFTABLES: "true" privileged: true \ No newline at end of file From 0534528f4ff8d92679382dc05ef5c64728be8260 Mon Sep 17 00:00:00 2001 From: ksurl Date: Fri, 3 Dec 2021 16:35:50 -0800 Subject: [PATCH 3/4] update container name for nftables testing --- test/test.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.bats b/test/test.bats index 8e2f377..a68cf46 100644 --- a/test/test.bats +++ b/test/test.bats @@ -24,7 +24,7 @@ } @test "Test the non-swarm environment with nftables" { - docker exec trafficjam_test bats /opt/trafficjam/test/test-dind.bats + docker exec trafficjam_test_nftables bats /opt/trafficjam/test/test-dind.bats } @test "Deploy the swarm environment" { From e51a538139e90534165b6fd724986d5ae85f89f7 Mon Sep 17 00:00:00 2001 From: Aram Akhavan Date: Fri, 3 Dec 2021 19:51:27 -0800 Subject: [PATCH 4/4] Nit - make the conditional more typical bash --- test/containers/trafficjam_test/entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/containers/trafficjam_test/entrypoint.sh b/test/containers/trafficjam_test/entrypoint.sh index bab3353..86d1562 100755 --- a/test/containers/trafficjam_test/entrypoint.sh +++ b/test/containers/trafficjam_test/entrypoint.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash #Check for nftables testing -if [ -n $NFTABLES ]; then +if [[ -n "$NFTABLES" ]]; then ln -s /sbin/xtables-nft-multi /sbin/iptables -f fi /usr/local/bin/dockerd-entrypoint.sh dockerd & @@ -15,4 +15,4 @@ while ! docker ps; do done docker build -t trafficjam /opt/trafficjam || exit 1; docker build -t whoami /opt/trafficjam/test/containers/whoami || exit 1; -sleep infinity \ No newline at end of file +sleep infinity