Browse code

Fix TestDockerSwarmSuite/TestSwarmInitIPv6

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>

Rob Murray authored on 2024/05/02 03:09:54
Showing 1 changed files
... ...
@@ -130,13 +130,15 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *testing.T) {
130 130
 }
131 131
 
132 132
 func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *testing.T) {
133
-	testRequires(c, IPv6)
134 133
 	ctx := testutil.GetContext(c)
135 134
 	d1 := s.AddDaemon(ctx, c, false, false)
136
-	cli.Docker(cli.Args("swarm", "init", "--listen-add", "::1"), cli.Daemon(d1)).Assert(c, icmd.Success)
135
+	cli.Docker(cli.Args("swarm", "init", "--listen-addr", "::1"),
136
+		cli.Daemon(d1)).Assert(c, icmd.Success)
137 137
 
138
+	token := s.daemons[0].JoinTokens(c).Worker
138 139
 	d2 := s.AddDaemon(ctx, c, false, false)
139
-	cli.Docker(cli.Args("swarm", "join", "::1"), cli.Daemon(d2)).Assert(c, icmd.Success)
140
+	cli.Docker(cli.Args("swarm", "join", "[::1]", "--token", token),
141
+		cli.Daemon(d2)).Assert(c, icmd.Success)
140 142
 
141 143
 	out := cli.Docker(cli.Args("info"), cli.Daemon(d2)).Assert(c, icmd.Success).Combined()
142 144
 	assert.Assert(c, strings.Contains(out, "Swarm: active"))