(t *testing.T)
| 32 | ) |
| 33 | |
| 34 | func 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" |
nothing calls this directly
no test coverage detected
searching dependent graphs…