Skip to content

Commit

Permalink
Fix TestDockerSwarmSuite/TestSwarmInitIPv6
Browse files Browse the repository at this point in the history
The test hadn't been running, because it used testRequires(c, IPv6)
and predicate "IPv6" returns the opposite of the expected result.

If the test had run, it'd have failed because:
- it used "--listen-add", but the option is "--listen-addr"
  - so, the daemon wouldn't have started
- it tried to use "--join ::1"
  - address "::1" was interpreted as host:port so the Dial() failed,
    it needed to be "[::1]".
  - it didn't supply a  join token

Signed-off-by: Rob Murray <rob.murray@docker.com>
  • Loading branch information
robmry committed May 1, 2024
1 parent 9d07820 commit 346a7c0
Showing 1 changed file with 5 additions and 3 deletions.
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)
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

0 comments on commit 346a7c0

Please sign in to comment.