Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update testing code according to the latest spec #230

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions conformance/02_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var test02Push = func() {
Expect(resp.StatusCode()).To(Equal(http.StatusNotFound))
})

g.Specify("POST request with digest and blob should yield a 201", func() {
g.Specify("POST request with digest and blob should yield a 201 or 202", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit too lenient. It's not that either 201 or 202 is acceptable, but that 201 and 202 indicate completely different things.

Copy link
Member

Choose a reason for hiding this comment

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

From a testing POV, how do you think we should address? Use an env var UPLOAD_EXPECTED_STATUS=202? As far as I understand they indicate different things from registry standpoint, but how can this be tested better in the client here?

Copy link
Contributor

Choose a reason for hiding this comment

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

So for cross-repo mounting, 201 indicates that the mount succeeded, and 202 indicates that you should proceed with the upload at the returned location.

I would expect that if a registry returned a 202 to me when I tried to do a monolithic upload, I need to perform a non-monolithic upload at Location, instead.

For this particular test, perhaps you don't care about the distinction? Quite possibly either response is valid, but I would guess that the rest of the test would break if a 202 was returned, given that the config wasn't uploaded, but I haven't looked through this code too deeply. If the upload did succeed, I would always expect a 201.

Is there a registry returning a 202 here? I would take that to indicate "I don't support single-request monolithic uploads", which maybe should fail the test? I'd need a bit more context to understand, I think.

Copy link
Member

Choose a reason for hiding this comment

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

My guess is this is for Harbor, which uses docker/distribution as a backend. So I believe that to be the context. Docker distribution is returning a 202 for this test, causing Harbor (and docker distribution) to fail.

So do we fix the test (as done here) to be more lenient, or is 202 actually incorrect as it is encoded in docker/distribution? Personally I lean towards the former since lotsa registries seem to have roots in docker

Copy link
Contributor

Choose a reason for hiding this comment

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

Reading through some code there doesn't appear to be anything that handles single-request monolithic blob uploads (@dmcgowan might be able to confirm). I don't see anything that reads the body, so I am assuming it's this case:

I would take that to indicate "I don't support single-request monolithic uploads", which maybe should fail the test?

I'm guessing the other upload paths are succeeding to upload the config, so this doesn't affect the other tests, even though the upload fails.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would be happy if we added spec language to that effect. It seems like a reasonable failure mode.

We already have that for cross-repo mounts, but it should apply to these monolithic uploads as well.

SkipIfDisabled(push)
req := client.NewRequest(reggie.POST, "/v2/<name>/blobs/uploads/").
SetHeader("Content-Length", configBlobContentLength).
Expand All @@ -71,7 +71,10 @@ var test02Push = func() {
Expect(err).To(BeNil())
location := resp.Header().Get("Location")
Expect(location).ToNot(BeEmpty())
Expect(resp.StatusCode()).To(Equal(http.StatusCreated))
Expect(resp.StatusCode()).To(SatisfyAny(
Equal(http.StatusCreated),
Equal(http.StatusAccepted),
))
})

g.Specify("GET request to blob URL from prior request should yield 200", func() {
Expand Down
4 changes: 0 additions & 4 deletions conformance/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ const (
MANIFEST_BLOB_UNKNOWN
MANIFEST_INVALID
MANIFEST_UNKNOWN
MANIFEST_UNVERIFIED
NAME_INVALID
NAME_UNKNOWN
SIZE_INVALID
TAG_INVALID
UNAUTHORIZED
DENIED
UNSUPPORTED
Expand Down Expand Up @@ -268,11 +266,9 @@ func init() {
MANIFEST_BLOB_UNKNOWN: "MANIFEST_BLOB_UNKNOWN",
MANIFEST_INVALID: "MANIFEST_INVALID",
MANIFEST_UNKNOWN: "MANIFEST_UNKNOWN",
MANIFEST_UNVERIFIED: "MANIFEST_UNVERIFIED",
NAME_INVALID: "NAME_INVALID",
NAME_UNKNOWN: "NAME_UNKNOWN",
SIZE_INVALID: "SIZE_INVALID",
TAG_INVALID: "TAG_INVALID",
UNAUTHORIZED: "UNAUTHORIZED",
DENIED: "DENIED",
UNSUPPORTED: "UNSUPPORTED",
Expand Down