Browse code

integration: Make some tests Parallel

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

Paweł Gronowski authored on 2026/05/14 00:28:17
Showing 11 changed files
... ...
@@ -41,7 +41,7 @@ func getCgroupFromBuildOutput(buildOutput io.Reader) (string, error) {
41 41
 // Returns the container cgroup and daemon cgroup.
42 42
 func testBuildWithCgroupNs(ctx context.Context, t *testing.T, daemonNsMode string) (string, string) {
43 43
 	d := daemon.New(t, daemon.WithDefaultCgroupNamespaceMode(daemonNsMode))
44
-	d.StartWithBusybox(ctx, t)
44
+	d.StartWithBusybox(ctx, t, "--iptables=false", "--ip6tables=false")
45 45
 	defer d.Stop(t)
46 46
 
47 47
 	dockerfile := `
... ...
@@ -72,6 +72,8 @@ func TestCgroupNamespacesBuild(t *testing.T) {
72 72
 	skip.If(t, testEnv.IsRemoteDaemon())
73 73
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
74 74
 
75
+	t.Parallel()
76
+
75 77
 	ctx := testutil.StartSpan(baseContext, t)
76 78
 
77 79
 	// When the daemon defaults to private cgroup namespaces, containers launched
... ...
@@ -85,6 +87,8 @@ func TestCgroupNamespacesBuildDaemonHostMode(t *testing.T) {
85 85
 	skip.If(t, testEnv.IsRemoteDaemon())
86 86
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
87 87
 
88
+	t.Parallel()
89
+
88 90
 	ctx := testutil.StartSpan(baseContext, t)
89 91
 
90 92
 	// When the daemon defaults to host cgroup namespaces, containers
... ...
@@ -26,13 +26,15 @@ func TestCreateWithCDIDevices(t *testing.T) {
26 26
 	skip.If(t, testEnv.DaemonInfo.OSType != "linux", "CDI devices are only supported on Linux")
27 27
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot run cdi tests with a remote daemon")
28 28
 
29
+	t.Parallel()
30
+
29 31
 	ctx := testutil.StartSpan(baseContext, t)
30 32
 
31 33
 	cwd, err := os.Getwd()
32 34
 	assert.NilError(t, err)
33 35
 
34 36
 	d := daemon.New(t)
35
-	d.StartWithBusybox(ctx, t, "--cdi-spec-dir="+filepath.Join(cwd, "testdata", "cdi"))
37
+	d.StartWithBusybox(ctx, t, "--cdi-spec-dir="+filepath.Join(cwd, "testdata", "cdi"), "--iptables=false", "--ip6tables=false")
36 38
 	defer d.Stop(t)
37 39
 
38 40
 	apiClient := d.NewClientT(t)
... ...
@@ -74,6 +76,8 @@ func TestCDISpecDirsAreInSystemInfo(t *testing.T) {
74 74
 	// TODO: This restriction can be relaxed with https://github.com/moby/moby/pull/46158
75 75
 	skip.If(t, testEnv.IsRootless, "the t.TempDir test creates a folder with incorrect permissions for rootless")
76 76
 
77
+	t.Parallel()
78
+
77 79
 	testCases := []struct {
78 80
 		description             string
79 81
 		config                  string
... ...
@@ -146,6 +150,7 @@ func TestCDISpecDirsAreInSystemInfo(t *testing.T) {
146 146
 
147 147
 				args = append(args, "--config-file="+configPath)
148 148
 			}
149
+			args = append(args, "--iptables=false", "--ip6tables=false")
149 150
 			d.Start(t, args...)
150 151
 			defer d.Stop(t)
151 152
 
... ...
@@ -160,6 +165,8 @@ func TestCDIInfoDiscoveredDevices(t *testing.T) {
160 160
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
161 161
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "CDI not supported on Windows")
162 162
 
163
+	t.Parallel()
164
+
163 165
 	ctx := testutil.StartSpan(baseContext, t)
164 166
 
165 167
 	// Create a sample CDI spec file
... ...
@@ -185,7 +192,7 @@ func TestCDIInfoDiscoveredDevices(t *testing.T) {
185 185
 	assert.NilError(t, err, "Failed to write sample CDI spec file")
186 186
 
187 187
 	d := daemon.New(t)
188
-	d.Start(t, "--feature", "cdi", "--cdi-spec-dir="+cdiDir)
188
+	d.Start(t, "--feature", "cdi", "--cdi-spec-dir="+cdiDir, "--iptables=false", "--ip6tables=false")
189 189
 	defer d.Stop(t)
190 190
 
191 191
 	c := d.NewClientT(t)
... ...
@@ -59,17 +59,19 @@ func TestExportContainerAfterDaemonRestart(t *testing.T) {
59 59
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows")
60 60
 	skip.If(t, testEnv.IsRemoteDaemon)
61 61
 
62
+	t.Parallel()
63
+
62 64
 	ctx := testutil.StartSpan(baseContext, t)
63 65
 
64 66
 	d := daemon.New(t)
65 67
 	c := d.NewClientT(t)
66 68
 
67
-	d.StartWithBusybox(ctx, t)
69
+	d.StartWithBusybox(ctx, t, "--iptables=false", "--ip6tables=false")
68 70
 	defer d.Stop(t)
69 71
 
70 72
 	ctrID := container.Create(ctx, t, c)
71 73
 
72
-	d.Restart(t)
74
+	d.Restart(t, "--iptables=false", "--ip6tables=false")
73 75
 
74 76
 	res, err := c.ContainerExport(ctx, ctrID, client.ContainerExportOptions{})
75 77
 	assert.NilError(t, err)
... ...
@@ -18,7 +18,7 @@ func testRunWithCgroupNs(ctx context.Context, t *testing.T, daemonNsMode string,
18 18
 	d := daemon.New(t, daemon.WithDefaultCgroupNamespaceMode(daemonNsMode))
19 19
 	apiClient := d.NewClientT(t)
20 20
 
21
-	d.StartWithBusybox(ctx, t)
21
+	d.StartWithBusybox(ctx, t, "--iptables=false", "--ip6tables=false")
22 22
 	defer d.Stop(t)
23 23
 
24 24
 	cID := container.Run(ctx, t, apiClient, containerOpts...)
... ...
@@ -34,7 +34,7 @@ func testCreateFailureWithCgroupNs(ctx context.Context, t *testing.T, daemonNsMo
34 34
 	d := daemon.New(t, daemon.WithDefaultCgroupNamespaceMode(daemonNsMode))
35 35
 	apiClient := d.NewClientT(t)
36 36
 
37
-	d.StartWithBusybox(ctx, t)
37
+	d.StartWithBusybox(ctx, t, "--iptables=false", "--ip6tables=false")
38 38
 	defer d.Stop(t)
39 39
 	_, err := container.CreateFromConfig(ctx, apiClient, container.NewTestConfig(containerOpts...))
40 40
 	assert.ErrorContains(t, err, errStr)
... ...
@@ -45,6 +45,8 @@ func TestCgroupNamespacesRun(t *testing.T) {
45 45
 	skip.If(t, testEnv.IsRemoteDaemon())
46 46
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
47 47
 
48
+	t.Parallel()
49
+
48 50
 	ctx := testutil.StartSpan(baseContext, t)
49 51
 
50 52
 	// When the daemon defaults to private cgroup namespaces, containers launched
... ...
@@ -59,6 +61,8 @@ func TestCgroupNamespacesRunPrivileged(t *testing.T) {
59 59
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
60 60
 	skip.If(t, testEnv.DaemonInfo.CgroupVersion == "2", "on cgroup v2, privileged containers use private cgroupns")
61 61
 
62
+	t.Parallel()
63
+
62 64
 	ctx := testutil.StartSpan(baseContext, t)
63 65
 
64 66
 	// When the daemon defaults to private cgroup namespaces, privileged containers
... ...
@@ -72,6 +76,8 @@ func TestCgroupNamespacesRunDaemonHostMode(t *testing.T) {
72 72
 	skip.If(t, testEnv.IsRemoteDaemon())
73 73
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
74 74
 
75
+	t.Parallel()
76
+
75 77
 	ctx := testutil.StartSpan(baseContext, t)
76 78
 
77 79
 	// When the daemon defaults to host cgroup namespaces, containers
... ...
@@ -85,6 +91,8 @@ func TestCgroupNamespacesRunHostMode(t *testing.T) {
85 85
 	skip.If(t, testEnv.IsRemoteDaemon())
86 86
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
87 87
 
88
+	t.Parallel()
89
+
88 90
 	ctx := testutil.StartSpan(baseContext, t)
89 91
 
90 92
 	// When the daemon defaults to private cgroup namespaces, containers launched
... ...
@@ -98,6 +106,8 @@ func TestCgroupNamespacesRunPrivateMode(t *testing.T) {
98 98
 	skip.If(t, testEnv.IsRemoteDaemon())
99 99
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
100 100
 
101
+	t.Parallel()
102
+
101 103
 	ctx := testutil.StartSpan(baseContext, t)
102 104
 
103 105
 	// When the daemon defaults to private cgroup namespaces, containers launched
... ...
@@ -111,6 +121,8 @@ func TestCgroupNamespacesRunPrivilegedAndPrivate(t *testing.T) {
111 111
 	skip.If(t, testEnv.IsRemoteDaemon())
112 112
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
113 113
 
114
+	t.Parallel()
115
+
114 116
 	ctx := testutil.StartSpan(baseContext, t)
115 117
 
116 118
 	containerCgroup, daemonCgroup := testRunWithCgroupNs(ctx, t, "private", container.WithPrivileged(true), container.WithCgroupnsMode("private"))
... ...
@@ -122,6 +134,8 @@ func TestCgroupNamespacesRunInvalidMode(t *testing.T) {
122 122
 	skip.If(t, testEnv.IsRemoteDaemon())
123 123
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
124 124
 
125
+	t.Parallel()
126
+
125 127
 	ctx := testutil.StartSpan(baseContext, t)
126 128
 
127 129
 	// An invalid cgroup namespace mode should return an error on container creation
... ...
@@ -136,12 +150,14 @@ func TestCgroupNamespacesRunOlderClient(t *testing.T) {
136 136
 	skip.If(t, testEnv.IsRemoteDaemon())
137 137
 	skip.If(t, !requirement.CgroupNamespacesEnabled())
138 138
 
139
+	t.Parallel()
140
+
139 141
 	ctx := testutil.StartSpan(baseContext, t)
140 142
 
141 143
 	d := daemon.New(t, daemon.WithEnvVars("DOCKER_MIN_API_VERSION=1.39"), daemon.WithDefaultCgroupNamespaceMode("private"))
142 144
 	apiClient := d.NewClientT(t, client.WithAPIVersion("1.39"))
143 145
 
144
-	d.StartWithBusybox(ctx, t)
146
+	d.StartWithBusybox(ctx, t, "--iptables=false", "--ip6tables=false")
145 147
 	defer d.Stop(t)
146 148
 
147 149
 	cID := container.Run(ctx, t, apiClient)
... ...
@@ -23,6 +23,8 @@ func TestNRIContainerCreateEnvVarMod(t *testing.T) {
23 23
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "cannot start a separate daemon with NRI enabled on Windows")
24 24
 	skip.If(t, testEnv.IsRootless)
25 25
 
26
+	t.Parallel()
27
+
26 28
 	ctx := testutil.StartSpan(baseContext, t)
27 29
 
28 30
 	sockPath := filepath.Join(t.TempDir(), "nri.sock")
... ...
@@ -78,6 +80,8 @@ func TestNRIContainerCreateUnsupportedAdj(t *testing.T) {
78 78
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "cannot start a separate daemon with NRI enabled on Windows")
79 79
 	skip.If(t, testEnv.IsRootless)
80 80
 
81
+	t.Parallel()
82
+
81 83
 	ctx := testutil.StartSpan(baseContext, t)
82 84
 
83 85
 	sockPath := filepath.Join(t.TempDir(), "nri.sock")
... ...
@@ -138,6 +142,8 @@ func TestNRIContainerCreateAddMount(t *testing.T) {
138 138
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "cannot start a separate daemon with NRI enabled on Windows")
139 139
 	skip.If(t, testEnv.IsRootless)
140 140
 
141
+	t.Parallel()
142
+
141 143
 	ctx := testutil.StartSpan(baseContext, t)
142 144
 
143 145
 	sockPath := filepath.Join(t.TempDir(), "nri.sock")
... ...
@@ -258,6 +264,8 @@ func TestNRIReload(t *testing.T) {
258 258
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "cannot start a separate daemon with NRI enabled on Windows")
259 259
 	skip.If(t, testEnv.IsRootless)
260 260
 
261
+	t.Parallel()
262
+
261 263
 	ctx := testutil.StartSpan(baseContext, t)
262 264
 
263 265
 	const pluginName = "00-nri-test-plugin"
... ...
@@ -56,9 +56,11 @@ func TestUsernsCommit(t *testing.T) {
56 56
 	skip.If(t, !testEnv.IsUserNamespaceInKernel())
57 57
 	skip.If(t, testEnv.IsRootless())
58 58
 
59
+	t.Parallel()
60
+
59 61
 	ctx := context.Background()
60 62
 	dUserRemap := daemon.New(t, daemon.WithUserNsRemap("default"))
61
-	dUserRemap.StartWithBusybox(ctx, t)
63
+	dUserRemap.StartWithBusybox(ctx, t, "--iptables=false", "--ip6tables=false")
62 64
 	clientUserRemap := dUserRemap.NewClientT(t)
63 65
 	defer clientUserRemap.Close()
64 66
 
... ...
@@ -24,6 +24,8 @@ func TestDiskUsageConcurrentPrune(t *testing.T) {
24 24
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
25 25
 	skip.If(t, !testEnv.UsingSnapshotter(), "only happens with containerd image store")
26 26
 
27
+	t.Parallel()
28
+
27 29
 	ctx := testutil.StartSpan(baseContext, t)
28 30
 
29 31
 	d := daemon.New(t)
... ...
@@ -18,6 +18,8 @@ import (
18 18
 func TestDiskUsage(t *testing.T) {
19 19
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows") // d.Start fails on Windows with `protocol not available`
20 20
 
21
+	t.Parallel()
22
+
21 23
 	ctx := testutil.StartSpan(baseContext, t)
22 24
 
23 25
 	d := daemon.New(t)
... ...
@@ -45,12 +45,14 @@ func TestInfoAPIWarnings(t *testing.T) {
45 45
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
46 46
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
47 47
 
48
+	t.Parallel()
49
+
48 50
 	ctx := testutil.StartSpan(baseContext, t)
49 51
 
50 52
 	d := daemon.New(t)
51 53
 	c := d.NewClientT(t)
52 54
 
53
-	d.Start(t, "-H=0.0.0.0:23756", "-H="+d.Sock())
55
+	d.Start(t, "-H=0.0.0.0:23756", "-H="+d.Sock(), "--iptables=false", "--ip6tables=false")
54 56
 	defer d.Stop(t)
55 57
 
56 58
 	result, err := c.Info(ctx, client.InfoOptions{})
... ...
@@ -73,10 +75,12 @@ func TestInfoDebug(t *testing.T) {
73 73
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
74 74
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME: test starts daemon with -H unix://.....")
75 75
 
76
+	t.Parallel()
77
+
76 78
 	_ = testutil.StartSpan(baseContext, t)
77 79
 
78 80
 	d := daemon.New(t)
79
-	d.Start(t, "--debug")
81
+	d.Start(t, "--debug", "--iptables=false", "--ip6tables=false")
80 82
 	defer d.Stop(t)
81 83
 
82 84
 	info := d.Info(t)
... ...
@@ -95,13 +99,15 @@ func TestInfoInsecureRegistries(t *testing.T) {
95 95
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
96 96
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME: test starts daemon with -H unix://.....")
97 97
 
98
+	t.Parallel()
99
+
98 100
 	const (
99 101
 		registryCIDR = "192.168.1.0/24"
100 102
 		registryHost = "insecurehost.com:5000"
101 103
 	)
102 104
 
103 105
 	d := daemon.New(t)
104
-	d.Start(t, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
106
+	d.Start(t, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost, "--iptables=false", "--ip6tables=false")
105 107
 	defer d.Stop(t)
106 108
 
107 109
 	info := d.Info(t)
... ...
@@ -122,13 +128,15 @@ func TestInfoRegistryMirrors(t *testing.T) {
122 122
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
123 123
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME: test starts daemon with -H unix://.....")
124 124
 
125
+	t.Parallel()
126
+
125 127
 	const (
126 128
 		registryMirror1 = "https://192.168.1.2"
127 129
 		registryMirror2 = "http://registry-mirror.example.com:5000"
128 130
 	)
129 131
 
130 132
 	d := daemon.New(t)
131
-	d.Start(t, "--registry-mirror="+registryMirror1, "--registry-mirror="+registryMirror2)
133
+	d.Start(t, "--registry-mirror="+registryMirror1, "--registry-mirror="+registryMirror2, "--iptables=false", "--ip6tables=false")
132 134
 	defer d.Stop(t)
133 135
 
134 136
 	info := d.Info(t)
... ...
@@ -101,14 +101,16 @@ func TestPingBuilderHeader(t *testing.T) {
101 101
 	skip.If(t, testEnv.IsRemoteDaemon)
102 102
 	skip.If(t, testEnv.DaemonInfo.OSType == "windows", "cannot spin up additional daemons on windows")
103 103
 
104
-	ctx := setupTest(t)
104
+	t.Parallel()
105
+
106
+	ctx := testutil.StartSpan(baseContext, t)
105 107
 	d := daemon.New(t)
106 108
 	apiClient := d.NewClientT(t)
107 109
 	defer apiClient.Close()
108 110
 
109 111
 	t.Run("default config", func(t *testing.T) {
110 112
 		testutil.StartSpan(ctx, t)
111
-		d.Start(t)
113
+		d.Start(t, "--iptables=false", "--ip6tables=false")
112 114
 		defer d.Stop(t)
113 115
 
114 116
 		expected := build.BuilderBuildKit
... ...
@@ -126,7 +128,7 @@ func TestPingBuilderHeader(t *testing.T) {
126 126
 		cfg := filepath.Join(d.RootDir(), "daemon.json")
127 127
 		err := os.WriteFile(cfg, []byte(`{"features": { "buildkit": false }}`), 0o644)
128 128
 		assert.NilError(t, err)
129
-		d.Start(t, "--config-file", cfg)
129
+		d.Start(t, "--config-file", cfg, "--iptables=false", "--ip6tables=false")
130 130
 		defer d.Stop(t)
131 131
 
132 132
 		expected := build.BuilderV1
... ...
@@ -436,6 +436,8 @@ func TestRunMountImageSubpathDaemonRestart(t *testing.T) {
436 436
 	skip.If(t, testEnv.IsRootless, "FIXME: https://github.com/moby/moby/issues/50999")
437 437
 	skip.If(t, !testEnv.UsingSnapshotter(), "FIXME: https://github.com/moby/moby/issues/50999")
438 438
 
439
+	t.Parallel()
440
+
439 441
 	ctx := testutil.StartSpan(baseContext, t)
440 442
 
441 443
 	d := daemon.New(t)