MCPcopy
hub / github.com/containerd/containerd / TestPodDualStack

Function TestPodDualStack

integration/pod_dualstack_test.go:34–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32)
33
34func TestPodDualStack(t *testing.T) {
35 testPodLogDir := t.TempDir()
36
37 t.Log("Create a sandbox")
38 sb, sbConfig := PodSandboxConfigWithCleanup(t, "sandbox", "dualstack", WithPodLogDirectory(testPodLogDir))
39
40 var (
41 testImage = images.Get(images.BusyBox)
42 containerName = "test-container"
43 )
44
45 EnsureImageExists(t, testImage)
46
47 t.Log("Create a container to print env")
48 var command ContainerOpts
49 if goruntime.GOOS == "windows" {
50 command = WithCommand("ipconfig")
51 } else {
52 command = WithCommand("ip", "address", "show", "dev", "eth0")
53 }
54 cnConfig := ContainerConfig(
55 containerName,
56 testImage,
57 command,
58 WithLogPath(containerName),
59 )
60 cn, err := runtimeService.CreateContainer(sb, cnConfig, sbConfig)
61 require.NoError(t, err)
62
63 t.Log("Start the container")
64 require.NoError(t, runtimeService.StartContainer(cn))
65
66 t.Log("Wait for container to finish running")
67 require.NoError(t, Eventually(func() (bool, error) {
68 s, err := runtimeService.ContainerStatus(cn)
69 if err != nil {
70 return false, err
71 }
72 if s.GetState() == runtime.ContainerState_CONTAINER_EXITED {
73 return true, nil
74 }
75 return false, nil
76 }, time.Second, 30*time.Second))
77
78 content, err := os.ReadFile(filepath.Join(testPodLogDir, containerName))
79 assert.NoError(t, err)
80 status, err := runtimeService.PodSandboxStatus(sb)
81 require.NoError(t, err)
82 ip := status.GetNetwork().GetIp()
83 additionalIps := status.GetNetwork().GetAdditionalIps()
84
85 var ipv4Regex, ipv6Regex string
86 if goruntime.GOOS == "windows" {
87 ipv4Regex = "^\\s*IPv4 Address"
88 ipv6Regex = "^\\s*IPv6 Address"
89 } else {
90 ipv4Regex = "inet .* scope global"
91 ipv6Regex = "inet6 .* scope global"

Callers

nothing calls this directly

Calls 15

GetFunction · 0.92
WithPodLogDirectoryFunction · 0.85
EnsureImageExistsFunction · 0.85
WithCommandFunction · 0.85
ContainerConfigFunction · 0.85
WithLogPathFunction · 0.85
EventuallyFunction · 0.85
LogMethod · 0.80
MatchStringMethod · 0.80
CreateContainerMethod · 0.65
StartContainerMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…