Browse code

integration-cli: DockerSwarmSuite: show output on failures

Unfortunately quite some of these tests do output-matching, which
may be CLI dependent; this patch prints the output string, to help
debugging failures that may be related to the output having changed
between CLI versions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/10/08 04:24:06
Showing 1 changed files
... ...
@@ -210,19 +210,19 @@ func (s *DockerSwarmSuite) TestSwarmServiceListFilter(c *testing.T) {
210 210
 	// We search checker.Contains with `name+" "` to prevent prefix only.
211 211
 	out, err = d.Cmd("service", "ls", "--filter", filter1)
212 212
 	assert.NilError(c, err, out)
213
-	assert.Assert(c, strings.Contains(out, name1+" "))
214
-	assert.Assert(c, !strings.Contains(out, name2+" "))
215
-	assert.Assert(c, !strings.Contains(out, name3+" "))
213
+	assert.Assert(c, strings.Contains(out, name1+" "), out)
214
+	assert.Assert(c, !strings.Contains(out, name2+" "), out)
215
+	assert.Assert(c, !strings.Contains(out, name3+" "), out)
216 216
 	out, err = d.Cmd("service", "ls", "--filter", filter2)
217 217
 	assert.NilError(c, err, out)
218
-	assert.Assert(c, strings.Contains(out, name1+" "))
219
-	assert.Assert(c, strings.Contains(out, name2+" "))
220
-	assert.Assert(c, !strings.Contains(out, name3+" "))
218
+	assert.Assert(c, strings.Contains(out, name1+" "), out)
219
+	assert.Assert(c, strings.Contains(out, name2+" "), out)
220
+	assert.Assert(c, !strings.Contains(out, name3+" "), out)
221 221
 	out, err = d.Cmd("service", "ls")
222 222
 	assert.NilError(c, err, out)
223
-	assert.Assert(c, strings.Contains(out, name1+" "))
224
-	assert.Assert(c, strings.Contains(out, name2+" "))
225
-	assert.Assert(c, strings.Contains(out, name3+" "))
223
+	assert.Assert(c, strings.Contains(out, name1+" "), out)
224
+	assert.Assert(c, strings.Contains(out, name2+" "), out)
225
+	assert.Assert(c, strings.Contains(out, name3+" "), out)
226 226
 }
227 227
 
228 228
 func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *testing.T) {
... ...
@@ -237,10 +237,10 @@ func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *testing.T) {
237 237
 
238 238
 	out, err = d.Cmd("node", "ls", "--filter", filter)
239 239
 	assert.NilError(c, err, out)
240
-	assert.Assert(c, strings.Contains(out, name))
240
+	assert.Assert(c, strings.Contains(out, name), out)
241 241
 	out, err = d.Cmd("node", "ls", "--filter", "name=none")
242 242
 	assert.NilError(c, err, out)
243
-	assert.Assert(c, !strings.Contains(out, name))
243
+	assert.Assert(c, !strings.Contains(out, name), out)
244 244
 }
245 245
 
246 246
 func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *testing.T) {
... ...
@@ -258,14 +258,14 @@ func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *testing.T) {
258 258
 
259 259
 	out, err = d.Cmd("node", "ps", "--filter", filter, "self")
260 260
 	assert.NilError(c, err, out)
261
-	assert.Assert(c, strings.Contains(out, name+".1"))
262
-	assert.Assert(c, strings.Contains(out, name+".2"))
263
-	assert.Assert(c, strings.Contains(out, name+".3"))
261
+	assert.Assert(c, strings.Contains(out, name+".1"), out)
262
+	assert.Assert(c, strings.Contains(out, name+".2"), out)
263
+	assert.Assert(c, strings.Contains(out, name+".3"), out)
264 264
 	out, err = d.Cmd("node", "ps", "--filter", "name=none", "self")
265 265
 	assert.NilError(c, err, out)
266
-	assert.Assert(c, !strings.Contains(out, name+".1"))
267
-	assert.Assert(c, !strings.Contains(out, name+".2"))
268
-	assert.Assert(c, !strings.Contains(out, name+".3"))
266
+	assert.Assert(c, !strings.Contains(out, name+".1"), out)
267
+	assert.Assert(c, !strings.Contains(out, name+".2"), out)
268
+	assert.Assert(c, !strings.Contains(out, name+".3"), out)
269 269
 }
270 270
 
271 271
 // Test case for #25375
... ...
@@ -437,7 +437,7 @@ func (s *DockerSwarmSuite) TestOverlayAttachableOnSwarmLeave(c *testing.T) {
437 437
 	// Check the network is gone
438 438
 	out, err = d.Cmd("network", "ls", "--format", "{{.Name}}")
439 439
 	assert.NilError(c, err, out)
440
-	assert.Assert(c, !strings.Contains(out, nwName))
440
+	assert.Assert(c, !strings.Contains(out, nwName), out)
441 441
 }
442 442
 
443 443
 func (s *DockerSwarmSuite) TestOverlayAttachableReleaseResourcesOnFailure(c *testing.T) {
... ...
@@ -484,7 +484,7 @@ func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *testing.T) {
484 484
 	// But only one is allowed
485 485
 	out, err = d.Cmd("network", "create", "-d", "overlay", "--ingress", "another-ingress")
486 486
 	assert.ErrorContains(c, err, "")
487
-	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "is already present"))
487
+	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "is already present"), out)
488 488
 	// It cannot be removed if it is being used
489 489
 	out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv1", "-p", "9000:8000", "busybox", "top")
490 490
 	assert.NilError(c, err, out)
... ...
@@ -505,11 +505,11 @@ func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *testing.T) {
505 505
 	// A service which needs the ingress network cannot be created if no ingress is present
506 506
 	out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv2", "-p", "500:500", "busybox", "top")
507 507
 	assert.ErrorContains(c, err, "")
508
-	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "no ingress network is present"))
508
+	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "no ingress network is present"), out)
509 509
 	// An existing service cannot be updated to use the ingress nw if the nw is not present
510 510
 	out, err = d.Cmd("service", "update", "--detach", "--publish-add", "9000:8000", "srv1")
511 511
 	assert.ErrorContains(c, err, "")
512
-	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "no ingress network is present"))
512
+	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "no ingress network is present"), out)
513 513
 	// But services which do not need routing mesh can be created regardless
514 514
 	out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv3", "--endpoint-mode", "dnsrr", "busybox", "top")
515 515
 	assert.NilError(c, err, out)
... ...
@@ -555,19 +555,19 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *testing.T) {
555 555
 
556 556
 	out, err = d.Cmd("service", "ps", "--filter", filter, name)
557 557
 	assert.NilError(c, err, out)
558
-	assert.Assert(c, strings.Contains(out, name+".1"))
559
-	assert.Assert(c, strings.Contains(out, name+".2"))
560
-	assert.Assert(c, strings.Contains(out, name+".3"))
558
+	assert.Assert(c, strings.Contains(out, name+".1"), out)
559
+	assert.Assert(c, strings.Contains(out, name+".2"), out)
560
+	assert.Assert(c, strings.Contains(out, name+".3"), out)
561 561
 	out, err = d.Cmd("service", "ps", "--filter", "name="+name+".1", name)
562 562
 	assert.NilError(c, err, out)
563
-	assert.Assert(c, strings.Contains(out, name+".1"))
564
-	assert.Assert(c, !strings.Contains(out, name+".2"))
565
-	assert.Assert(c, !strings.Contains(out, name+".3"))
563
+	assert.Assert(c, strings.Contains(out, name+".1"), out)
564
+	assert.Assert(c, !strings.Contains(out, name+".2"), out)
565
+	assert.Assert(c, !strings.Contains(out, name+".3"), out)
566 566
 	out, err = d.Cmd("service", "ps", "--filter", "name=none", name)
567 567
 	assert.NilError(c, err, out)
568
-	assert.Assert(c, !strings.Contains(out, name+".1"))
569
-	assert.Assert(c, !strings.Contains(out, name+".2"))
570
-	assert.Assert(c, !strings.Contains(out, name+".3"))
568
+	assert.Assert(c, !strings.Contains(out, name+".1"), out)
569
+	assert.Assert(c, !strings.Contains(out, name+".2"), out)
570
+	assert.Assert(c, !strings.Contains(out, name+".3"), out)
571 571
 	name = "redis-cluster-sha1"
572 572
 	out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "--mode=global", "busybox", "top")
573 573
 	assert.NilError(c, err, out)
... ...
@@ -578,13 +578,13 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *testing.T) {
578 578
 	filter = "name=redis-cluster"
579 579
 	out, err = d.Cmd("service", "ps", "--filter", filter, name)
580 580
 	assert.NilError(c, err, out)
581
-	assert.Assert(c, strings.Contains(out, name))
581
+	assert.Assert(c, strings.Contains(out, name), out)
582 582
 	out, err = d.Cmd("service", "ps", "--filter", "name="+name, name)
583 583
 	assert.NilError(c, err, out)
584
-	assert.Assert(c, strings.Contains(out, name))
584
+	assert.Assert(c, strings.Contains(out, name), out)
585 585
 	out, err = d.Cmd("service", "ps", "--filter", "name=none", name)
586 586
 	assert.NilError(c, err, out)
587
-	assert.Assert(c, !strings.Contains(out, name))
587
+	assert.Assert(c, !strings.Contains(out, name), out)
588 588
 }
589 589
 
590 590
 func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *testing.T) {
... ...
@@ -803,7 +803,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *testing.T) {
803 803
 
804 804
 	out, err := d.Cmd("network", "create", "-d", globalNetworkPlugin, "foo")
805 805
 	assert.ErrorContains(c, err, "", out)
806
-	assert.Assert(c, strings.Contains(out, "not supported in swarm mode"))
806
+	assert.Assert(c, strings.Contains(out, "not supported in swarm mode"), out)
807 807
 }
808 808
 
809 809
 // Test case for #24712
... ...
@@ -822,7 +822,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *testing.T) {
822 822
 	// The complete env is [VAR1=A VAR2=A VAR1=B VAR1=C VAR2= VAR2] and duplicates will be removed => [VAR1=C VAR2]
823 823
 	out, err = d.Cmd("inspect", "--format", "{{ .Spec.TaskTemplate.ContainerSpec.Env }}", name)
824 824
 	assert.NilError(c, err, out)
825
-	assert.Assert(c, strings.Contains(out, "[VAR1=C VAR2]"))
825
+	assert.Assert(c, strings.Contains(out, "[VAR1=C VAR2]"), out)
826 826
 }
827 827
 
828 828
 func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *testing.T) {
... ...
@@ -1024,8 +1024,9 @@ func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
1024 1024
 	result.Assert(c, icmd.Expected{
1025 1025
 		ExitCode: 1,
1026 1026
 	})
1027
-	assert.Assert(c, strings.Contains(result.Combined(), "Error: This node is not part of a swarm"))
1028
-	assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"))
1027
+	out := result.Combined()
1028
+	assert.Assert(c, strings.Contains(result.Combined(), "Error: This node is not part of a swarm"), out)
1029
+	assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"), out)
1029 1030
 	out, err := d.Cmd("swarm", "init")
1030 1031
 	assert.NilError(c, err, out)
1031 1032
 
... ...
@@ -1035,8 +1036,9 @@ func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
1035 1035
 	result.Assert(c, icmd.Expected{
1036 1036
 		ExitCode: 1,
1037 1037
 	})
1038
-	assert.Assert(c, strings.Contains(result.Combined(), "Error: swarm is not locked"))
1039
-	assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"))
1038
+	out = result.Combined()
1039
+	assert.Assert(c, strings.Contains(result.Combined(), "Error: swarm is not locked"), out)
1040
+	assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"), out)
1040 1041
 }
1041 1042
 
1042 1043
 func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
... ...
@@ -1069,7 +1071,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
1069 1069
 
1070 1070
 	outs, err = d.Cmd("node", "ls")
1071 1071
 	assert.Assert(c, err == nil, outs)
1072
-	assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1072
+	assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1073 1073
 	outs, err = d.Cmd("swarm", "update", "--autolock=false")
1074 1074
 	assert.Assert(c, err == nil, outs)
1075 1075
 
... ...
@@ -1077,7 +1079,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
1077 1077
 
1078 1078
 	outs, err = d.Cmd("node", "ls")
1079 1079
 	assert.Assert(c, err == nil, outs)
1080
-	assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1080
+	assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1081 1081
 }
1082 1082
 
1083 1083
 func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) {
... ...
@@ -1093,10 +1095,10 @@ func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) {
1093 1093
 	assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateLocked)
1094 1094
 
1095 1095
 	outs, _ = d.Cmd("node", "ls")
1096
-	assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1096
+	assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1097 1097
 	// `docker swarm leave` a locked swarm without --force will return an error
1098 1098
 	outs, _ = d.Cmd("swarm", "leave")
1099
-	assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and locked."))
1099
+	assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and locked."), outs)
1100 1100
 	// It is OK for user to leave a locked swarm with --force
1101 1101
 	outs, err = d.Cmd("swarm", "leave", "--force")
1102 1102
 	assert.Assert(c, err == nil, outs)
... ...
@@ -1188,7 +1190,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
1188 1188
 	// promote worker
1189 1189
 	outs, err = d1.Cmd("node", "promote", d2.NodeID())
1190 1190
 	assert.NilError(c, err)
1191
-	assert.Assert(c, strings.Contains(outs, "promoted to a manager in the swarm"))
1191
+	assert.Assert(c, strings.Contains(outs, "promoted to a manager in the swarm"), outs)
1192 1192
 	// join new manager node
1193 1193
 	d3 := s.AddDaemon(c, true, true)
1194 1194
 
... ...
@@ -1205,7 +1207,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
1205 1205
 	// demote manager back to worker - workers are not locked
1206 1206
 	outs, err = d1.Cmd("node", "demote", d3.NodeID())
1207 1207
 	assert.NilError(c, err)
1208
-	assert.Assert(c, strings.Contains(outs, "demoted in the swarm"))
1208
+	assert.Assert(c, strings.Contains(outs, "demoted in the swarm"), outs)
1209 1209
 	// Wait for it to actually be demoted, for the key and cert to be replaced.
1210 1210
 	// Then restart and assert that the node is not locked.  If we don't wait for the cert
1211 1211
 	// to be replaced, then the node still has the manager TLS key which is still locked
... ...
@@ -1249,7 +1251,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
1249 1249
 		assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
1250 1250
 
1251 1251
 		outs, _ = d.Cmd("node", "ls")
1252
-		assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1252
+		assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1253 1253
 		cmd := d.Command("swarm", "unlock")
1254 1254
 		cmd.Stdin = bytes.NewBufferString(unlockKey)
1255 1255
 		result := icmd.RunCmd(cmd)
... ...
@@ -1277,7 +1279,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
1277 1277
 		})
1278 1278
 
1279 1279
 		outs, _ = d.Cmd("node", "ls")
1280
-		assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1280
+		assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1281 1281
 		cmd = d.Command("swarm", "unlock")
1282 1282
 		cmd.Stdin = bytes.NewBufferString(newUnlockKey)
1283 1283
 		icmd.RunCmd(cmd).Assert(c, icmd.Success)
... ...
@@ -1296,7 +1298,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
1296 1296
 				}
1297 1297
 			}
1298 1298
 			assert.NilError(c, err)
1299
-			assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1299
+			assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1300 1300
 			break
1301 1301
 		}
1302 1302
 
... ...
@@ -1339,7 +1341,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
1339 1339
 			assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
1340 1340
 
1341 1341
 			outs, _ := d.Cmd("node", "ls")
1342
-			assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1342
+			assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1343 1343
 			cmd := d.Command("swarm", "unlock")
1344 1344
 			cmd.Stdin = bytes.NewBufferString(unlockKey)
1345 1345
 			result := icmd.RunCmd(cmd)
... ...
@@ -1367,7 +1369,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
1367 1367
 			})
1368 1368
 
1369 1369
 			outs, _ = d.Cmd("node", "ls")
1370
-			assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1370
+			assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1371 1371
 			cmd = d.Command("swarm", "unlock")
1372 1372
 			cmd.Stdin = bytes.NewBufferString(newUnlockKey)
1373 1373
 			icmd.RunCmd(cmd).Assert(c, icmd.Success)
... ...
@@ -1389,7 +1391,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
1389 1389
 					}
1390 1390
 				}
1391 1391
 				assert.NilError(c, err, "[%s] failed after %d retries: %v (%s)", d.ID(), retry, err, outs)
1392
-				assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
1392
+				assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"), outs)
1393 1393
 				break
1394 1394
 			}
1395 1395
 		}
... ...
@@ -1405,7 +1407,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) {
1405 1405
 		// set to lock
1406 1406
 		outs, err := d.Cmd("swarm", "update", "--autolock")
1407 1407
 		assert.Assert(c, err == nil, "out: %v", outs)
1408
-		assert.Assert(c, strings.Contains(outs, "docker swarm unlock"))
1408
+		assert.Assert(c, strings.Contains(outs, "docker swarm unlock"), outs)
1409 1409
 		unlockKey := getUnlockKey(d, c, outs)
1410 1410
 
1411 1411
 		checkSwarmUnlockedToLocked(c, d)
... ...
@@ -1456,15 +1458,15 @@ func (s *DockerSwarmSuite) TestSwarmManagerAddress(c *testing.T) {
1456 1456
 
1457 1457
 	out, err := d1.Cmd("info")
1458 1458
 	assert.NilError(c, err, out)
1459
-	assert.Assert(c, strings.Contains(out, expectedOutput))
1459
+	assert.Assert(c, strings.Contains(out, expectedOutput), out)
1460 1460
 
1461 1461
 	out, err = d2.Cmd("info")
1462 1462
 	assert.NilError(c, err, out)
1463
-	assert.Assert(c, strings.Contains(out, expectedOutput))
1463
+	assert.Assert(c, strings.Contains(out, expectedOutput), out)
1464 1464
 
1465 1465
 	out, err = d3.Cmd("info")
1466 1466
 	assert.NilError(c, err, out)
1467
-	assert.Assert(c, strings.Contains(out, expectedOutput))
1467
+	assert.Assert(c, strings.Contains(out, expectedOutput), out)
1468 1468
 }
1469 1469
 
1470 1470
 func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *testing.T) {
... ...
@@ -1475,9 +1477,10 @@ func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *testing.T) {
1475 1475
 	assert.Assert(c, strings.TrimSpace(out) != "")
1476 1476
 
1477 1477
 	out, err = d.Cmd("network", "inspect", "--format", "{{.IPAM.Options}}", "foo")
1478
+	out = strings.TrimSpace(out)
1478 1479
 	assert.NilError(c, err, out)
1479
-	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "foo:bar"))
1480
-	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "com.docker.network.ipam.serial:true"))
1480
+	assert.Assert(c, strings.Contains(out, "foo:bar"), out)
1481
+	assert.Assert(c, strings.Contains(out, "com.docker.network.ipam.serial:true"), out)
1481 1482
 	out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--network=foo", "--name", "top", "busybox", "top")
1482 1483
 	assert.NilError(c, err, out)
1483 1484
 
... ...
@@ -1486,8 +1489,8 @@ func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *testing.T) {
1486 1486
 
1487 1487
 	out, err = d.Cmd("network", "inspect", "--format", "{{.IPAM.Options}}", "foo")
1488 1488
 	assert.NilError(c, err, out)
1489
-	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "foo:bar"))
1490
-	assert.Assert(c, strings.Contains(strings.TrimSpace(out), "com.docker.network.ipam.serial:true"))
1489
+	assert.Assert(c, strings.Contains(out, "foo:bar"), out)
1490
+	assert.Assert(c, strings.Contains(out, "com.docker.network.ipam.serial:true"), out)
1491 1491
 }
1492 1492
 
1493 1493
 // Test case for issue #27866, which did not allow NW name that is the prefix of a swarm NW ID.
... ...
@@ -1526,7 +1529,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkCreateDup(c *testing.T) {
1526 1526
 			out, err := d.Cmd("network", "create", "--driver", driver1, nwName)
1527 1527
 			assert.NilError(c, err, "out: %v", out)
1528 1528
 			out, err = d.Cmd("network", "create", "--driver", driver2, nwName)
1529
-			assert.Assert(c, strings.Contains(out, fmt.Sprintf("network with name %s already exists", nwName)))
1529
+			assert.Assert(c, strings.Contains(out, fmt.Sprintf("network with name %s already exists", nwName)), out)
1530 1530
 			assert.ErrorContains(c, err, "")
1531 1531
 			c.Logf("As expected, the attempt to network %q with %q failed: %s",
1532 1532
 				nwName, driver2, out)
... ...
@@ -1550,9 +1553,9 @@ func (s *DockerSwarmSuite) TestSwarmPublishDuplicatePorts(c *testing.T) {
1550 1550
 	// Dynamic ports are likely to be 30000 and 30001 but doesn't matter
1551 1551
 	out, err = d.Cmd("service", "inspect", "--format", "{{.Endpoint.Ports}} len={{len .Endpoint.Ports}}", id)
1552 1552
 	assert.NilError(c, err, out)
1553
-	assert.Assert(c, strings.Contains(out, "len=4"))
1554
-	assert.Assert(c, strings.Contains(out, "{ tcp 80 5005 ingress}"))
1555
-	assert.Assert(c, strings.Contains(out, "{ tcp 80 5006 ingress}"))
1553
+	assert.Assert(c, strings.Contains(out, "len=4"), out)
1554
+	assert.Assert(c, strings.Contains(out, "{ tcp 80 5005 ingress}"), out)
1555
+	assert.Assert(c, strings.Contains(out, "{ tcp 80 5006 ingress}"), out)
1556 1556
 }
1557 1557
 
1558 1558
 func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *testing.T) {
... ...
@@ -1560,7 +1563,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *testing.T) {
1560 1560
 
1561 1561
 	out, err := d.Cmd("node", "ls")
1562 1562
 	assert.NilError(c, err)
1563
-	assert.Assert(c, !strings.Contains(out, "Drain"))
1563
+	assert.Assert(c, !strings.Contains(out, "Drain"), out)
1564 1564
 	out, err = d.Cmd("swarm", "join-token", "-q", "manager")
1565 1565
 	assert.NilError(c, err)
1566 1566
 	assert.Assert(c, strings.TrimSpace(out) != "")
... ...
@@ -1575,10 +1578,10 @@ func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *testing.T) {
1575 1575
 
1576 1576
 	out, err = d.Cmd("node", "ls")
1577 1577
 	assert.NilError(c, err)
1578
-	assert.Assert(c, strings.Contains(out, "Drain"))
1578
+	assert.Assert(c, strings.Contains(out, "Drain"), out)
1579 1579
 	out, err = d1.Cmd("node", "ls")
1580 1580
 	assert.NilError(c, err)
1581
-	assert.Assert(c, strings.Contains(out, "Drain"))
1581
+	assert.Assert(c, strings.Contains(out, "Drain"), out)
1582 1582
 }
1583 1583
 
1584 1584
 func (s *DockerSwarmSuite) TestSwarmInitWithDrain(c *testing.T) {
... ...
@@ -1652,7 +1655,7 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *testing.T) {
1652 1652
 	// Name with duplicates
1653 1653
 	out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", name)
1654 1654
 	assert.ErrorContains(c, err, "", out)
1655
-	assert.Assert(c, strings.Contains(out, "2 matches found based on name"))
1655
+	assert.Assert(c, strings.Contains(out, "2 matches found based on name"), out)
1656 1656
 	out, err = d.Cmd("network", "rm", n2.ID)
1657 1657
 	assert.NilError(c, err, out)
1658 1658
 
... ...
@@ -1674,7 +1677,7 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *testing.T) {
1674 1674
 	// Name with duplicates
1675 1675
 	out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", name)
1676 1676
 	assert.ErrorContains(c, err, "", out)
1677
-	assert.Assert(c, strings.Contains(out, "2 matches found based on name"))
1677
+	assert.Assert(c, strings.Contains(out, "2 matches found based on name"), out)
1678 1678
 }
1679 1679
 
1680 1680
 func (s *DockerSwarmSuite) TestSwarmStopSignal(c *testing.T) {
... ...
@@ -1721,18 +1724,18 @@ func (s *DockerSwarmSuite) TestSwarmServiceLsFilterMode(c *testing.T) {
1721 1721
 
1722 1722
 	out, err = d.Cmd("service", "ls")
1723 1723
 	assert.NilError(c, err, out)
1724
-	assert.Assert(c, strings.Contains(out, "top1"))
1725
-	assert.Assert(c, strings.Contains(out, "top2"))
1726
-	assert.Assert(c, !strings.Contains(out, "localnet"))
1724
+	assert.Assert(c, strings.Contains(out, "top1"), out)
1725
+	assert.Assert(c, strings.Contains(out, "top2"), out)
1726
+	assert.Assert(c, !strings.Contains(out, "localnet"), out)
1727 1727
 	out, err = d.Cmd("service", "ls", "--filter", "mode=global")
1728
-	assert.Assert(c, !strings.Contains(out, "top1"))
1729
-	assert.Assert(c, strings.Contains(out, "top2"))
1728
+	assert.Assert(c, !strings.Contains(out, "top1"), out)
1729
+	assert.Assert(c, strings.Contains(out, "top2"), out)
1730 1730
 	assert.NilError(c, err, out)
1731 1731
 
1732 1732
 	out, err = d.Cmd("service", "ls", "--filter", "mode=replicated")
1733 1733
 	assert.NilError(c, err, out)
1734
-	assert.Assert(c, strings.Contains(out, "top1"))
1735
-	assert.Assert(c, !strings.Contains(out, "top2"))
1734
+	assert.Assert(c, strings.Contains(out, "top1"), out)
1735
+	assert.Assert(c, !strings.Contains(out, "top2"), out)
1736 1736
 }
1737 1737
 
1738 1738
 func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *testing.T) {
... ...
@@ -1740,10 +1743,10 @@ func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *testing.T) {
1740 1740
 
1741 1741
 	out, err := d.Cmd("swarm", "init", "--data-path-addr", "0.0.0.0")
1742 1742
 	assert.ErrorContains(c, err, "")
1743
-	assert.Assert(c, strings.Contains(out, "data path address must be a non-zero IP"))
1743
+	assert.Assert(c, strings.Contains(out, "data path address must be a non-zero IP"), out)
1744 1744
 	out, err = d.Cmd("swarm", "init", "--data-path-addr", "0.0.0.0:2000")
1745 1745
 	assert.ErrorContains(c, err, "")
1746
-	assert.Assert(c, strings.Contains(out, "data path address must be a non-zero IP"))
1746
+	assert.Assert(c, strings.Contains(out, "data path address must be a non-zero IP"), out)
1747 1747
 }
1748 1748
 
1749 1749
 func (s *DockerSwarmSuite) TestSwarmJoinLeave(c *testing.T) {
... ...
@@ -1813,7 +1816,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsSource(c *testing.T) {
1813 1813
 
1814 1814
 	// d3 is a worker, not able to get cluster events
1815 1815
 	out = waitForEvent(c, d3, "0", "-f scope=swarm", "", 1)
1816
-	assert.Assert(c, !strings.Contains(out, "network create "))
1816
+	assert.Assert(c, !strings.Contains(out, "network create "), out)
1817 1817
 }
1818 1818
 
1819 1819
 func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *testing.T) {
... ...
@@ -1826,14 +1829,14 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *testing.T) {
1826 1826
 
1827 1827
 	// scope swarm filters cluster events
1828 1828
 	out = waitForEvent(c, d, "0", "-f scope=swarm", "service create "+serviceID, defaultRetryCount)
1829
-	assert.Assert(c, !strings.Contains(out, "container create "))
1829
+	assert.Assert(c, !strings.Contains(out, "container create "), out)
1830 1830
 	// all events are returned if scope is not specified
1831 1831
 	waitForEvent(c, d, "0", "", "service create "+serviceID, 1)
1832 1832
 	waitForEvent(c, d, "0", "", "container create ", defaultRetryCount)
1833 1833
 
1834 1834
 	// scope local only shows non-cluster events
1835 1835
 	out = waitForEvent(c, d, "0", "-f scope=local", "container create ", 1)
1836
-	assert.Assert(c, !strings.Contains(out, "service create "))
1836
+	assert.Assert(c, !strings.Contains(out, "service create "), out)
1837 1837
 }
1838 1838
 
1839 1839
 func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *testing.T) {
... ...
@@ -1852,10 +1855,10 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *testing.T) {
1852 1852
 
1853 1853
 	// filter by service
1854 1854
 	out = waitForEvent(c, d, "0", "-f type=service", "service create "+serviceID, defaultRetryCount)
1855
-	assert.Assert(c, !strings.Contains(out, "network create"))
1855
+	assert.Assert(c, !strings.Contains(out, "network create"), out)
1856 1856
 	// filter by network
1857 1857
 	out = waitForEvent(c, d, "0", "-f type=network", "network create "+networkID, defaultRetryCount)
1858
-	assert.Assert(c, !strings.Contains(out, "service create"))
1858
+	assert.Assert(c, !strings.Contains(out, "service create"), out)
1859 1859
 }
1860 1860
 
1861 1861
 func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *testing.T) {
... ...
@@ -1875,18 +1878,18 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *testing.T) {
1875 1875
 
1876 1876
 	// wait for service update start
1877 1877
 	out = waitForEvent(c, d, t1, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
1878
-	assert.Assert(c, strings.Contains(out, "updatestate.new=updating"))
1878
+	assert.Assert(c, strings.Contains(out, "updatestate.new=updating"), out)
1879 1879
 	// allow service update complete. This is a service with 1 instance
1880 1880
 	time.Sleep(400 * time.Millisecond)
1881 1881
 	out = waitForEvent(c, d, t1, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
1882
-	assert.Assert(c, strings.Contains(out, "updatestate.new=completed, updatestate.old=updating"))
1882
+	assert.Assert(c, strings.Contains(out, "updatestate.new=completed, updatestate.old=updating"), out)
1883 1883
 	// scale service
1884 1884
 	t2 := daemonUnixTime(c)
1885 1885
 	out, err = d.Cmd("service", "scale", "test=3")
1886 1886
 	assert.NilError(c, err, out)
1887 1887
 
1888 1888
 	out = waitForEvent(c, d, t2, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
1889
-	assert.Assert(c, strings.Contains(out, "replicas.new=3, replicas.old=1"))
1889
+	assert.Assert(c, strings.Contains(out, "replicas.new=3, replicas.old=1"), out)
1890 1890
 	// remove service
1891 1891
 	t3 := daemonUnixTime(c)
1892 1892
 	out, err = d.Cmd("service", "rm", "test")
... ...
@@ -1909,7 +1912,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsNode(c *testing.T) {
1909 1909
 
1910 1910
 	// filter by type
1911 1911
 	out = waitForEvent(c, d1, t1, "-f type=node", "node update "+d3ID, defaultRetryCount)
1912
-	assert.Assert(c, strings.Contains(out, "availability.new=pause, availability.old=active"))
1912
+	assert.Assert(c, strings.Contains(out, "availability.new=pause, availability.old=active"), out)
1913 1913
 	t2 := daemonUnixTime(c)
1914 1914
 	out, err = d1.Cmd("node", "demote", d3ID)
1915 1915
 	assert.NilError(c, err, out)
... ...
@@ -1990,7 +1993,7 @@ func getUnlockKey(d *daemon.Daemon, c *testing.T, autolockOutput string) string
1990 1990
 
1991 1991
 	// Check that "docker swarm init --autolock" or "docker swarm update --autolock"
1992 1992
 	// contains all the expected strings, including the unlock key
1993
-	assert.Assert(c, strings.Contains(autolockOutput, "docker swarm unlock"))
1994
-	assert.Assert(c, strings.Contains(autolockOutput, unlockKey))
1993
+	assert.Assert(c, strings.Contains(autolockOutput, "docker swarm unlock"), autolockOutput)
1994
+	assert.Assert(c, strings.Contains(autolockOutput, unlockKey), autolockOutput)
1995 1995
 	return unlockKey
1996 1996
 }