MCPcopy
hub / github.com/moby/moby / TestStaticIPOutsideSubpool

Function TestStaticIPOutsideSubpool

integration/container/run_linux_test.go:304–339  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

302}
303
304func TestStaticIPOutsideSubpool(t *testing.T) {
305 skip.If(t, testEnv.IsRemoteDaemon)
306 skip.If(t, testEnv.DaemonInfo.OSType != "linux")
307
308 ctx := testutil.StartSpan(baseContext, t)
309
310 d := daemon.New(t)
311 d.StartWithBusybox(ctx, t)
312 defer d.Stop(t)
313
314 apiClient, err := client.New(client.FromEnv, client.WithAPIVersion("1.43"))
315 assert.NilError(t, err)
316
317 const netname = "subnet-range"
318 n := net.CreateNoError(ctx, t, apiClient, netname, net.WithIPAMRange("10.42.0.0/16", "10.42.128.0/24", "10.42.0.1"))
319 defer net.RemoveNoError(ctx, t, apiClient, n)
320
321 cID := container.Run(ctx, t, apiClient,
322 container.WithImage("busybox:latest"),
323 container.WithCmd("sh", "-c", `ip -4 -oneline addr show eth0`),
324 container.WithNetworkMode(netname),
325 container.WithIPv4(netname, "10.42.1.3"),
326 )
327
328 poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID))
329
330 out, err := apiClient.ContainerLogs(ctx, cID, client.ContainerLogsOptions{ShowStdout: true})
331 assert.NilError(t, err)
332 defer out.Close()
333
334 var b bytes.Buffer
335 _, err = io.Copy(&b, out)
336 assert.NilError(t, err)
337
338 assert.Check(t, is.Contains(b.String(), "inet 10.42.1.3/16"))
339}
340
341func TestWorkingDirNormalization(t *testing.T) {
342 ctx := setupTest(t)

Callers

nothing calls this directly

Calls 15

StartSpanFunction · 0.92
NewFunction · 0.92
RunFunction · 0.92
WithImageFunction · 0.92
WithCmdFunction · 0.92
WithNetworkModeFunction · 0.92
WithIPv4Function · 0.92
IsStoppedFunction · 0.92
StartWithBusyboxMethod · 0.80
CheckMethod · 0.80
NewMethod · 0.65
ContainerLogsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…