Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove broken integration-cli IPv6 tests #47788

Merged
merged 3 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 0 additions & 70 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,65 +282,6 @@ func verifyIPTablesDoesNotContains(c *testing.T, ipTablesSearchString string) {
}
}

// TestDaemonIPv6Enabled checks that when the daemon is started with --ipv6=true that the docker0 bridge
// has the fe80::1 address and that a container is assigned a link-local address
func (s *DockerDaemonSuite) TestDaemonIPv6Enabled(c *testing.T) {
testRequires(c, IPv6)

setupV6(c)
defer teardownV6(c)

s.d.StartWithBusybox(testutil.GetContext(c), c, "--ipv6")

iface, err := net.InterfaceByName("docker0")
if err != nil {
c.Fatalf("Error getting docker0 interface: %v", err)
}

addrs, err := iface.Addrs()
if err != nil {
c.Fatalf("Error getting addresses for docker0 interface: %v", err)
}

var found bool
expected := "fe80::1/64"

for i := range addrs {
if addrs[i].String() == expected {
found = true
break
}
}

if !found {
c.Fatalf("Bridge does not have an IPv6 Address")
}

if out, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "busybox:latest"); err != nil {
c.Fatalf("Could not run container: %s, %v", out, err)
}

out, err := s.d.Cmd("inspect", "--format", "'{{.NetworkSettings.Networks.bridge.LinkLocalIPv6Address}}'", "ipv6test")
if err != nil {
c.Fatalf("Error inspecting container: %s, %v", out, err)
}
out = strings.Trim(out, " \r\n'")

if ip := net.ParseIP(out); ip == nil {
c.Fatalf("Container should have a link-local IPv6 address")
}

out, err = s.d.Cmd("inspect", "--format", "'{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}'", "ipv6test")
if err != nil {
c.Fatalf("Error inspecting container: %s, %v", out, err)
}
out = strings.Trim(out, " \r\n'")

if ip := net.ParseIP(out); ip != nil {
c.Fatalf("Container should not have a global IPv6 address: %v", out)
}
}

// TestDaemonIPv6FixedCIDR checks that when the daemon is started with --ipv6=true and a fixed CIDR
// that running containers are given a link-local and global IPv6 address
func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *testing.T) {
Expand Down Expand Up @@ -1442,17 +1383,6 @@ func (s *DockerDaemonSuite) TestDaemonTLSVerifyIssue13964(c *testing.T) {
})
}

func setupV6(c *testing.T) {
// Hack to get the right IPv6 address on docker0, which has already been created
result := icmd.RunCommand("ip", "addr", "add", "fe80::1/64", "dev", "docker0")
result.Assert(c, icmd.Success)
}

func teardownV6(c *testing.T) {
result := icmd.RunCommand("ip", "addr", "del", "fe80::1/64", "dev", "docker0")
result.Assert(c, icmd.Success)
}

func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlways(c *testing.T) {
s.d.StartWithBusybox(testutil.GetContext(c), c)

Expand Down
8 changes: 5 additions & 3 deletions integration-cli/docker_cli_swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *testing.T) {
}

func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *testing.T) {
testRequires(c, IPv6)
robmry marked this conversation as resolved.
Show resolved Hide resolved
ctx := testutil.GetContext(c)
d1 := s.AddDaemon(ctx, c, false, false)
cli.Docker(cli.Args("swarm", "init", "--listen-add", "::1"), cli.Daemon(d1)).Assert(c, icmd.Success)
cli.Docker(cli.Args("swarm", "init", "--listen-addr", "::1"),
cli.Daemon(d1)).Assert(c, icmd.Success)

token := s.daemons[0].JoinTokens(c).Worker
d2 := s.AddDaemon(ctx, c, false, false)
cli.Docker(cli.Args("swarm", "join", "::1"), cli.Daemon(d2)).Assert(c, icmd.Success)
cli.Docker(cli.Args("swarm", "join", "[::1]", "--token", token),
cli.Daemon(d2)).Assert(c, icmd.Success)

out := cli.Docker(cli.Args("info"), cli.Daemon(d2)).Assert(c, icmd.Success).Combined()
assert.Assert(c, strings.Contains(out, "Swarm: active"))
Expand Down
5 changes: 0 additions & 5 deletions integration-cli/requirements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ func containerdSnapshotterEnabled() bool {
return false
}

func IPv6() bool {
cmd := exec.Command("test", "-f", "/proc/net/if_inet6")
return cmd.Run() != nil
}

func UserNamespaceROMount() bool {
// quick case--userns not enabled in this test run
if os.Getenv("DOCKER_REMAP_ROOT") == "" {
Expand Down