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 all commits
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ 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/command/blobs
!test/e2e/testdata/zot/command/images/
!test/e2e/testdata/zot/command/artifacts/
!test/e2e/testdata/zot/command/blobs/
!test/e2e/testdata/zot/config.json
!test/e2e/testdata/zot/passwd_bcrypt
51 changes: 22 additions & 29 deletions test/e2e/suite/command/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var _ = Describe("Remote registry users:", func() {
pullRoot := "pulled"
tempDir := PrepareTempFiles()
stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName))
ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot).
ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot).
MatchStatus(stateKeys, true, len(stateKeys)).
WithWorkDir(tempDir).Exec()
// check config
Expand All @@ -67,7 +67,7 @@ var _ = Describe("Remote registry users:", func() {
WithWorkDir(tempDir).Exec()
}

ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files").
ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files").
ExpectFailure().
WithDescription("fail if overwrite old files are disabled")
})
Expand All @@ -76,7 +76,7 @@ var _ = Describe("Remote registry users:", func() {
pullRoot := "pulled"
tempDir := PrepareTempFiles()
stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(oras.MediaTypeUnknownConfig))
ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot).
ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot).
MatchStatus(stateKeys, true, len(stateKeys)).
WithWorkDir(tempDir).Exec()
// check config
Expand All @@ -96,13 +96,13 @@ var _ = Describe("Remote registry users:", func() {
foobar.ManifestStateKey),
foobar.ImageReferrersStateKeys...,
)
ORAS("pull", RegistryRef(Host, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject").
ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject").
MatchStatus(stateKeys, true, len(stateKeys)).
WithWorkDir(tempDir).Exec()
})

It("should pull specific platform", func() {
ORAS("pull", RegistryRef(Host, ImageRepo, "multi"), "--platform", "linux/amd64", "-v", "-o", GinkgoT().TempDir()).
ORAS("pull", RegistryRef(ZOTHost, ImageRepo, "multi"), "--platform", "linux/amd64", "-v", "-o", GinkgoT().TempDir()).
MatchStatus(multi_arch.LinuxAMD64StateKeys, true, len(multi_arch.LinuxAMD64StateKeys)).Exec()
})
})
Expand All @@ -113,70 +113,63 @@ var _ = Describe("OCI image layout users:", func() {
var (
configName = "test.config"
)
prepare := func(root string, repo string, tagOrDigest string) {
ORAS("cp", RegistryRef(Host, repo, tagOrDigest), Flags.ToLayout, LayoutRef(root, tagOrDigest), "-r").WithDescription("prepare oci layout test env").Exec()
}
It("should pull all files in an image to a target folder", func() {
pullRoot := "pulled"
tempDir := PrepareTempFiles()
prepare(tempDir, ArtifactRepo, foobar.Tag)
root := PrepareTempOCI(ImageRepo)
stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName))
ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "--config", configName, "-o", pullRoot).
ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "--config", configName, "-o", pullRoot).
MatchStatus(stateKeys, true, len(stateKeys)).
WithWorkDir(tempDir).Exec()
WithWorkDir(root).Exec()
// check config
configPath := filepath.Join(tempDir, pullRoot, configName)
configPath := filepath.Join(root, pullRoot, configName)
Expect(configPath).Should(BeAnExistingFile())
f, err := os.Open(configPath)
Expect(err).ShouldNot(HaveOccurred())
defer f.Close()
Eventually(gbytes.BufferReader(f)).Should(gbytes.Say("{}"))
for _, f := range foobar.ImageLayerNames {
// check layers
Binary("diff", filepath.Join(tempDir, "foobar", f), filepath.Join(pullRoot, f)).
WithWorkDir(tempDir).Exec()
Binary("diff", filepath.Join(root, "foobar", f), filepath.Join(pullRoot, f)).
WithWorkDir(root).Exec()
}

ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files").
ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files").
ExpectFailure().
WithDescription("fail if overwrite old files are disabled")
})

It("should skip config if media type does not match", func() {
pullRoot := "pulled"
tempDir := PrepareTempFiles()
prepare(tempDir, ArtifactRepo, foobar.Tag)
root := PrepareTempOCI(ImageRepo)
stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(oras.MediaTypeUnknownConfig))
ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot).
ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot).
MatchStatus(stateKeys, true, len(stateKeys)).
WithWorkDir(tempDir).Exec()
WithWorkDir(root).Exec()
// check config
Expect(filepath.Join(pullRoot, configName)).ShouldNot(BeAnExistingFile())
for _, f := range foobar.ImageLayerNames {
// check layers
Binary("diff", filepath.Join(tempDir, "foobar", f), filepath.Join(pullRoot, f)).
WithWorkDir(tempDir).
Binary("diff", filepath.Join(root, "foobar", f), filepath.Join(pullRoot, f)).
WithWorkDir(root).
WithDescription("should download identical file " + f).Exec()
}
})

It("should pull subject", func() {
tempDir := GinkgoT().TempDir()
prepare(tempDir, ArtifactRepo, foobar.Tag)
root := PrepareTempOCI(ArtifactRepo)
stateKeys := append(append(
foobar.ImageLayerStateKeys,
foobar.ManifestStateKey),
foobar.ImageReferrersStateKeys...,
)
ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject").
ORAS("pull", Flags.Layout, LayoutRef(root, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject").
MatchStatus(stateKeys, true, len(stateKeys)).
WithWorkDir(tempDir).Exec()
WithWorkDir(root).Exec()
})

It("should pull specific platform", func() {
tempDir := GinkgoT().TempDir()
prepare(tempDir, ImageRepo, multi_arch.Tag)
ORAS("pull", Flags.Layout, LayoutRef(tempDir, multi_arch.Tag), "--platform", "linux/amd64", "-v", "-o", tempDir).
root := PrepareTempOCI(ImageRepo)
ORAS("pull", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--platform", "linux/amd64", "-v", "-o", root).
MatchStatus(multi_arch.LinuxAMD64StateKeys, true, len(multi_arch.LinuxAMD64StateKeys)).Exec()
})
})
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","config":{"mediaType":"test.signature.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d","size":16,"annotations":{"org.opencontainers.image.title":"signature"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47","size":660},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:57Z"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
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":"test.sbom.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38","size":11,"annotations":{"org.opencontainers.image.title":"sbom"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb","size":851},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:42Z"}}
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 @@
mocked signature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mocked sbom
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"}}]}
23 changes: 23 additions & 0 deletions test/e2e/testdata/zot/command/artifacts/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"schemaVersion": 2,
"manifests": [
{
"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:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47",
"size": 660
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17",
"size": 670
}
]
}
1 change: 1 addition & 0 deletions test/e2e/testdata/zot/command/artifacts/oci-layout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"imageLayoutVersion":"1.0.0"}
Loading