Skip to content

Commit

Permalink
integration-cli/daemon: remove uses of deprecated WaitRun utility
Browse files Browse the repository at this point in the history
We should probably look a bit at the replacement though; looks like the
replacement;

- calls t.Fatal() by itself, instead of returning errors.
- does not use t.Helper(), which can make it more difficult to locate
  where errors happened.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Apr 3, 2023
1 parent d2a5948 commit 7d77c27
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
9 changes: 2 additions & 7 deletions integration-cli/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,9 @@ func (d *Daemon) CheckActiveContainerCount(t *testing.T) (interface{}, string) {
return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", out)
}

// WaitRun waits for a container to be running for 10s
func (d *Daemon) WaitRun(contID string) error {
args := []string{"--host", d.Sock()}
return WaitInspectWithArgs(d.dockerBinary, contID, "{{.State.Running}}", "true", 10*time.Second, args...)
}

// WaitInspectWithArgs waits for the specified expression to be equals to the specified expected string in the given time.
// Deprecated: use cli.WaitCmd instead
//
// Deprecated: use [cli.WaitRun] instead.
func WaitInspectWithArgs(dockerBinary, name, expr, expected string, timeout time.Duration, arg ...string) error {
after := time.After(timeout)

Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2589,7 +2589,7 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) {
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")
assert.NilError(c, err, "Output: %s", out)

s.d.WaitRun("top")
cli.WaitRun(c, "top")

// Wait for shell command to be completed
_, err = s.d.Cmd("exec", "top", "sh", "-c", `for i in $(seq 1 5); do if [ -e /adduser_end ]; then rm -f /adduser_end && break; else sleep 1 && false; fi; done`)
Expand All @@ -2616,7 +2616,7 @@ func (s *DockerDaemonSuite) TestRemoveContainerAfterLiveRestore(c *testing.T) {
out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "top")
assert.NilError(c, err, "Output: %s", out)

s.d.WaitRun("top")
cli.WaitRun(c, "top")

// restart daemon.
s.d.Restart(c, "--live-restore", "--storage-driver", "overlay2")
Expand Down
6 changes: 2 additions & 4 deletions integration-cli/docker_cli_network_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c
assert.NilError(c, err, out)

// verify container has finished starting before killing daemon
err = s.d.WaitRun(cName)
assert.NilError(c, err)
cli.WaitRun(c, cName)
}

// Kill daemon ungracefully and restart
Expand All @@ -1114,8 +1113,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c

// make sure all the containers are up and running
for i := 0; i < 10; i++ {
err := s.d.WaitRun(fmt.Sprintf("hostc-%d", i))
assert.NilError(c, err)
cli.WaitRun(c, fmt.Sprintf("hostc-%d", i))
}
}

Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_cli_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3998,15 +3998,15 @@ func (s *DockerDaemonSuite) TestRunWithUlimitAndDaemonDefault(c *testing.T) {
name := "test-A"
_, err := s.d.Cmd("run", "--name", name, "-d", "busybox", "top")
assert.NilError(c, err)
assert.NilError(c, s.d.WaitRun(name))
cli.WaitRun(c, name)

out, err := s.d.Cmd("inspect", "--format", "{{.HostConfig.Ulimits}}", name)
assert.NilError(c, err)
assert.Assert(c, strings.Contains(out, "[nofile=65535:65535]"))
name = "test-B"
_, err = s.d.Cmd("run", "--name", name, "--ulimit=nofile=42", "-d", "busybox", "top")
assert.NilError(c, err)
assert.NilError(c, s.d.WaitRun(name))
cli.WaitRun(c, name)

out, err = s.d.Cmd("inspect", "--format", "{{.HostConfig.Ulimits}}", name)
assert.NilError(c, err)
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *testing.T) {
out, err = d.Cmd("run", "-d", "--net", networkID, "busybox", "top")
assert.NilError(c, err, out)
cID := strings.TrimSpace(out)
d.WaitRun(cID)
cli.WaitRun(c, cID)

out, err = d.Cmd("rm", "-f", cID)
assert.NilError(c, err, out)
Expand Down

0 comments on commit 7d77c27

Please sign in to comment.