Skip to content

Update pull tests#16039

Merged
jessfraz merged 3 commits intomoby:masterfrom
icecrime:update_pull_tests
Sep 4, 2015
Merged

Update pull tests#16039
jessfraz merged 3 commits intomoby:masterfrom
icecrime:update_pull_tests

Conversation

@icecrime
Copy link
Contributor

@icecrime icecrime commented Sep 3, 2015

This is a first step into improving code coverage of our push/pull code.

  • Introduce the DockerPushPullSuite that interacts with its own dedicated daemon, thus allowing to start from a clean environment and finely test against the impact of isolated push and pull operations.
  • Update and migrate existing tests to the DockerPushPullSuite. Most tests were preserved, but refactored and made more exhaustive. One test was deliberately removed (TestPullVerified) as it is unreliable and that the feature was obsoleted by content trust.
  • Move all trust related tests to docker_cli_pull_trusted_test.go.
  • Move tests depending on a local registry to docker_cli_pull_local_test.go.

After this PR gets in, I'll proceed in adding new test scenarios, and doing the same work on the push tests.

One thing I should mention (and feel free to file as an issue, or submit a PR) is that I'm not happy with the way DockerPushPullSuite is: it's too easy to incorrectly call to dockerCmd and hit the wrong daemon. I believe the global integration tests daemon started as part of hack/make/.integration-daemon-start should be modeled by a Daemon instance in the testing code, and that no function should execute commands without acting against a specific instance.

@aaronlehmann
Copy link

Introduce the DockerPushPullSuite that interacts with its own dedicated daemon, thus allowing to start from a clean environment and finely test against the impact of isolated push and pull operations.
Update and migrate existing tests to the DockerPushPullSuite. Most tests were preserved, but refactored and made more exhaustive. One test was deliberately removed (TestPullVerified) as it is unreliable and that the feature was obsoleted by content trust.

Awesome. I've run into issues with images not being cleaned up while working on push/pull tests. This will be a big improvement.

One thing I should mention (and feel free to file as an issue, or submit a PR) is that I'm not happy with the way DockerPushPullSuite is: it's too easy to incorrectly call to dockerCmd and hit the wrong daemon. I believe the global integration tests daemon started as part of hack/make/.integration-daemon-start should be modeled by a Daemon instance in the testing code, and that no function should execute commands without acting against a specific instance.

Agreed.

Choose a reason for hiding this comment

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

As this is implemented now, the name DockerPushPullSuite is misleading, because this isn't usable for pushes (no private registry). I think we should do one of the following:

  • This should be renamed to something like DockerHubPullSuite, and tests involving a private registry should be part of a different testsuite (possibly DockerRegistrySuite, with changes to make it similar to this testsuite).

or

  • This testsuite could provide a private registry, and replace DockerRegistrySuite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's absolutely right, I'll rename to DockerHubPullSuite, thanks!

Introduce the `DockerHubPullSuite` that interacts with its own dedicated
daemon, thus allowing to start from a clean environment and finely test
against the impact of isolated push and pull operations.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
@cpuguy83
Copy link
Member

cpuguy83 commented Sep 3, 2015

ping @vdemeester Who is also working on cleaning up dockerCmd and other things.

Copy link
Member

Choose a reason for hiding this comment

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

Probably just a nit (and because I think we don't use enough the power of check) — I'm writing this by memory so there might be a typo 😅 :

matches = len(digestExpr.FindAllStringSubmatch(out, -1))
c.Check(matches, check.Equals, 1, check.Commentf("expected exactly one image digest in the output, got %d", matches))
_, err := digest.ParseDigest(matches[0][1])
c.Check(err, check.IsNil, check.Commentf("invalid digest %q in output", matches[0][1]))

Below you could do it with check.Matches, etc.. but I also feel like we should have our own Checker for the docker project (but that's another story 😉).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're right. @icecrime can try at least. Maybe it's not so easy as we think, but worth a try.

@vdemeester
Copy link
Member

Test looks good and I'm 👍 of adding more test suites that are smaller and make sense 😉. Small nit with the use (or not) of check but that's no big deal 😛.

On the dockerCmd side these ones won't be a problem to fix as for almost all of them we don't use the return values (so no refactor will be needed on those).

One thing I should mention (and feel free to file as an issue, or submit a PR) is that I'm not happy with the way DockerPushPullSuite is: it's too easy to incorrectly call to dockerCmd and hit the wrong daemon. I believe the global integration tests daemon started as part of hack/make/.integration-daemon-start should be modeled by a Daemon instance in the testing code, and that no function should execute commands without acting against a specific instance.

Agreed too.

@icecrime
Copy link
Contributor Author

icecrime commented Sep 3, 2015

I'm not happy with this yet, give me a moment ;-)

@icecrime icecrime closed this Sep 3, 2015
@icecrime icecrime reopened this Sep 3, 2015
Arnaud Porterie added 2 commits September 3, 2015 15:57
Add a `checker` package that adds some utility Checker implementation,
the first one being `checker.Contains`, as well as brining all go-check
provided Checker implementations in scope as a commodity.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Update and migrate existing tests to the `DockerHubPullSuite`. Most
tests were preserved, but refactored and made more exhaustive. One test
was deliberately removed (`TestPullVerified`) as it is unreliable and
that the feature was obsoleted by content trust.

Move all trust related tests to `docker_cli_pull_trusted_test.go`.

Move tests depending on a local registry to `docker_cli_pull_local_test.go`.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
@icecrime
Copy link
Contributor Author

icecrime commented Sep 3, 2015

Updated with much better use of go-check, as well as introducing our very own integration-cli/checkers package. PTAL!

@aaronlehmann
Copy link

LGTM

@vdemeester
Copy link
Member

@icecrime this looks good 😻

@jessfraz
Copy link
Contributor

jessfraz commented Sep 4, 2015

LGTM

@jessfraz
Copy link
Contributor

jessfraz commented Sep 4, 2015

something is going on w windows its unrelated, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants