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): migrate oras pull specs to ZOT #1086

Merged
merged 32 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f61b791
test(e2e): add zot
qweeah Aug 22, 2023
06abf60
add auth tests
qweeah Aug 22, 2023
8e644c6
uncomment changes
qweeah Aug 23, 2023
0c7a3ee
move auth and scenario suite to zot
qweeah Aug 23, 2023
35d8bd4
add password
qweeah Aug 23, 2023
1700e23
update description
qweeah Aug 23, 2023
7267ca4
separate prepare script out
qweeah Aug 23, 2023
a2cc4ea
check in zot config
qweeah Aug 23, 2023
e5f7398
add run access
qweeah Aug 23, 2023
2feed93
fix prepare bug
qweeah Aug 23, 2023
96fc889
remove prepare changes
qweeah Aug 24, 2023
2c2b597
run zot container via current user
qweeah Aug 25, 2023
6f9f3c2
rename zot
qweeah Aug 25, 2023
0a00292
add images repo for command suite and attach tests
qweeah Aug 25, 2023
3d60a75
update blob tests
qweeah Aug 25, 2023
c79ba60
Merge remote-tracking branch 'origin_src/main' into zot-attach
qweeah Aug 25, 2023
6e1998b
Merge remote-tracking branch 'origin_src/main' into zot-blob
qweeah Aug 28, 2023
d3d747b
Merge remote-tracking branch 'origin_src/main' into zot-attach
qweeah Aug 28, 2023
8efd185
add doc
qweeah Aug 28, 2023
f3cf89e
doc clean
qweeah Aug 28, 2023
8295d85
Merge branch 'zot-attach' into zot-blob
qweeah Aug 28, 2023
dea043d
fix e2e
qweeah Aug 28, 2023
1945b87
test(e2e): migrate `oras push` specs to ZOT
qweeah Aug 28, 2023
f028e61
fix e2e
qweeah Aug 28, 2023
a25d23f
fix e2e
qweeah Aug 29, 2023
003072a
Merge branch 'zot-push' into zot-pull
qweeah Aug 29, 2023
df78bef
test(e2e): migrate specs for `oras pull`
qweeah Aug 29, 2023
1e9bbd8
fix e2e
qweeah Aug 29, 2023
e2a4c38
Merge branch 'zot-push' into zot-pull
qweeah Aug 29, 2023
b42c474
Merge remote-tracking branch 'origin_src/main' into zot-blob
qweeah Aug 29, 2023
fe44903
Merge branch 'zot-blob' into zot-pull
qweeah Aug 29, 2023
997ba25
Merge remote-tracking branch 'origin_src/main' into zot-pull
qweeah Aug 29, 2023
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
Prev Previous commit
Next Next commit
add images repo for command suite and attach tests
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Aug 25, 2023
commit 0a0029216e326443b8f9f09d54ad69d4f4788bb9
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ _dist/
# Distribution storage files for local E2E testing
test/e2e/testdata/distribution/mount/docker/
test/e2e/testdata/distribution/mount_fallback/docker/


# OCI Layout Files ZOT storage files for local E2E testing
test/e2e/testdata/zot/
!test/e2e/testdata/zot/command/images
!test/e2e/testdata/zot/config.json
!test/e2e/testdata/zot/passwd_bcrypt
16 changes: 16 additions & 0 deletions test/e2e/internal/utils/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ import (
"github.com/onsi/gomega/gbytes"
)

// CopyZotRepo copies oci layout data between repostories.
func CopyZotRepo(fromRepo string, toRepo string) {
zotRoot := filepath.Join(TestDataRoot, "zot")
fromRepo = filepath.Join(zotRoot, fromRepo)
toRepo = filepath.Join(zotRoot, toRepo)
Expect(CopyFiles(fromRepo, toRepo)).ShouldNot(HaveOccurred())
}

// PrepareTempOCI prepares an OCI layout root via copying from an ZOT repo and
// return the path.
func PrepareTempOCI(fromZotRepo string) string {
root := PrepareTempFiles()
Expect(CopyFiles(filepath.Join(TestDataRoot, "zot", fromZotRepo), root)).ShouldNot(HaveOccurred())
return root
}

// PrepareTempFiles copies test data into a temp folder and return it.
func PrepareTempFiles() string {
tempDir := GinkgoT().TempDir()
Expand Down
45 changes: 19 additions & 26 deletions test/e2e/suite/command/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ var _ = Describe("ORAS beginners:", func() {
})

It("should fail when no subject reference provided", func() {
ORAS("attach", "--artifact-type", "oras.test").ExpectFailure().MatchErrKeyWords("Error:").Exec()
ORAS("attach", "--artifact-type", "oras/test").ExpectFailure().MatchErrKeyWords("Error:").Exec()
})

It("should fail if no file reference or manifest annotation provided for registry", func() {
ORAS("attach", "--artifact-type", "oras.test", RegistryRef(Host, ImageRepo, foobar.Tag)).
ORAS("attach", "--artifact-type", "oras/test", RegistryRef(ZOTHost, ImageRepo, foobar.Tag)).
ExpectFailure().MatchErrKeyWords("Error: no blob or manifest annotation are provided").Exec()
})

It("should fail if no file reference or manifest annotation provided for OCI layout", func() {
root := GinkgoT().TempDir()
ORAS("attach", "--artifact-type", "oras.test", LayoutRef(root, foobar.Tag)).
ORAS("attach", "--artifact-type", "oras/test", LayoutRef(root, foobar.Tag)).
ExpectFailure().MatchErrKeyWords("Error: no blob or manifest annotation are provided").Exec()
})

It("should fail if distribution spec is unkown", func() {
ORAS("attach", "--artifact-type", "oras.test", RegistryRef(Host, ImageRepo, foobar.Tag), "--distribution-spec", "???").
ORAS("attach", "--artifact-type", "oras/test", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--distribution-spec", "???").
ExpectFailure().MatchErrKeyWords("unknown distribution specification flag").Exec()
})
})
Expand All @@ -71,11 +71,10 @@ var _ = Describe("1.1 registry users:", func() {
When("running attach command", func() {
It("should attach a file to a subject", func() {
testRepo := attachTestRepo("simple")
tempDir := PrepareTempFiles()
subjectRef := RegistryRef(Host, testRepo, foobar.Tag)
prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef)
CopyZotRepo(ImageRepo, testRepo)
subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag)
ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)).
WithWorkDir(tempDir).
WithWorkDir(PrepareTempFiles()).
MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec()
})

Expand All @@ -84,8 +83,8 @@ var _ = Describe("1.1 registry users:", func() {
testRepo := attachTestRepo("export-manifest")
tempDir := PrepareTempFiles()
exportName := "manifest.json"
subjectRef := RegistryRef(Host, testRepo, foobar.Tag)
prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef)
subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag)
CopyZotRepo(ImageRepo, testRepo)
// test
ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName).
WithWorkDir(tempDir).
Expand All @@ -95,15 +94,15 @@ var _ = Describe("1.1 registry users:", func() {
bytes := ORAS("discover", subjectRef, "-o", "json").Exec().Out.Contents()
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(len(index.Manifests)).To(Equal(1))
fetched := ORAS("manifest", "fetch", RegistryRef(Host, testRepo, index.Manifests[0].Digest.String())).Exec().Out.Contents()
fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, index.Manifests[0].Digest.String())).Exec().Out.Contents()
MatchFile(filepath.Join(tempDir, exportName), string(fetched), DefaultTimeout)
})

It("should attach a file via a OCI Image", func() {
testRepo := attachTestRepo("image")
tempDir := PrepareTempFiles()
subjectRef := RegistryRef(Host, testRepo, foobar.Tag)
prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef)
subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag)
CopyZotRepo(ImageRepo, testRepo)
// test
ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)).
WithWorkDir(tempDir).
Expand All @@ -120,8 +119,8 @@ var _ = Describe("1.1 registry users:", func() {
testRepo := attachTestRepo("simple")
absAttachFileName := filepath.Join(PrepareTempFiles(), foobar.AttachFileName)

subjectRef := RegistryRef(Host, testRepo, foobar.Tag)
prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef)
subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag)
CopyZotRepo(ImageRepo, testRepo)
statusKey := foobar.AttachFileStateKey
statusKey.Name = absAttachFileName
ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia), "--disable-path-validation").
Expand All @@ -133,8 +132,8 @@ var _ = Describe("1.1 registry users:", func() {
testRepo := attachTestRepo("simple")
absAttachFileName := filepath.Join(PrepareTempFiles(), foobar.AttachFileName)

subjectRef := RegistryRef(Host, testRepo, foobar.Tag)
prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef)
subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag)
CopyZotRepo(ImageRepo, testRepo)
statusKey := foobar.AttachFileStateKey
statusKey.Name = absAttachFileName
ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia)).
Expand Down Expand Up @@ -204,24 +203,19 @@ var _ = Describe("1.0 registry users:", func() {

var _ = Describe("OCI image layout users:", func() {
When("running attach command", func() {
prepare := func(root string) {
ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), Flags.ToLayout, LayoutRef(root, foobar.Tag)).Exec()
}
It("should attach a file to a subject", func() {
root := PrepareTempFiles()
root := PrepareTempOCI(ImageRepo)
subjectRef := LayoutRef(root, foobar.Tag)
prepare(root)
ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)).
WithWorkDir(root).
MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec()
})

It("should attach a file to a subject and export the built manifest", func() {
// prepare
root := PrepareTempFiles()
exportName := "manifest.json"
root := PrepareTempOCI(ImageRepo)
subjectRef := LayoutRef(root, foobar.Tag)
prepare(root)
// test
ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName).
WithWorkDir(root).
Expand All @@ -236,9 +230,8 @@ var _ = Describe("OCI image layout users:", func() {
MatchFile(filepath.Join(root, exportName), string(fetched), DefaultTimeout)
})
It("should attach a file via a OCI Image", func() {
root := PrepareTempFiles()
root := PrepareTempOCI(ImageRepo)
subjectRef := LayoutRef(root, foobar.Tag)
prepare(root)
// test
ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)).
WithWorkDir(root).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architecture": "arm64",
"os": "linux"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
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.oci.image.config.v1+json","digest":"sha256:1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1","size":53},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1","size":10240,"annotations":{"org.opencontainers.image.title":"hello.tar"}}]}
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.oci.image.config.v1+json","digest":"sha256:a5dfce5d28768e985f91f610591f0203bb6e07f11e2fb0ce1b8508e9aac4ebe2","size":73},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1","size":10240,"annotations":{"org.opencontainers.image.title":"hello.tar"}}]}
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.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1","size":10240,"annotations":{"org.opencontainers.image.title":"hello.tar"}}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architecture": "arm",
"os": "linux",
"variant": "v7"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mediaType":"application/vnd.oci.image.index.v1+json","schemaVersion":2,"manifests":[{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1","size":458,"platform":{"architecture":"amd64","os":"linux"}},{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:4f93460061882467e6fb3b772dc6ab72130d9ac1906aed2fc7589a5cd145433c","size":458,"platform":{"architecture":"arm64","os":"linux"}},{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:58efe73e78fe043ca31b89007a025c594ce12aa7e6da27d21c7b14b50112e255","size":458,"platform":{"architecture":"arm","os":"linux","variant":"v7"}}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bar
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,"annotations":{"org.opencontainers.image.title":"foo1"}},{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae","size":3,"annotations":{"org.opencontainers.image.title":"foo2"}},{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9","size":3,"annotations":{"org.opencontainers.image.title":"bar"}}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architecture": "amd64",
"os": "linux"
}
49 changes: 49 additions & 0 deletions test/e2e/testdata/zot/command/images/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f",
"size": 706,
"annotations": {
"org.opencontainers.image.ref.name": "multi"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb",
"size": 851,
"annotations": {
"org.opencontainers.image.ref.name": "foobar"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:58efe73e78fe043ca31b89007a025c594ce12aa7e6da27d21c7b14b50112e255",
"size": 458,
"platform": {
"architecture": "arm",
"os": "linux",
"variant": "v7"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:4f93460061882467e6fb3b772dc6ab72130d9ac1906aed2fc7589a5cd145433c",
"size": 458,
"platform": {
"architecture": "arm64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1",
"size": 458,
"platform": {
"architecture": "amd64",
"os": "linux"
}
}
]
}
1 change: 1 addition & 0 deletions test/e2e/testdata/zot/command/images/oci-layout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"imageLayoutVersion":"1.0.0"}