Skip to content

Commit

Permalink
update copy e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Jan 25, 2024
1 parent 2e41840 commit dcd5e44
Showing 1 changed file with 25 additions and 69 deletions.
94 changes: 25 additions & 69 deletions test/e2e/suite/command/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,11 @@ var _ = Describe("1.1 registry users:", func() {
Exec()
// validate
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst)
var index ocispec.Index
bytes := ORAS("discover", dst, "-o", "json", "--artifact-type", ma.IndexReferrerConfigStateKey.Name).
MatchKeyWords(ma.IndexReferrerDigest).
WithDescription("copy image referrer").
Exec().Out.Contents()
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(len(index.Manifests)).To(Equal(1))
Expect(index.Manifests[0].Digest.String()).To(Equal(ma.IndexReferrerDigest))
ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.LinuxAMD64Referrer.Digest.String())).
WithDescription("copy referrer of successor").
Exec()

digests := ORAS("discover", dst, "--format", "{{range .Manifests}}{{println .Digest}}{{end}}").Exec().Out.Contents()
for _, digest := range strings.Split(strings.TrimSpace(string(digests)), "\n") {
CompareRef(RegistryRef(ZOTHost, ArtifactRepo, digest), RegistryRef(ZOTHost, dstRepo, digest))
}
})

It("should copy a multi-arch image and its referrers without concurrency limitation", func() {
Expand All @@ -206,17 +200,10 @@ var _ = Describe("1.1 registry users:", func() {
Exec()
// validate
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst)
var index ocispec.Index
bytes := ORAS("discover", dst, "-o", "json", "--artifact-type", ma.IndexReferrerConfigStateKey.Name).
MatchKeyWords(ma.IndexReferrerDigest).
WithDescription("copy image referrer").
Exec().Out.Contents()
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(len(index.Manifests)).To(Equal(1))
Expect(index.Manifests[0].Digest.String()).To(Equal(ma.IndexReferrerDigest))
ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.LinuxAMD64Referrer.Digest.String())).
WithDescription("copy referrer of successor").
Exec()
digests := ORAS("discover", dst, "--format", "{{range .Manifests}}{{println .Digest}}{{end}}").Exec().Out.Contents()
for _, digest := range strings.Split(strings.TrimSpace(string(digests)), "\n") {
CompareRef(RegistryRef(ZOTHost, ArtifactRepo, digest), RegistryRef(ZOTHost, dstRepo, digest))
}
})

It("should copy an empty index", func() {
Expand All @@ -240,17 +227,10 @@ var _ = Describe("1.1 registry users:", func() {
Exec()
// validate
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst)
var index ocispec.Index
bytes := ORAS("discover", dst, "-o", "json", "--artifact-type", ma.IndexReferrerConfigStateKey.Name).
MatchKeyWords(ma.IndexReferrerDigest).
WithDescription("copy image referrer").
Exec().Out.Contents()
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(len(index.Manifests)).To(Equal(1))
Expect(index.Manifests[0].Digest.String()).To(Equal(ma.IndexReferrerDigest))
ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.LinuxAMD64Referrer.Digest.String())).
WithDescription("not copy referrer of successor").
Exec()
digests := ORAS("discover", dst, "--format", "{{range .Manifests}}{{println .Digest}}{{end}}").Exec().Out.Contents()
for _, digest := range strings.Split(strings.TrimSpace(string(digests)), "\n") {
CompareRef(RegistryRef(ZOTHost, ArtifactRepo, digest), RegistryRef(ZOTHost, dstRepo, digest))
}
})

It("should copy a certain platform of image to a new repository via tag", func() {
Expand Down Expand Up @@ -285,52 +265,28 @@ var _ = Describe("1.1 registry users:", func() {
MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()).
Exec()
// validate
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.LinuxAMD64.Digest.String()), dst)
var index ocispec.Index
bytes := ORAS("discover", dst, "-o", "json", "--platform", "linux/amd64").
MatchKeyWords(ma.LinuxAMD64Referrer.Digest.String()).
WithDescription("discover amd64 referrers").
Exec().Out.Contents()
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(len(index.Manifests)).To(Equal(1))
Expect(index.Manifests[0].Digest.String()).To(Equal(ma.LinuxAMD64Referrer.Digest.String()))
ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.Digest)).
WithDescription("not copy index").
ExpectFailure().
Exec()
ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.IndexReferrerDigest)).
WithDescription("not copy index referrer").
ExpectFailure().
Exec()
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst)
digests := ORAS("discover", dst, "--format", "{{range .Manifests}}{{println .Digest}}{{end}}").Exec().Out.Contents()
for _, digest := range strings.Split(strings.TrimSpace(string(digests)), "\n") {
CompareRef(RegistryRef(ZOTHost, ArtifactRepo, digest), RegistryRef(ZOTHost, dstRepo, digest))
}
})

It("should copy a certain platform of image and its referrers to a new repository without tagging", func() {
stateKeys := append(ma.LinuxAMD64StateKeys, ma.LinuxAMD64ReferrerStateKey, ma.LinuxAMD64ReferrerConfigStateKey)
src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag)
dstRepo := cpTestRepo("platform-referrers-no-tag")
ORAS("cp", src, RegistryRef(ZOTHost, dstRepo, ""), "-r", "--platform", "linux/amd64", "-v").
dst := RegistryRef(ZOTHost, dstRepo, "")
ORAS("cp", src, dst, "-r", "--platform", "linux/amd64", "-v").
MatchStatus(stateKeys, true, len(stateKeys)).
MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()).
Exec()
// validate
dstRef := RegistryRef(ZOTHost, dstRepo, ma.LinuxAMD64.Digest.String())
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.LinuxAMD64.Digest.String()), dstRef)
var index ocispec.Index
bytes := ORAS("discover", dstRef, "-o", "json", "--platform", "linux/amd64").
MatchKeyWords(ma.LinuxAMD64Referrer.Digest.String()).
WithDescription("discover amd64 referrers").
Exec().Out.Contents()
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(len(index.Manifests)).To(Equal(1))
Expect(index.Manifests[0].Digest.String()).To(Equal(ma.LinuxAMD64Referrer.Digest.String()))
ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.Digest)).
WithDescription("not copy index").
ExpectFailure().
Exec()
ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.IndexReferrerDigest)).
WithDescription("not copy index referrer").
ExpectFailure().
Exec()
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst)
digests := ORAS("discover", dst, "--format", "{{range .Manifests}}{{println .Digest}}{{end}}").Exec().Out.Contents()
for _, digest := range strings.Split(strings.TrimSpace(string(digests)), "\n") {
CompareRef(RegistryRef(ZOTHost, ArtifactRepo, digest), RegistryRef(ZOTHost, dstRepo, digest))
}
})

It("should copy an image to a new repository with multiple tagging", func() {
Expand Down

0 comments on commit dcd5e44

Please sign in to comment.