Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
| ... | ... |
@@ -62,14 +62,14 @@ func TestNetworkLoopbackNat(t *testing.T) {
|
| 62 | 62 |
defer setupTest(t)() |
| 63 | 63 |
|
| 64 | 64 |
msg := "it works" |
| 65 |
- startServerContainer(t, msg, 8080) |
|
| 65 |
+ serverContainerID := startServerContainer(t, msg, 8080) |
|
| 66 | 66 |
|
| 67 | 67 |
endpoint := getExternalAddress(t) |
| 68 | 68 |
|
| 69 | 69 |
client := request.NewAPIClient(t) |
| 70 | 70 |
ctx := context.Background() |
| 71 | 71 |
|
| 72 |
- cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -w 5 %s 8080", endpoint.String())), container.WithTty(true), container.WithNetworkMode("container:server"))
|
|
| 72 |
+ cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -w 5 %s 8080", endpoint.String())), container.WithTty(true), container.WithNetworkMode("container:"+serverContainerID))
|
|
| 73 | 73 |
|
| 74 | 74 |
poll.WaitOn(t, container.IsStopped(ctx, client, cID), poll.WithDelay(100*time.Millisecond)) |
| 75 | 75 |
|
| ... | ... |
@@ -90,7 +90,7 @@ func startServerContainer(t *testing.T, msg string, port int) string {
|
| 90 | 90 |
client := request.NewAPIClient(t) |
| 91 | 91 |
ctx := context.Background() |
| 92 | 92 |
|
| 93 |
- cID := container.Run(t, ctx, client, container.WithName("server"), container.WithCmd("sh", "-c", fmt.Sprintf("echo %q | nc -lp %d", msg, port)), container.WithExposedPorts(fmt.Sprintf("%d/tcp", port)), func(c *container.TestContainerConfig) {
|
|
| 93 |
+ cID := container.Run(t, ctx, client, container.WithName("server-"+t.Name()), container.WithCmd("sh", "-c", fmt.Sprintf("echo %q | nc -lp %d", msg, port)), container.WithExposedPorts(fmt.Sprintf("%d/tcp", port)), func(c *container.TestContainerConfig) {
|
|
| 94 | 94 |
c.HostConfig.PortBindings = nat.PortMap{
|
| 95 | 95 |
nat.Port(fmt.Sprintf("%d/tcp", port)): []nat.PortBinding{
|
| 96 | 96 |
{
|