Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit bb990f0

Browse files
cpuguy83thaJeztah
authored andcommitted
Fix more signal handling issues in tests.
Found these by doing a `grep -R 'using the force'` on a full test run. There's still a few more which are running against the main test daemon, so it is difficult to find which test they belong to. Signed-off-by: Brian Goff <cpuguy83@gmail.com> (cherry picked from commit fcd65ebf49a858c4f6223d1b1db728f7400a3b6d) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 4076c57b508e1753e123b078b43df714e7a14f2f Component: engine
1 parent 188bdab commit bb990f0

5 files changed

Lines changed: 16 additions & 18 deletions

File tree

components/engine/integration-cli/docker_cli_daemon_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *testing.T) {
427427

428428
s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:2::/64", "--default-gateway-v6=2001:db8:2::100")
429429

430-
out, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "busybox:latest")
430+
out, err := s.d.Cmd("run", "-d", "--name=ipv6test", "busybox:latest", "top")
431431
assert.NilError(c, err, "Could not run container: %s, %v", out, err)
432432

433433
out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}", "ipv6test")
@@ -454,7 +454,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *testing.T) {
454454

455455
s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:1::/64")
456456

457-
out, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "--mac-address", "AA:BB:CC:DD:EE:FF", "busybox")
457+
out, err := s.d.Cmd("run", "-d", "--name=ipv6test", "--mac-address", "AA:BB:CC:DD:EE:FF", "busybox", "top")
458458
assert.NilError(c, err, out)
459459

460460
out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}", "ipv6test")
@@ -469,7 +469,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *testing.T) {
469469
deleteInterface(c, "docker0")
470470

471471
s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:2::/64")
472-
out, err := s.d.Cmd("run", "-itd", "--name=hostcnt", "--network=host", "busybox:latest")
472+
out, err := s.d.Cmd("run", "-d", "--name=hostcnt", "--network=host", "busybox:latest", "top")
473473
assert.NilError(c, err, "Could not run container: %s, %v", out, err)
474474

475475
out, err = s.d.Cmd("exec", "hostcnt", "ip", "-6", "addr", "show", "docker0")
@@ -2703,7 +2703,7 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) {
27032703
testRequires(c, DaemonIsLinux)
27042704
s.d.StartWithBusybox(c, "--live-restore")
27052705

2706-
out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "sh", "-c", "addgroup -S test && adduser -S -G test test -D -s /bin/sh && touch /adduser_end && top")
2706+
out, err := s.d.Cmd("run", "--init", "-d", "--name=top", "busybox", "sh", "-c", "addgroup -S test && adduser -S -G test test -D -s /bin/sh && touch /adduser_end && exec top")
27072707
assert.NilError(c, err, "Output: %s", out)
27082708

27092709
s.d.WaitRun("top")

components/engine/integration-cli/docker_cli_network_unix_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *testing
956956
_, err := s.d.Cmd("network", "create", "-d", dnd, "--subnet", "1.1.1.0/24", "net1")
957957
assert.NilError(c, err)
958958

959-
_, err = s.d.Cmd("run", "-itd", "--net", "net1", "--name", "foo", "--ip", "1.1.1.10", "busybox", "sh")
959+
_, err = s.d.Cmd("run", "-d", "--net", "net1", "--name", "foo", "--ip", "1.1.1.10", "busybox", "top")
960960
assert.NilError(c, err)
961961

962962
// Kill daemon and restart
@@ -980,7 +980,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *testing
980980
setupRemoteNetworkDrivers(c, mux, server.URL, dnd, did)
981981

982982
// trying to reuse the same ip must succeed
983-
_, err = s.d.Cmd("run", "-itd", "--net", "net1", "--name", "bar", "--ip", "1.1.1.10", "busybox", "sh")
983+
_, err = s.d.Cmd("run", "-d", "--net", "net1", "--name", "bar", "--ip", "1.1.1.10", "busybox", "top")
984984
assert.NilError(c, err)
985985
}
986986

components/engine/integration-cli/docker_cli_service_create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *testing
362362

363363
func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
364364
d := s.AddDaemon(c, true, true)
365-
out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--mount", "type=tmpfs,target=/foo,tmpfs-size=1MB", "busybox", "sh", "-c", "mount | grep foo; tail -f /dev/null")
365+
out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--mount", "type=tmpfs,target=/foo,tmpfs-size=1MB", "busybox", "sh", "-c", "mount | grep foo; exec tail -f /dev/null")
366366
assert.NilError(c, err, out)
367367
id := strings.TrimSpace(out)
368368

components/engine/integration-cli/docker_cli_service_logs_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *testing.T) {
3434

3535
for name, message := range services {
3636
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox",
37-
"sh", "-c", fmt.Sprintf("echo %s; tail -f /dev/null", message))
37+
"sh", "-c", fmt.Sprintf("echo %s; exec tail -f /dev/null", message))
3838
assert.NilError(c, err)
3939
assert.Assert(c, strings.TrimSpace(out) != "")
4040
}
@@ -75,7 +75,7 @@ func (s *DockerSwarmSuite) TestServiceLogsCompleteness(c *testing.T) {
7575
name := "TestServiceLogsCompleteness"
7676

7777
// make a service that prints 6 lines
78-
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", "for line in $(seq 0 5); do echo log test $line; done; sleep 100000")
78+
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", "for line in $(seq 0 5); do echo log test $line; done; exec tail /dev/null")
7979
assert.NilError(c, err)
8080
assert.Assert(c, strings.TrimSpace(out) != "")
8181

@@ -126,7 +126,7 @@ func (s *DockerSwarmSuite) TestServiceLogsSince(c *testing.T) {
126126

127127
name := "TestServiceLogsSince"
128128

129-
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", "for i in $(seq 1 3); do sleep .1; echo log$i; done; sleep 10000000")
129+
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", "for i in $(seq 1 3); do usleep 100000; echo log$i; done; exec tail /dev/null")
130130
assert.NilError(c, err)
131131
assert.Assert(c, strings.TrimSpace(out) != "")
132132
poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
@@ -160,7 +160,7 @@ func (s *DockerSwarmSuite) TestServiceLogsFollow(c *testing.T) {
160160

161161
name := "TestServiceLogsFollow"
162162

163-
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", "while true; do echo log test; sleep 0.1; done")
163+
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", "trap 'exit 0' TERM; while true; do echo log test; usleep 100000; done")
164164
assert.NilError(c, err)
165165
assert.Assert(c, strings.TrimSpace(out) != "")
166166

@@ -215,7 +215,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTaskLogs(c *testing.T) {
215215
// which has this the task id as an environment variable templated in
216216
"--env", "TASK={{.Task.ID}}",
217217
// and runs this command to print exactly 6 logs lines
218-
"busybox", "sh", "-c", "for line in $(seq 0 5); do echo $TASK log test $line; done; sleep 100000",
218+
"busybox", "sh", "-c", "trap 'exit 0' TERM; for line in $(seq 0 5); do echo $TASK log test $line; done; sleep 100000",
219219
))
220220
result.Assert(c, icmd.Expected{})
221221
// ^^ verify that we get no error
@@ -323,9 +323,7 @@ func (s *DockerSwarmSuite) TestServiceLogsNoHangDeletedContainer(c *testing.T) {
323323
result = icmd.RunCmd(d.Command("ps", "-q"))
324324
containerID := strings.TrimSpace(result.Stdout())
325325
assert.Assert(c, containerID != "")
326-
result = icmd.RunCmd(d.Command("stop", containerID))
327-
result.Assert(c, icmd.Expected{Out: containerID})
328-
result = icmd.RunCmd(d.Command("rm", containerID))
326+
result = icmd.RunCmd(d.Command("rm", "-f", containerID))
329327
result.Assert(c, icmd.Expected{Out: containerID})
330328

331329
// run logs. use tail 2 to make sure we don't try to get a bunch of logs
@@ -360,7 +358,7 @@ func (s *DockerSwarmSuite) TestServiceLogsDetails(c *testing.T) {
360358
// busybox image, shell string
361359
"busybox", "sh", "-c",
362360
// make a log line
363-
"echo LogLine; while true; do sleep 1; done;",
361+
"trap 'exit 0' TERM; echo LogLine; while true; do sleep 1; done;",
364362
))
365363

366364
result.Assert(c, icmd.Expected{})

components/engine/integration-cli/docker_cli_userns_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
4646
// writable by the remapped root UID/GID pair
4747
assert.NilError(c, os.Chown(tmpDir, uid, gid))
4848

49-
out, err := s.d.Cmd("run", "-d", "--name", "userns", "-v", tmpDir+":/goofy", "-v", tmpDirNotExists+":/donald", "busybox", "sh", "-c", "touch /goofy/testfile; top")
49+
out, err := s.d.Cmd("run", "-d", "--name", "userns", "-v", tmpDir+":/goofy", "-v", tmpDirNotExists+":/donald", "busybox", "sh", "-c", "touch /goofy/testfile; exec top")
5050
assert.NilError(c, err, "Output: %s", out)
5151

5252
user := s.findUser(c, "userns")
@@ -79,7 +79,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
7979
assert.Equal(c, stat.GID(), uint32(gid), "Touched file not owned by remapped root GID")
8080

8181
// use host usernamespace
82-
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; top")
82+
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; exec top")
8383
assert.Assert(c, err == nil, "Output: %s", out)
8484
user = s.findUser(c, "userns_skip")
8585
// userns are skipped, user is root

0 commit comments

Comments
 (0)