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

test(e2e): add specs to hint for pulling unnamed layers #1174

Merged
merged 3 commits into from
Nov 7, 2023
Merged
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
3 changes: 3 additions & 0 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ graph TD;
G1["referrer.index(image)"] -- subject --> F1
G2["referrer.image(image)"] -- subject --> F2
G3["index"] -- subject --> F1

H0>tag: unnamed]-..->H1["artifact contains unnamed layer"]
I0>tag: empty]-..->I1["artifact contains only one empty layer"]
end
```

Expand Down
22 changes: 22 additions & 0 deletions test/e2e/internal/testdata/artifact/empty/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright The ORAS Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package empty

const (
Tag = "empty"
Digest = "sha256:7156dd4030da2375969c4da97e051d907f54ff8e9d28cc82c57289bbd22e3f9f"
ArtifactType = "test/empty.artifact"
)
22 changes: 22 additions & 0 deletions test/e2e/internal/testdata/artifact/unnamed/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright The ORAS Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package unnamed

const (
Tag = "unnamed"
Digest = "sha256:977c6cf8e8aeaa35a5b5d6127e5008775d66d65985ac77634f79e1d7501bba83"
ArtifactType = "application/vnd.unknown.config.v1+json"
)
27 changes: 27 additions & 0 deletions test/e2e/suite/command/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/onsi/gomega/gbytes"
"oras.land/oras/test/e2e/internal/testdata/artifact/blob"
"oras.land/oras/test/e2e/internal/testdata/artifact/config"
"oras.land/oras/test/e2e/internal/testdata/artifact/empty"
"oras.land/oras/test/e2e/internal/testdata/artifact/unnamed"
"oras.land/oras/test/e2e/internal/testdata/feature"
"oras.land/oras/test/e2e/internal/testdata/foobar"
"oras.land/oras/test/e2e/internal/testdata/multi_arch"
Expand All @@ -39,6 +41,31 @@ var _ = Describe("ORAS beginners:", func() {
out := ORAS("pull", "--help").MatchKeyWords(ExampleDesc).Exec().Out
gomega.Expect(out).Should(gbytes.Say("--include-subject\\s+%s", regexp.QuoteMeta(feature.Preview.Mark)))
})

hintMsg := func(reference string) string {
return fmt.Sprintf("Skipped pulling layers without file name in \"org.opencontainers.image.title\"\nUse 'oras copy %s --to-oci-layout <layout-dir>' to pull all layers.\n", reference)
}
It("should show hint for unnamed layer", func() {
tempDir := PrepareTempFiles()
ref := RegistryRef(ZOTHost, ArtifactRepo, unnamed.Tag)
ORAS("pull", ref).
WithWorkDir(tempDir).
MatchContent(hintMsg(ref)).Exec()
})

It("should not show hint for unnamed config blob", func() {
tempDir := PrepareTempFiles()
ref := RegistryRef(ZOTHost, ImageRepo, foobar.Tag)
out := ORAS("pull", ref).WithWorkDir(tempDir).Exec().Out
gomega.Expect(out).ShouldNot(gbytes.Say(hintMsg(ref)))
})

It("should not show hint for empty layer", func() {
tempDir := PrepareTempFiles()
ref := RegistryRef(ZOTHost, ArtifactRepo, empty.Tag)
out := ORAS("pull", ref).WithWorkDir(tempDir).Exec().Out
gomega.Expect(out).ShouldNot(gbytes.Say(hintMsg(ref)))
})
})
})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","artifactType":"test/empty.artifact","config":{"mediaType":"application/vnd.oci.empty.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2,"data":"e30="},"layers":[{"mediaType":"application/vnd.oci.empty.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2,"data":"e30="}],"annotations":{"org.opencontainers.image.created":"2023-11-06T08:07:54Z"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.unknown.config.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae","size":3}]}
16 changes: 16 additions & 0 deletions test/e2e/testdata/zot/command/artifacts/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:7679bc22c33b87aa345c6950a993db98a6df7a6cc77a35c388908a3a50be6bad",
"size": 867
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:7156dd4030da2375969c4da97e051d907f54ff8e9d28cc82c57289bbd22e3f9f",
"size": 519,
"annotations": {
"org.opencontainers.image.ref.name": "empty"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:977c6cf8e8aeaa35a5b5d6127e5008775d66d65985ac77634f79e1d7501bba83",
"size": 390,
"annotations": {
"org.opencontainers.image.ref.name": "unnamed"
}
}
]
}