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

conformance test: tear down manifests before blobs #156

Closed
wants to merge 3 commits 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
35 changes: 25 additions & 10 deletions conformance/01_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ var test01Pull = func() {
})

g.Context("Teardown", func() {
if deleteManifestBeforeBlobs {
g.Specify("Delete manifest created in setup", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300)))
})
}

g.Specify("Delete config blob created in setup", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
Expand All @@ -174,16 +187,18 @@ var test01Pull = func() {
BeNumerically("<", 300)))
})

g.Specify("Delete manifest created in setup", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300)))
})
if !deleteManifestBeforeBlobs {
g.Specify("Delete manifest created in setup", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300)))
})
}
})
})
}
48 changes: 34 additions & 14 deletions conformance/02_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@ var test02Push = func() {
})

g.Context("Teardown", func() {
if deleteManifestBeforeBlobs {
g.Specify("Delete manifest created in tests", func() {
SkipIfDisabled(push)
RunOnlyIf(runPushSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAny(
SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300),
),
Equal(http.StatusMethodNotAllowed),
))
})
}

g.Specify("Delete config blob created in tests", func() {
SkipIfDisabled(push)
RunOnlyIf(runPushSetup)
Expand Down Expand Up @@ -276,20 +293,23 @@ var test02Push = func() {
))
})

g.Specify("Delete manifest created in tests", func() {
SkipIfDisabled(push)
RunOnlyIf(runPushSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAny(
SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300),
),
Equal(http.StatusMethodNotAllowed),
))
})
if !deleteManifestBeforeBlobs {
g.Specify("Delete manifest created in tests", func() {
SkipIfDisabled(push)
RunOnlyIf(runPushSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAny(
SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300),
),
Equal(http.StatusMethodNotAllowed),
))
})
}

})
})
}
35 changes: 25 additions & 10 deletions conformance/03_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ var test03ContentDiscovery = func() {
})

g.Context("Teardown", func() {
if deleteManifestBeforeBlobs {
g.Specify("Delete created manifest & associated tags", func() {
SkipIfDisabled(contentDiscovery)
RunOnlyIf(runContentDiscoverySetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300)))
})
}

g.Specify("Delete config blob created in tests", func() {
SkipIfDisabled(contentDiscovery)
RunOnlyIf(runContentDiscoverySetup)
Expand All @@ -150,16 +163,18 @@ var test03ContentDiscovery = func() {
BeNumerically("<", 300)))
})

g.Specify("Delete created manifest & associated tags", func() {
SkipIfDisabled(contentDiscovery)
RunOnlyIf(runContentDiscoverySetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300)))
})
if !deleteManifestBeforeBlobs {
g.Specify("Delete created manifest & associated tags", func() {
SkipIfDisabled(contentDiscovery)
RunOnlyIf(runContentDiscoverySetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300)))
})
}
})
})
}
12 changes: 12 additions & 0 deletions conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export OCI_TEST_CONTENT_MANAGEMENT=1
# Extra settings
export OCI_HIDE_SKIPPED_WORKFLOWS=0
export OCI_DEBUG=0
export OCI_DELETE_MANIFEST_BEFORE_BLOBS=0
```

Lastly, run the tests:
Expand Down Expand Up @@ -147,6 +148,15 @@ the report, you must set the following in the environment:
OCI_HIDE_SKIPPED_WORKFLOWS=1
```

#### Teardown Order

By default, the teardown phase of each test deletes blobs before manifests. Some registries require the opposite order, deleting manifests before blobs. In this case, you must set the following in the environment:

```
# Required to delete manifests before blobs
OCI_DELETE_MANIFEST_BEFORE_BLOBS=1
```

#### Container Image

You may use the [Dockerfile](./Dockerfile) located in this directory
Expand All @@ -172,6 +182,7 @@ docker run --rm \
-e OCI_TEST_CONTENT_MANAGEMENT=1 \
-e OCI_HIDE_SKIPPED_WORKFLOWS=0 \
-e OCI_DEBUG=0 \
-e OCI_DELETE_MANIFEST_BEFORE_BLOBS=0 \
conformance:latest
```

Expand Down Expand Up @@ -206,6 +217,7 @@ jobs:
OCI_TEST_CONTENT_MANAGEMENT: 1
OCI_HIDE_SKIPPED_WORKFLOWS: 0
OCI_DEBUG: 0
OCI_DELETE_MANIFEST_BEFORE_BLOBS: 0
- run: mkdir -p .out/ && mv {report.html,junit.xml} .out/
if: always()
- name: Upload test results zip as build artifact
Expand Down
38 changes: 21 additions & 17 deletions conformance/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,24 @@ const (
DENIED
UNSUPPORTED

envVarRootURL = "OCI_ROOT_URL"
envVarNamespace = "OCI_NAMESPACE"
envVarUsername = "OCI_USERNAME"
envVarPassword = "OCI_PASSWORD"
envVarDebug = "OCI_DEBUG"
envVarPull = "OCI_TEST_PULL"
envVarPush = "OCI_TEST_PUSH"
envVarContentDiscovery = "OCI_TEST_CONTENT_DISCOVERY"
envVarContentManagement = "OCI_TEST_CONTENT_MANAGEMENT"
envVarPushEmptyLayer = "OCI_SKIP_EMPTY_LAYER_PUSH_TEST"
envVarBlobDigest = "OCI_BLOB_DIGEST"
envVarManifestDigest = "OCI_MANIFEST_DIGEST"
envVarEmptyLayerManifestDigest = "OCI_EMPTY_LAYER_MANIFEST_DIGEST"
envVarTagName = "OCI_TAG_NAME"
envVarTagList = "OCI_TAG_LIST"
envVarHideSkippedWorkflows = "OCI_HIDE_SKIPPED_WORKFLOWS"
envVarAuthScope = "OCI_AUTH_SCOPE"
envVarRootURL = "OCI_ROOT_URL"
envVarNamespace = "OCI_NAMESPACE"
envVarUsername = "OCI_USERNAME"
envVarPassword = "OCI_PASSWORD"
envVarDebug = "OCI_DEBUG"
envVarPull = "OCI_TEST_PULL"
envVarPush = "OCI_TEST_PUSH"
envVarContentDiscovery = "OCI_TEST_CONTENT_DISCOVERY"
envVarContentManagement = "OCI_TEST_CONTENT_MANAGEMENT"
envVarPushEmptyLayer = "OCI_SKIP_EMPTY_LAYER_PUSH_TEST"
envVarBlobDigest = "OCI_BLOB_DIGEST"
envVarManifestDigest = "OCI_MANIFEST_DIGEST"
envVarEmptyLayerManifestDigest = "OCI_EMPTY_LAYER_MANIFEST_DIGEST"
envVarTagName = "OCI_TAG_NAME"
envVarTagList = "OCI_TAG_LIST"
envVarHideSkippedWorkflows = "OCI_HIDE_SKIPPED_WORKFLOWS"
envVarAuthScope = "OCI_AUTH_SCOPE"
envVarDeleteManifestBeforeBlobs = "OCI_DELETE_MANIFEST_BEFORE_BLOBS"

emptyLayerTestTag = "emptylayer"
testTagName = "tagtest0"
Expand Down Expand Up @@ -123,6 +124,7 @@ var (
runContentDiscoverySetup bool
runContentManagementSetup bool
skipEmptyLayerTest bool
deleteManifestBeforeBlobs bool
Version = "unknown"
)

Expand Down Expand Up @@ -274,6 +276,7 @@ func init() {
runContentDiscoverySetup = true
runContentManagementSetup = true
skipEmptyLayerTest = false
deleteManifestBeforeBlobs = false

if os.Getenv(envVarTagName) != "" &&
os.Getenv(envVarManifestDigest) != "" &&
Expand All @@ -286,6 +289,7 @@ func init() {
}

skipEmptyLayerTest, _ = strconv.ParseBool(os.Getenv(envVarPushEmptyLayer))
deleteManifestBeforeBlobs, _ = strconv.ParseBool(os.Getenv(envVarDeleteManifestBeforeBlobs))

reportJUnitFilename = "junit.xml"
reportHTMLFilename = "report.html"
Expand Down