From bbf8b6313ac4c6466fc46e9c9daada862d1a1ebf Mon Sep 17 00:00:00 2001 From: "Lixia (Sylvia) Lei" Date: Mon, 2 Dec 2024 22:27:57 +0800 Subject: [PATCH] cp e2e Signed-off-by: Lixia (Sylvia) Lei --- test/e2e/suite/command/blob.go | 4 +- test/e2e/suite/command/cp.go | 64 ++++++++++++++++++-------- test/e2e/suite/command/push.go | 2 +- test/e2e/suite/command/resolve_host.go | 10 ++-- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/test/e2e/suite/command/blob.go b/test/e2e/suite/command/blob.go index 717a7d366..ab9815ff1 100644 --- a/test/e2e/suite/command/blob.go +++ b/test/e2e/suite/command/blob.go @@ -236,7 +236,7 @@ var _ = Describe("1.1 registry users:", func() { MatchContent(fmt.Sprintf(pushDescFmt, mediaType)).Exec() ORAS("blob", "fetch", RegistryRef(ZOTHost, repo, pushDigest), "--output", "-").MatchContent(pushContent).Exec() - ORAS("blob", "push", RegistryRef(ZOTHost, repo, ""), blobPath, "-v"). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, ""), blobPath). WithDescription("skip the pushing if the blob already exists in the target repo"). MatchKeyWords("Exists").Exec() }) @@ -347,7 +347,7 @@ var _ = Describe("OCI image layout users:", func() { // test ORAS("blob", "push", Flags.Layout, LayoutRef(tmpRoot, pushDigest), blobPath, "--media-type", mediaType, "--descriptor"). MatchContent(fmt.Sprintf(pushDescFmt, mediaType)).Exec() - ORAS("blob", "push", Flags.Layout, LayoutRef(tmpRoot, pushDigest), blobPath, "-v"). + ORAS("blob", "push", Flags.Layout, LayoutRef(tmpRoot, pushDigest), blobPath). WithDescription("skip pushing if the blob already exists in the target repo"). MatchKeyWords("Exists").Exec() // validate diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index d297197a3..4d1b1775d 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -34,6 +34,7 @@ import ( "oras.land/oras/test/e2e/internal/testdata/foobar" ma "oras.land/oras/test/e2e/internal/testdata/multi_arch" . "oras.land/oras/test/e2e/internal/utils" + "oras.land/oras/test/e2e/internal/utils/match" ) func cpTestRepo(text string) string { @@ -54,6 +55,29 @@ var _ = Describe("ORAS beginners:", func() { gomega.Expect(out).ShouldNot(gbytes.Say("--verbose")) }) + It("should show deprecation message and print unnamed status output for --verbose", func() { + src := RegistryRef(ZOTHost, ArtifactRepo, blob.Tag) + dst := RegistryRef(ZOTHost, cpTestRepo("test-verbose"), "copied") + ORAS("cp", src, dst, "--verbose"). + MatchErrKeyWords(DeprecationMessageVerboseFlag). + MatchStatus(blob.StateKeys, true, len(blob.StateKeys)). + Exec() + CompareRef(src, dst) + }) + + It("should show deprecation message and print unnamed status output for --verbose=false", func() { + src := RegistryRef(ZOTHost, ArtifactRepo, blob.Tag) + dst := RegistryRef(ZOTHost, cpTestRepo("test-verbose-false"), "copied") + stateKeys := []match.StateKey{ + {Digest: "2ef548696ac7", Name: "hello.tar"}, + } + ORAS("cp", src, dst, "--verbose=false"). + MatchErrKeyWords(DeprecationMessageVerboseFlag). + MatchStatus(stateKeys, true, len(stateKeys)). + Exec() + CompareRef(src, dst) + }) + It("should fail when no reference provided", func() { ORAS("cp").ExpectFailure().MatchErrKeyWords("Error:").Exec() }) @@ -127,7 +151,7 @@ var _ = Describe("1.1 registry users:", func() { It("should copy an artifact with blob", func() { src := RegistryRef(ZOTHost, ArtifactRepo, blob.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("artifact-with-blob"), "copied") - ORAS("cp", src, dst, "-v").MatchStatus(blob.StateKeys, true, len(blob.StateKeys)).Exec() + ORAS("cp", src, dst).MatchStatus(blob.StateKeys, true, len(blob.StateKeys)).Exec() CompareRef(src, dst) }) @@ -143,34 +167,34 @@ var _ = Describe("1.1 registry users:", func() { It("should copy an artifact with config", func() { src := RegistryRef(ZOTHost, ArtifactRepo, config.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("artifact-with-config"), "copied") - ORAS("cp", src, dst, "-v").MatchStatus(config.StateKeys, true, len(config.StateKeys)).Exec() + ORAS("cp", src, dst).MatchStatus(config.StateKeys, true, len(config.StateKeys)).Exec() }) It("should copy index and its subject", func() { stateKeys := append(ma.IndexStateKeys, index.ManifestStatusKey) src := RegistryRef(ZOTHost, ArtifactRepo, index.ManifestDigest) dst := RegistryRef(ZOTHost, cpTestRepo("index-with-subject"), "") - ORAS("cp", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() }) It("should copy an image to a new repository via tag", func() { src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("tag"), "copied") - ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst).MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) It("should copy an image to a new repository via digest", func() { src := RegistryRef(ZOTHost, ImageRepo, foobar.Digest) dst := RegistryRef(ZOTHost, cpTestRepo("digest"), "copiedTag") - ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst).MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) It("should copy an image to a new repository via tag without tagging", func() { src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("no-tagging"), foobar.Digest) - ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst).MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) @@ -178,7 +202,7 @@ var _ = Describe("1.1 registry users:", func() { stateKeys := append(append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageReferrerConfigStateKeys[0]), foobar.ImageReferrersStateKeys...) src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("referrers"), foobar.Digest) - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, dst) }) @@ -187,7 +211,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) dstRepo := cpTestRepo("index-referrers") dst := RegistryRef(ZOTHost, dstRepo, "copiedTag") - ORAS("cp", src, dst, "-r", "-v"). + ORAS("cp", src, dst, "-r"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -233,7 +257,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) dstRepo := cpTestRepo("index-referrers-digest") dst := RegistryRef(ZOTHost, dstRepo, ma.Digest) - ORAS("cp", src, dst, "-r", "-v"). + ORAS("cp", src, dst, "-r"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -249,7 +273,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(ZOTHost, ImageRepo, ma.Tag) dst := RegistryRef(ZOTHost, cpTestRepo("platform-tag"), "copiedTag") - ORAS("cp", src, dst, "--platform", "linux/amd64", "-v"). + ORAS("cp", src, dst, "--platform", "linux/amd64"). MatchStatus(ma.LinuxAMD64StateKeys, true, len(ma.LinuxAMD64StateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() @@ -260,7 +284,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(ZOTHost, ImageRepo, ma.Digest) dstRepo := cpTestRepo("platform-digest") dst := RegistryRef(ZOTHost, dstRepo, "") - ORAS("cp", src, dst, "--platform", "linux/amd64", "-v"). + ORAS("cp", src, dst, "--platform", "linux/amd64"). MatchStatus(ma.LinuxAMD64StateKeys, true, len(ma.LinuxAMD64StateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() @@ -273,7 +297,7 @@ var _ = Describe("1.1 registry users:", func() { dstRepo := cpTestRepo("platform-referrers") dst := RegistryRef(ZOTHost, dstRepo, "copiedTag") digest := ma.LinuxAMD64.Digest.String() - ORAS("cp", src, dst, "-r", "--platform", "linux/amd64", "-v"). + ORAS("cp", src, dst, "-r", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + digest). Exec() @@ -291,7 +315,7 @@ var _ = Describe("1.1 registry users:", func() { dstRepo := cpTestRepo("platform-referrers-no-tag") dst := RegistryRef(ZOTHost, dstRepo, "") digest := ma.LinuxAMD64.Digest.String() - ORAS("cp", src, dst, "-r", "--platform", "linux/amd64", "-v"). + ORAS("cp", src, dst, "-r", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + digest). Exec() @@ -308,7 +332,7 @@ var _ = Describe("1.1 registry users:", func() { tags := []string{"tag1", "tag2", "tag3"} dstRepo := cpTestRepo("multi-tagging") dst := RegistryRef(ZOTHost, dstRepo, "") - ORAS("cp", src, dst+":"+strings.Join(tags, ","), "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() + ORAS("cp", src, dst+":"+strings.Join(tags, ",")).MatchStatus(foobarStates, true, len(foobarStates)).Exec() for _, tag := range tags { dst := RegistryRef(ZOTHost, dstRepo, tag) CompareRef(src, dst) @@ -323,7 +347,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { repo := cpTestRepo("1.0-mount") src := RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag) dst := RegistryRef(FallbackHost, repo, "") - out := ORAS("cp", src, dst, "-v").Exec() + out := ORAS("cp", src, dst).Exec() Expect(out).Should(gbytes.Say("Mounted fcde2b2edba5 bar")) CompareRef(src, RegistryRef(FallbackHost, repo, foobar.Digest)) }) @@ -333,7 +357,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { stateKeys := append(append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageReferrerConfigStateKeys[0]), foobar.ImageReferrersStateKeys...) src := RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()) dst := RegistryRef(FallbackHost, repo, "") - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, RegistryRef(FallbackHost, repo, foobar.SignatureImageReferrer.Digest.String())) ORAS("discover", "-o", "tree", RegistryRef(FallbackHost, repo, foobar.Digest)). WithDescription("discover referrer via subject").MatchKeyWords(foobar.SignatureImageReferrer.Digest.String(), foobar.SBOMImageReferrer.Digest.String()).Exec() @@ -343,7 +367,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { stateKeys := append(append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageReferrerConfigStateKeys[0]), foobar.ImageReferrersStateKeys...) src := RegistryRef(FallbackHost, ArtifactRepo, foobar.SBOMImageReferrer.Digest.String()) dst := RegistryRef(ZOTHost, repo, "") - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, RegistryRef(ZOTHost, repo, foobar.SBOMImageReferrer.Digest.String())) ORAS("discover", "-o", "tree", RegistryRef(ZOTHost, repo, foobar.Digest)). WithDescription("discover referrer via subject").MatchKeyWords(foobar.SignatureImageReferrer.Digest.String(), foobar.SBOMImageReferrer.Digest.String()).Exec() @@ -528,7 +552,7 @@ var _ = Describe("OCI layout users:", func() { toDir := GinkgoT().TempDir() dst := LayoutRef(toDir, "copied") // test - ORAS("cp", src, Flags.ToLayout, dst, "-r", "-v"). + ORAS("cp", src, Flags.ToLayout, dst, "-r"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -557,7 +581,7 @@ var _ = Describe("OCI layout users:", func() { // prepare ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() // test - ORAS("cp", src, Flags.FromLayout, dst, "-r", "-v"). + ORAS("cp", src, Flags.FromLayout, dst, "-r"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() @@ -725,7 +749,7 @@ var _ = Describe("OCI image spec v1.1.0-rc2 artifact users:", func() { digest := foobar.SBOMArtifactReferrer.Digest.String() src := RegistryRef(Host, ArtifactRepo, digest) dst := RegistryRef(Host, cpTestRepo("referrers"), digest) - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + ORAS("cp", "-r", src, dst).MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, dst) }) }) diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index dc3a79458..f546d89b3 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -65,7 +65,7 @@ var _ = Describe("ORAS beginners:", func() { Exec() }) - It("should show deprecation message and print unnamed status output for --verbose", func() { + It("should show deprecation message and print unnamed status output for --verbose=false", func() { repo := pushTestRepo("test-verbose-false") tag := "e2e" tempDir := PrepareTempFiles() diff --git a/test/e2e/suite/command/resolve_host.go b/test/e2e/suite/command/resolve_host.go index 9d90d7a24..724705b05 100644 --- a/test/e2e/suite/command/resolve_host.go +++ b/test/e2e/suite/command/resolve_host.go @@ -126,7 +126,7 @@ var _ = Describe("1.1 registry users:", func() { It("should copy an image with source resolve DNS rules", func() { repo := testRepo("cp/from") dst := RegistryRef(Host, repo, "copied") - ORAS(append([]string{"cp", RegistryRef(mockedHost, ImageRepo, foobar.Tag), dst, "-v"}, from...)...). + ORAS(append([]string{"cp", RegistryRef(mockedHost, ImageRepo, foobar.Tag), dst}, from...)...). MatchStatus(foobarStates, true, len(foobarStates)). Exec() CompareRef(RegistryRef(Host, ImageRepo, foobar.Tag), dst) @@ -136,7 +136,7 @@ var _ = Describe("1.1 registry users:", func() { src := RegistryRef(Host, ImageRepo, foobar.Tag) repo := testRepo("cp/to") tag := "copied" - ORAS(append([]string{"cp", src, RegistryRef(mockedHost, repo, tag), "-v"}, to...)...). + ORAS(append([]string{"cp", src, RegistryRef(mockedHost, repo, tag)}, to...)...). MatchStatus(foobarStates, true, len(foobarStates)). Exec() CompareRef(src, RegistryRef(Host, repo, tag)) @@ -147,7 +147,7 @@ var _ = Describe("1.1 registry users:", func() { repo := testRepo("cp/base") tag := "copied" flags := append(to[2:], "--resolve", unary[1]) //hack to chop the destination flags off - ORAS(append([]string{"cp", src, RegistryRef(mockedHost, repo, tag), "-v"}, flags...)...). + ORAS(append([]string{"cp", src, RegistryRef(mockedHost, repo, tag)}, flags...)...). MatchStatus(foobarStates, true, len(foobarStates)). Exec() CompareRef(src, RegistryRef(Host, repo, tag)) @@ -157,7 +157,7 @@ var _ = Describe("1.1 registry users:", func() { repo := testRepo("cp/override") tag := "copied" flags := append(append(to, from...), "--resolve", mockedHost+":80:1.1.1.1:5000") - ORAS(append([]string{"cp", RegistryRef(mockedHost, ImageRepo, foobar.Tag), RegistryRef(mockedHost, repo, tag), "-v"}, flags...)...). + ORAS(append([]string{"cp", RegistryRef(mockedHost, ImageRepo, foobar.Tag), RegistryRef(mockedHost, repo, tag)}, flags...)...). MatchStatus(foobarStates, true, len(foobarStates)). Exec() CompareRef(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, repo, tag)) @@ -235,7 +235,7 @@ var _ = Describe("1.1 registry users:", func() { It("should push files without customized media types", func() { repo := testRepo("push") tempDir := PrepareTempFiles() - ORAS(append([]string{"push", RegistryRef(mockedHost, repo, foobar.Tag), "-v"}, append(foobar.FileLayerNames, unary...)...)...). + ORAS(append([]string{"push", RegistryRef(mockedHost, repo, foobar.Tag)}, append(foobar.FileLayerNames, unary...)...)...). MatchStatus(foobar.FileStateKeys, true, len(foobar.FileStateKeys)). WithWorkDir(tempDir).Exec() })