Browse Source

integration-cli: remove deprecated dockerCmd and waitRun utilities

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 1 year ago
parent
commit
5a72ed3406

+ 1 - 16
integration-cli/docker_utils_test.go

@@ -39,13 +39,6 @@ func dockerCmdWithError(args ...string) (string, int, error) {
 	return result.Combined(), result.ExitCode, result.Error
 }
 
-// Deprecated: use cli.Docker or cli.DockerCmd
-func dockerCmd(c testing.TB, args ...string) (string, int) {
-	c.Helper()
-	result := cli.DockerCmd(c, args...)
-	return result.Combined(), result.ExitCode
-}
-
 // Deprecated: use cli.Docker or cli.DockerCmd
 func dockerCmdWithResult(args ...string) *icmd.Result {
 	return cli.Docker(cli.Args(args...))
@@ -216,9 +209,7 @@ func runCommandAndReadContainerFile(c *testing.T, filename string, command strin
 	result := icmd.RunCommand(command, args...)
 	result.Assert(c, icmd.Success)
 	contID := strings.TrimSpace(result.Combined())
-	if err := waitRun(contID); err != nil {
-		c.Fatalf("%v: %q", contID, err)
-	}
+	cli.WaitRun(c, contID)
 	return readContainerFile(c, contID, filename)
 }
 
@@ -309,12 +300,6 @@ func createTmpFile(c *testing.T, content string) string {
 	return filename
 }
 
-// waitRun will wait for the specified container to be running, maximum 5 seconds.
-// Deprecated: use cli.WaitFor
-func waitRun(contID string) error {
-	return daemon.WaitInspectWithArgs(dockerBinary, contID, "{{.State.Running}}", "true", 5*time.Second)
-}
-
 // waitInspect will wait for the specified container to have the specified string
 // in the inspect output. It will wait until the specified timeout (in seconds)
 // is reached.

+ 2 - 1
integration-cli/events_utils_test.go

@@ -13,6 +13,7 @@ import (
 
 	"github.com/containerd/log"
 	eventstestutils "github.com/docker/docker/daemon/events/testutils"
+	"github.com/docker/docker/integration-cli/cli"
 	"gotest.tools/v3/assert"
 )
 
@@ -100,7 +101,7 @@ func (e *eventObserver) CheckEventError(c *testing.T, id, event string, match ev
 
 	if e.disconnectionError != nil {
 		until := daemonUnixTime(c)
-		out, _ := dockerCmd(c, "events", "--since", e.startTime, "--until", until)
+		out := cli.DockerCmd(c, "events", "--since", e.startTime, "--until", until).Stdout()
 		events := strings.Split(strings.TrimSpace(out), "\n")
 		for _, e := range events {
 			if _, ok := match(e); ok {

+ 5 - 4
integration-cli/fixtures_linux_daemon_test.go

@@ -10,6 +10,7 @@ import (
 	"strings"
 	"testing"
 
+	"github.com/docker/docker/integration-cli/cli"
 	"github.com/docker/docker/testutil/fixtures/load"
 	"gotest.tools/v3/assert"
 )
@@ -61,7 +62,7 @@ func ensureSyscallTest(ctx context.Context, c *testing.T) {
 	}
 	buildArgs = append(buildArgs, []string{"-q", "-t", "syscall-test", tmp}...)
 	buildArgs = append([]string{"build"}, buildArgs...)
-	dockerCmd(c, buildArgs...)
+	cli.DockerCmd(c, buildArgs...)
 }
 
 func ensureSyscallTestBuild(ctx context.Context, c *testing.T) {
@@ -74,7 +75,7 @@ func ensureSyscallTestBuild(ctx context.Context, c *testing.T) {
 	}
 	buildArgs = append(buildArgs, []string{"-q", "-t", "syscall-test", "../contrib/syscall-test"}...)
 	buildArgs = append([]string{"build"}, buildArgs...)
-	dockerCmd(c, buildArgs...)
+	cli.DockerCmd(c, buildArgs...)
 }
 
 func ensureNNPTest(ctx context.Context, c *testing.T) {
@@ -116,7 +117,7 @@ func ensureNNPTest(ctx context.Context, c *testing.T) {
 	}
 	buildArgs = append(buildArgs, []string{"-q", "-t", "nnp-test", tmp}...)
 	buildArgs = append([]string{"build"}, buildArgs...)
-	dockerCmd(c, buildArgs...)
+	cli.DockerCmd(c, buildArgs...)
 }
 
 func ensureNNPTestBuild(ctx context.Context, c *testing.T) {
@@ -129,5 +130,5 @@ func ensureNNPTestBuild(ctx context.Context, c *testing.T) {
 	}
 	buildArgs = append(buildArgs, []string{"-q", "-t", "npp-test", "../contrib/nnp-test"}...)
 	buildArgs = append([]string{"build"}, buildArgs...)
-	dockerCmd(c, buildArgs...)
+	cli.DockerCmd(c, buildArgs...)
 }

+ 2 - 1
integration-cli/requirements_test.go

@@ -15,6 +15,7 @@ import (
 	"github.com/docker/docker/api/types/swarm"
 	"github.com/docker/docker/api/types/versions"
 	"github.com/docker/docker/client"
+	"github.com/docker/docker/integration-cli/cli"
 	"github.com/docker/docker/integration-cli/requirement"
 	"github.com/docker/docker/testutil/registry"
 )
@@ -173,7 +174,7 @@ func TODOBuildkit() bool {
 }
 
 func DockerCLIVersion(t testing.TB) string {
-	out, _ := dockerCmd(t, "--version")
+	out := cli.DockerCmd(t, "--version").Stdout()
 	version := strings.Fields(out)
 	if len(version) < 3 {
 		t.Fatal("unknown version output", version)

+ 2 - 1
integration-cli/utils_test.go

@@ -8,6 +8,7 @@ import (
 	"strings"
 	"testing"
 
+	"github.com/docker/docker/integration-cli/cli"
 	"github.com/docker/docker/testutil"
 	"github.com/pkg/errors"
 	"gotest.tools/v3/icmd"
@@ -130,7 +131,7 @@ func existingElements(c *testing.T, opts elementListOptions) []string {
 	if opts.format != "" {
 		args = append(args, "--format", opts.format)
 	}
-	out, _ := dockerCmd(c, args...)
+	out := cli.DockerCmd(c, args...).Combined()
 	var lines []string
 	for _, l := range strings.Split(out, "\n") {
 		if l != "" {