Skip to content

Commit

Permalink
Merge pull request #476 from waynr/dont-rely-on-tag-listing-in-manife…
Browse files Browse the repository at this point in the history
…st-pull-test

conformance: pull tests shouldn't rely on tag listing
  • Loading branch information
jdolitsky authored Apr 25, 2024
2 parents 81bb239 + c758964 commit d679e21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
23 changes: 5 additions & 18 deletions conformance/01_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var test01Pull = func() {
g.Specify("Populate registry with test manifest", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
tag := testTagName
tag = testTagName
req := client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>",
reggie.WithReference(tag)).
SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json").
Expand All @@ -98,26 +98,13 @@ var test01Pull = func() {
BeNumerically("<", 300)))
})

g.Specify("Get the name of a tag", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.GET, "/v2/<name>/tags/list")
resp, err := client.Do(req)
Expect(err).To(BeNil())
tag = getTagNameFromResponse(resp)

// attempt to forcibly overwrite this tag with the unique manifest for this run
req = client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>",
reggie.WithReference(tag)).
SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json").
SetBody(manifests[0].Content)
_, _ = client.Do(req)
})

g.Specify("Get tag name from environment", func() {
SkipIfDisabled(pull)
RunOnlyIfNot(runPullSetup)
tag = os.Getenv(envVarTagName)
tmp := os.Getenv(envVarTagName)
if tmp != "" {
tag = tmp
}
})
})

Expand Down
13 changes: 0 additions & 13 deletions conformance/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,19 +624,6 @@ func getTagList(resp *reggie.Response) []string {
return tagList.Tags
}

func getTagNameFromResponse(lastResponse *reggie.Response) (tagName string) {
tl := &TagList{}
if lastResponse != nil {
jsonData := lastResponse.Body()
err := json.Unmarshal(jsonData, tl)
if err == nil && len(tl.Tags) > 0 {
tagName = tl.Tags[0]
}
}

return
}

// Adapted from https://gist.github.com/dopey/c69559607800d2f2f90b1b1ed4e550fb
func randomString(n int) string {
const letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
Expand Down

0 comments on commit d679e21

Please sign in to comment.