From 1dedea2fb8915f036be8d197015b8b2774fe29d8 Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Wed, 5 Jul 2023 13:49:53 -0400 Subject: [PATCH] integration: disable iptables in parallel tests Multiple daemons starting/running concurrently can collide with each other when editing iptables rules. Most integration tests which opt into parallelism and start daemons work around this problem by starting the daemon with the --iptables=false option. However, some of the tests neglect to pass the option when starting or restarting the daemon, resulting in those tests being flaky. Audit the integration tests which call t.Parallel() and (*Daemon).Stop() and add --iptables=false arguments where needed. Signed-off-by: Cory Snider (cherry picked from commit cdcb7c28c5f6d29652fa9d37dc45041b190d1cd4) Signed-off-by: Cory Snider --- integration/container/daemon_linux_test.go | 6 +++--- integration/container/daemon_test.go | 2 +- integration/image/import_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/integration/container/daemon_linux_test.go b/integration/container/daemon_linux_test.go index 5189c6bf53..7f14f6df42 100644 --- a/integration/container/daemon_linux_test.go +++ b/integration/container/daemon_linux_test.go @@ -141,7 +141,7 @@ func TestDaemonHostGatewayIP(t *testing.T) { // Verify the IP in /etc/hosts is same as host-gateway-ip d := daemon.New(t) // Verify the IP in /etc/hosts is same as the default bridge's IP - d.StartWithBusybox(t) + d.StartWithBusybox(t, "--iptables=false") c := d.NewClientT(t) ctx := context.Background() cID := container.Run(ctx, t, c, @@ -158,7 +158,7 @@ func TestDaemonHostGatewayIP(t *testing.T) { d.Stop(t) // Verify the IP in /etc/hosts is same as host-gateway-ip - d.StartWithBusybox(t, "--host-gateway-ip=6.7.8.9") + d.StartWithBusybox(t, "--iptables=false", "--host-gateway-ip=6.7.8.9") cID = container.Run(ctx, t, c, container.WithExtraHost("host.docker.internal:host-gateway"), ) @@ -220,7 +220,7 @@ func TestRestartDaemonWithRestartingContainer(t *testing.T) { assert.NilError(t, err) assert.NilError(t, os.WriteFile(configPath, configBytes, 0600)) - d.Start(t) + d.Start(t, "--iptables=false") ctxTimeout, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() diff --git a/integration/container/daemon_test.go b/integration/container/daemon_test.go index 94468a4409..a0a66b7247 100644 --- a/integration/container/daemon_test.go +++ b/integration/container/daemon_test.go @@ -43,7 +43,7 @@ func TestContainerKillOnDaemonStart(t *testing.T) { assert.Assert(t, inspect.State.Running) assert.NilError(t, d.Kill()) - d.Start(t) + d.Start(t, "--iptables=false") inspect, err = client.ContainerInspect(ctx, id) assert.Check(t, is.Nil(err)) diff --git a/integration/image/import_test.go b/integration/image/import_test.go index 110ab87a5f..9ee647867a 100644 --- a/integration/image/import_test.go +++ b/integration/image/import_test.go @@ -27,7 +27,7 @@ func TestImportExtremelyLargeImageWorks(t *testing.T) { // Spin up a new daemon, so that we can run this test in parallel (it's a slow test) d := daemon.New(t) - d.Start(t) + d.Start(t, "--iptables=false") defer d.Stop(t) client := d.NewClientT(t)