Skip to content

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jul 27, 2023

Dusting off some old branches 😂

  • integration-cli: remove transformCmd utility
  • integration-cli: DockerCLIPsSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIInspectSuite: replace dockerCmd and waitRun
  • integration-cli: DockerNetworkSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLINetmodeSuite: replace dockerCmd and waitRun
  • integration-cli: dockerCmdWithFail: remove unused return
  • integration-cli: DockerAPISuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIAttachSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIEventSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIExecSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIInfoSuite: replace dockerCmd and waitRun
  • integration-cli: findContainerIP: replace dockerCmd
  • integration-cli: DockerBenchmarkSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIHealthSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLILinksSuite: replace dockerCmd and waitRun
  • integration-cli: DockerRegistryAuthHtpasswdSuite: replace dockerCmd
  • integration-cli: DockerCLILogsSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIRunSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLISaveLoadSuite: replace dockerCmd
  • integration-cli: DockerCLIBuildSuite: replace dockerCmd
  • integration-cli: DockerCLICpSuite: replace dockerCmd
  • integration-cli: DockerRegistrySuite: replace dockerCmd
  • integration-cli: replace dockerCmd
  • integration-cli: DockerCLISearchSuite: replace dockerCmd
  • integration-cli: DockerCLIRmiSuite: replace dockerCmd
  • integration-cli: DockerCLIPortSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIImagesSuite: replace dockerCmd
  • integration-cli: DockerCLIVolumeSuite: replace dockerCmd
  • integration-cli: DockerDaemonSuite: replace dockerCmd
  • integration-cli: DockerCLIUpdateSuite: replace dockerCmd and waitRun
  • integration-cli: DockerCLIStartSuite: replace dockerCmd
  • integration-cli: DockerCLICommitSuite: replace dockerCmd
  • integration-cli: DockerCLIStatsSuite: replace dockerCmd and waitRun

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added status/2-code-review area/testing kind/refactor PR's that refactor, or clean-up code labels Jul 27, 2023
@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch from 93355ac to 23c7d4c Compare July 27, 2023 13:40
@thaJeztah

This comment was marked as resolved.

@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch 2 times, most recently from 985e00b to 00be3f1 Compare July 27, 2023 15:39
@thaJeztah thaJeztah marked this pull request as ready for review July 27, 2023 19:16
@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch from dbe6b79 to de03113 Compare July 27, 2023 22:33
@thaJeztah thaJeztah marked this pull request as draft July 27, 2023 23:19
@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch 2 times, most recently from 3940c56 to 3d26f90 Compare July 28, 2023 09:03
@thaJeztah thaJeztah changed the title integration-cli: remove various uses of deprecated dockerCmd and waitRun integration-cli: remove deprecated dockerCmd and waitRun utilities Jul 28, 2023
@thaJeztah thaJeztah marked this pull request as ready for review July 28, 2023 11:00
@thaJeztah
Copy link
Member Author

I'll temporarily move this one to draft, pending #45652

I thought it would only conflict on imports, but after reviewing that PR, I noticed it also changes some lines around dockerCmd (and related), so I'll rebase this one after the other PR was merged.

/cc @cpuguy83 (reviews of this one welcome 🤗)

@thaJeztah thaJeztah marked this pull request as draft July 30, 2023 13:56
@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch from 3d26f90 to 8516a9f Compare August 14, 2023 15:44
@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch from 8516a9f to 0748c6f Compare September 7, 2023 22:21
@thaJeztah thaJeztah marked this pull request as ready for review September 7, 2023 22:22
@thaJeztah thaJeztah mentioned this pull request Sep 7, 2023
@thaJeztah
Copy link
Member Author

@rumpl @vvoland @cpuguy83 ptal 🤗

@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch from 0748c6f to 07dab91 Compare October 11, 2023 12:27
@thaJeztah
Copy link
Member Author

Unrelated, but interesting failure;

=== FAIL: amd64.integration.system TestLoginFailsWithBadCredentials (1.17s)
    login_test.go:28: assertion failed: expected error to contain "unauthorized: incorrect username or password", got "Error response from daemon: login attempt to https://registry-1.docker.io/v2/ failed with status: 401 Unauthorized"
        Error response from daemon: login attempt to https://registry-1.docker.io/v2/ failed with status: 401 Unauthorized

@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch from 07dab91 to 107b7c7 Compare October 18, 2023 07:40
Copy link
Member

@rumpl rumpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I'll be honest I half reviewed this, my eyes hurt. It's fine to merge, most of the changes are mechanical

@thaJeztah
Copy link
Member Author

Yeah, it's a pain to review this one; MOST of the changes are mechanical; there are some cases where I made some small "somewhat" changes (e.g. remove intermediate vars while updating, or (as pointed out in a comment above) changed vars to consts. Most of those were because I saw touching those lines anyway, so might as well update to reduce follow-up code-churn.

It's been a while since I made this PR, but I recall there were some slightly opinionated changes; e.g. some "utility" lines (e.g. create a container and get its ID from the output) where I swapped CombinedOutput for StdOut. For those, I mostly made the assumption that those commands themselves are not part of the "coverage" of the test, so if they ran successfully we could just consume the expected output (disregarding output on StdErr, if any).

Copy link
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but ouch, my eyes 😅

@@ -136,7 +137,7 @@ func (s *DockerAPISuite) TestPostContainersAttach(c *testing.T) {
}

// Create a container that only emits stdout.
cid, _ := dockerCmd(c, "run", "-di", "busybox", "cat")
cid := cli.DockerCmd(c, "run", "-di", "busybox", "cat").Combined()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use .Combined() here
(see next comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Wrote this pair of comment right when I was starting to review this, but after looking at everything I think you did make the changes to use .Stdout() when it makes sense, I think this is the only odd one out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, this one definitely can be StdOut() because we're capturing the output of the CLI (container ID) here, not so much the output of the container's command.

@@ -152,7 +153,7 @@ func (s *DockerAPISuite) TestPostContainersAttach(c *testing.T) {
expectTimeout(wc, br, "stdout")

// Test the similar functions of the stderr stream.
cid, _ = dockerCmd(c, "run", "-di", "busybox", "/bin/sh", "-c", "cat >&2")
cid = cli.DockerCmd(c, "run", "-di", "busybox", "/bin/sh", "-c", "cat >&2").Stdout()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then use .Stdout() here? They're both doing the same thing, just grabbing the container ID to use later, right?

If this was a 1:1 change we should just use .Combined() everywhere, but if we're making changes that make sense then we could use .Stdout() for both of these, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess I got confused and thought we could be capturing the container's process output (or maybe I just got fatigued 😂).

repoName := "foobar-save-load-test"
before, _ := dockerCmd(c, "commit", name, repoName)
imgRepoName := "foobar-save-load-test"
before := cli.DockerCmd(c, "commit", name, imgRepoName).Combined()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be a .Stdout(), right? docker commit prints to stdout if everything went okay (which seems to be expected here)


// It *should not* have copied the directory using the target's name, but
// used the given name instead.
unexpectedPath := filepath.Join(testVol, cpTestPathParent)
stat, err := os.Lstat(unexpectedPath)
if err == nil {
out = fmt.Sprintf("target name was copied: %q - %q", stat.Mode(), stat.Name())
c.Errorf("target name was unexpectedly preserved: %q - %q", stat.Mode(), stat.Name())
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much more readable :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Also adding some consts for fixed values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Also renaming vars that collided with package-level vars
and using consts for fixed values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Also adding some consts for fixed values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Also fixed some variables that shadowed package-level vars, and
used consts for fixed values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the remove_deprecated_utils branch from 107b7c7 to 5a72ed3 Compare October 19, 2023 16:02
@thaJeztah
Copy link
Member Author

👍 updated; addressed the comments (❤️)

@thaJeztah thaJeztah added this to the 25.0.0 milestone Oct 19, 2023
@thaJeztah thaJeztah merged commit c3ca4f5 into moby:master Oct 20, 2023
@thaJeztah thaJeztah deleted the remove_deprecated_utils branch October 20, 2023 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/refactor PR's that refactor, or clean-up code status/2-code-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants