Skip to content

Commit 7be5e85

Browse files
committed
Add test for automatic cross mounting behaviour
This adds conformance tests for automatic cross mounting. Usually, the test should not run as it can give a false positive. The OCI_AUTOMATIC_CROSSMOUNT must be set based on how the registry is expected to be configured. Signed-off-by: Sargun Dhillon <sargun@sargun.me>
1 parent 162b5c9 commit 7be5e85

3 files changed

Lines changed: 82 additions & 35 deletions

File tree

conformance/02_push_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,34 @@ var test02Push = func() {
238238
loc := lastResponse.GetRelativeLocation()
239239
Expect(loc).To(ContainSubstring("/blobs/uploads/"))
240240
})
241+
242+
g.Specify("Cross-mounting without from, and automatic content discovery enabled should return a 201", func() {
243+
SkipIfDisabled(push)
244+
RunOnlyIf(runAutomaticCrossmountTest)
245+
RunOnlyIf(lastResponse.StatusCode() == http.StatusCreated)
246+
RunOnlyIf(automaticCrossmountEnabled)
247+
248+
req := client.NewRequest(reggie.POST, "/v2/<name>/blobs/uploads/",
249+
reggie.WithName(crossmountNamespace)).
250+
SetQueryParam("mount", testBlobADigest)
251+
resp, err := client.Do(req)
252+
Expect(err).To(BeNil())
253+
Expect(resp.StatusCode()).To(Equal(http.StatusCreated))
254+
})
255+
256+
g.Specify("Cross-mounting without from, and automatic content discovery disabled should return a 202", func() {
257+
SkipIfDisabled(push)
258+
RunOnlyIf(runAutomaticCrossmountTest)
259+
RunOnlyIf(lastResponse.StatusCode() == http.StatusCreated)
260+
RunOnlyIfNot(automaticCrossmountEnabled)
261+
262+
req := client.NewRequest(reggie.POST, "/v2/<name>/blobs/uploads/",
263+
reggie.WithName(crossmountNamespace)).
264+
SetQueryParam("mount", testBlobADigest)
265+
resp, err := client.Do(req)
266+
Expect(err).To(BeNil())
267+
Expect(resp.StatusCode()).To(Equal(http.StatusAccepted))
268+
})
241269
})
242270

243271
g.Context("Manifest Upload", func() {

conformance/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@ the environment:
115115
OCI_CROSSMOUNT_NAMESPACE="myorg/other"
116116
```
117117

118+
If you want to test the behaviour of automatic content discovery, you should set the `OCI_AUTOMATIC_CROSSMOUNT` variable.
119+
120+
```
121+
# Do not test automatic cross mounting
122+
unset OCI_AUTOMATIC_CROSSMOUNT
123+
124+
# Test that automatic cross mounting is working as expected
125+
OCI_AUTOMATIC_CROSSMOUNT=1
126+
127+
# Test that automatic cross mounting is disabled
128+
OCI_AUTOMATIC_CROSSMOUNT=0
129+
```
130+
118131
##### Content Discovery
119132

120133
The Content Discovery tests validate that the contents of a registry can be discovered.

conformance/setup.go

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const (
7171
envVarAuthScope = "OCI_AUTH_SCOPE"
7272
envVarDeleteManifestBeforeBlobs = "OCI_DELETE_MANIFEST_BEFORE_BLOBS"
7373
envVarCrossmountNamespace = "OCI_CROSSMOUNT_NAMESPACE"
74+
envVarAutomaticCrossmount = "OCI_AUTOMATIC_CROSSMOUNT"
7475

7576
emptyLayerTestTag = "emptylayer"
7677
testTagName = "tagtest0"
@@ -97,41 +98,43 @@ var (
9798
envVarContentManagement: contentManagement,
9899
}
99100

100-
testBlobA []byte
101-
testBlobALength string
102-
testBlobADigest string
103-
testBlobB []byte
104-
testBlobBDigest string
105-
testBlobBChunk1 []byte
106-
testBlobBChunk1Length string
107-
testBlobBChunk2 []byte
108-
testBlobBChunk2Length string
109-
testBlobBChunk1Range string
110-
testBlobBChunk2Range string
111-
client *reggie.Client
112-
crossmountNamespace string
113-
dummyDigest string
114-
errorCodes []string
115-
invalidManifestContent []byte
116-
layerBlobData []byte
117-
layerBlobDigest string
118-
layerBlobContentLength string
119-
emptyLayerManifestContent []byte
120-
nonexistentManifest string
121-
reportJUnitFilename string
122-
reportHTMLFilename string
123-
httpWriter *httpDebugWriter
124-
testsToRun int
125-
suiteDescription string
126-
runPullSetup bool
127-
runPushSetup bool
128-
runContentDiscoverySetup bool
129-
runContentManagementSetup bool
130-
skipEmptyLayerTest bool
131-
deleteManifestBeforeBlobs bool
132-
configs []TestBlob
133-
manifests []TestBlob
134-
Version = "unknown"
101+
testBlobA []byte
102+
testBlobALength string
103+
testBlobADigest string
104+
testBlobB []byte
105+
testBlobBDigest string
106+
testBlobBChunk1 []byte
107+
testBlobBChunk1Length string
108+
testBlobBChunk2 []byte
109+
testBlobBChunk2Length string
110+
testBlobBChunk1Range string
111+
testBlobBChunk2Range string
112+
client *reggie.Client
113+
crossmountNamespace string
114+
dummyDigest string
115+
errorCodes []string
116+
invalidManifestContent []byte
117+
layerBlobData []byte
118+
layerBlobDigest string
119+
layerBlobContentLength string
120+
emptyLayerManifestContent []byte
121+
nonexistentManifest string
122+
reportJUnitFilename string
123+
reportHTMLFilename string
124+
httpWriter *httpDebugWriter
125+
testsToRun int
126+
suiteDescription string
127+
runPullSetup bool
128+
runPushSetup bool
129+
runContentDiscoverySetup bool
130+
runContentManagementSetup bool
131+
skipEmptyLayerTest bool
132+
deleteManifestBeforeBlobs bool
133+
runAutomaticCrossmountTest bool
134+
automaticCrossmountEnabled bool
135+
configs []TestBlob
136+
manifests []TestBlob
137+
Version = "unknown"
135138
)
136139

137140
func init() {
@@ -320,6 +323,9 @@ func init() {
320323

321324
skipEmptyLayerTest, _ = strconv.ParseBool(os.Getenv(envVarPushEmptyLayer))
322325
deleteManifestBeforeBlobs, _ = strconv.ParseBool(os.Getenv(envVarDeleteManifestBeforeBlobs))
326+
automaticCrossmountVal := ""
327+
automaticCrossmountVal, runAutomaticCrossmountTest = os.LookupEnv(envVarAutomaticCrossmount)
328+
automaticCrossmountEnabled, _ = strconv.ParseBool(automaticCrossmountVal)
323329

324330
reportJUnitFilename = "junit.xml"
325331
reportHTMLFilename = "report.html"

0 commit comments

Comments
 (0)