Skip to content

Commit

Permalink
integration/container: use ipv4 for some tests to reduce flakiness
Browse files Browse the repository at this point in the history
I noticed when updating libnetwork, that the s390x and ppc64le machines have
IPv6 enabled, and wondered if this could be responsible for the flakiness
in these tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Aug 26, 2022
1 parent 3e8573a commit fb6299a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions integration/container/nat_test.go
Expand Up @@ -29,7 +29,7 @@ func TestNetworkNat(t *testing.T) {
startServerContainer(t, msg, 8080)

endpoint := getExternalAddress(t)
conn, err := net.Dial("tcp", net.JoinHostPort(endpoint.String(), "8080"))
conn, err := net.Dial("tcp4", net.JoinHostPort(endpoint.String(), "8080"))
assert.NilError(t, err)
defer conn.Close()

Expand All @@ -46,7 +46,7 @@ func TestNetworkLocalhostTCPNat(t *testing.T) {
msg := "hi yall"
startServerContainer(t, msg, 8081)

conn, err := net.Dial("tcp", "localhost:8081")
conn, err := net.Dial("tcp4", "localhost:8081")
assert.NilError(t, err)
defer conn.Close()

Expand All @@ -70,7 +70,7 @@ func TestNetworkLoopbackNat(t *testing.T) {
ctx := context.Background()

cID := container.Run(ctx, t, client,
container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -w 1 %s 8080", endpoint.String())),
container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -4 -w 1 %s 8080", endpoint.String())),
container.WithTty(true),
container.WithNetworkMode("container:"+serverContainerID),
)
Expand Down
2 changes: 1 addition & 1 deletion integration/container/rename_test.go
Expand Up @@ -159,7 +159,7 @@ func TestRenameAnonymousContainer(t *testing.T) {
networkName: {},
}
c.HostConfig.NetworkMode = containertypes.NetworkMode(networkName)
}, container.WithCmd("ping", count, "1", container1Name))
}, container.WithCmd("ping", "-4", count, "1", container1Name))
poll.WaitOn(t, container.IsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond))

inspect, err := client.ContainerInspect(ctx, cID)
Expand Down
6 changes: 3 additions & 3 deletions integration/container/run_linux_test.go
Expand Up @@ -85,15 +85,15 @@ func TestHostnameDnsResolution(t *testing.T) {

const (
hostname = "foobar"
netName = "foobar-net"
)

// using user defined network as we want to use internal DNS
netName := "foobar-net"
net.CreateNoError(context.Background(), t, client, netName, net.WithDriver("bridge"))

cID := container.Run(ctx, t, client, func(c *container.TestContainerConfig) {
c.Config.Hostname = hostname
c.HostConfig.NetworkMode = containertypes.NetworkMode(netName)
c.HostConfig.NetworkMode = netName
})

poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
Expand All @@ -104,7 +104,7 @@ func TestHostnameDnsResolution(t *testing.T) {

// Clear hosts file so ping will use DNS for hostname resolution
res, err := container.Exec(ctx, client, cID,
[]string{"sh", "-c", "echo 127.0.0.1 localhost | tee /etc/hosts && ping -c 1 foobar"})
[]string{"sh", "-c", "echo 127.0.0.1 localhost | tee /etc/hosts && ping -4 -c 1 foobar"})
assert.NilError(t, err)
assert.Check(t, is.Equal("", res.Stderr()))
assert.Equal(t, 0, res.ExitCode)
Expand Down

0 comments on commit fb6299a

Please sign in to comment.