From 5a72ed3406f61b721bc6bf76d21cc96467b08f9e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 27 Jul 2023 20:01:59 +0200 Subject: [PATCH] integration-cli: remove deprecated dockerCmd and waitRun utilities Signed-off-by: Sebastiaan van Stijn --- integration-cli/docker_utils_test.go | 17 +---------------- integration-cli/events_utils_test.go | 3 ++- integration-cli/fixtures_linux_daemon_test.go | 9 +++++---- integration-cli/requirements_test.go | 3 ++- integration-cli/utils_test.go | 3 ++- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/integration-cli/docker_utils_test.go b/integration-cli/docker_utils_test.go index 852cf1155e..1490ab2e86 100644 --- a/integration-cli/docker_utils_test.go +++ b/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. diff --git a/integration-cli/events_utils_test.go b/integration-cli/events_utils_test.go index 827ec0f662..2e63645460 100644 --- a/integration-cli/events_utils_test.go +++ b/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 { diff --git a/integration-cli/fixtures_linux_daemon_test.go b/integration-cli/fixtures_linux_daemon_test.go index 384169462e..0ec24a101f 100644 --- a/integration-cli/fixtures_linux_daemon_test.go +++ b/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...) } diff --git a/integration-cli/requirements_test.go b/integration-cli/requirements_test.go index 9786fd9fac..425c98672f 100644 --- a/integration-cli/requirements_test.go +++ b/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) diff --git a/integration-cli/utils_test.go b/integration-cli/utils_test.go index 97b4e22ddc..136f15c69e 100644 --- a/integration-cli/utils_test.go +++ b/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 != "" {