(t *testing.T)
| 79 | } |
| 80 | |
| 81 | func TestNetworkLoopbackNat(t *testing.T) { |
| 82 | skip.If(t, testEnv.GitHubActions, "FIXME: https://github.com/moby/moby/issues/41561") |
| 83 | skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME") |
| 84 | skip.If(t, testEnv.IsRemoteDaemon) |
| 85 | |
| 86 | ctx := setupTest(t) |
| 87 | |
| 88 | msg := "it works" |
| 89 | serverContainerID := startServerContainer(ctx, t, msg, 8080) |
| 90 | |
| 91 | endpoint := getExternalAddress(t) |
| 92 | |
| 93 | apiClient := testEnv.APIClient() |
| 94 | |
| 95 | cID := container.Run(ctx, t, apiClient, |
| 96 | container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -w 1 %s 8080", endpoint.String())), |
| 97 | container.WithTty(true), |
| 98 | container.WithNetworkMode("container:"+serverContainerID), |
| 99 | ) |
| 100 | |
| 101 | poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID)) |
| 102 | |
| 103 | logs, err := apiClient.ContainerLogs(ctx, cID, client.ContainerLogsOptions{ |
| 104 | ShowStdout: true, |
| 105 | }) |
| 106 | assert.NilError(t, err) |
| 107 | defer logs.Close() |
| 108 | |
| 109 | var b bytes.Buffer |
| 110 | _, err = io.Copy(&b, logs) |
| 111 | assert.NilError(t, err) |
| 112 | |
| 113 | assert.Check(t, is.Equal(msg, strings.TrimSpace(b.String()))) |
| 114 | } |
| 115 | |
| 116 | func startServerContainer(ctx context.Context, t *testing.T, msg string, port uint16) string { |
| 117 | t.Helper() |
nothing calls this directly
no test coverage detected
searching dependent graphs…