mirror of https://github.com/containers/podman.git
test: fix manifest e2e test assumption
fix an assumption in the test, that the --compression-format is unchanged from the original image. Instead validate that all the required architectures are part of the manifest. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
8377483145
commit
c50826cea9
|
@ -16,6 +16,35 @@ import (
|
|||
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// validateManifestHasAllArchs checks that the specified manifest has all
|
||||
// the archs in `imageList`
|
||||
func validateManifestHasAllArchs(path string) error {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var result struct {
|
||||
Manifests []struct {
|
||||
Platform struct {
|
||||
Architecture string
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := json.Unmarshal(data, &result); err != nil {
|
||||
return err
|
||||
}
|
||||
archs := map[string]bool{
|
||||
"amd64": false,
|
||||
"arm64": false,
|
||||
"ppc64le": false,
|
||||
"s390x": false,
|
||||
}
|
||||
for _, m := range result.Manifests {
|
||||
archs[m.Platform.Architecture] = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Internal function to verify instance compression
|
||||
func verifyInstanceCompression(descriptor []imgspecv1.Descriptor, compression string, arch string) bool {
|
||||
for _, instance := range descriptor {
|
||||
|
@ -419,19 +448,8 @@ add_compression = ["zstd"]`), 0o644)
|
|||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
files, err := filepath.Glob(dest + string(os.PathSeparator) + "*")
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
check := SystemExec("sha256sum", files)
|
||||
check.WaitWithDefaultTimeout()
|
||||
Expect(check).Should(ExitCleanly())
|
||||
prefix := "sha256:"
|
||||
Expect(check.OutputToString()).To(
|
||||
And(
|
||||
ContainSubstring(strings.TrimPrefix(imageListAMD64InstanceDigest, prefix)),
|
||||
ContainSubstring(strings.TrimPrefix(imageListPPC64LEInstanceDigest, prefix)),
|
||||
ContainSubstring(strings.TrimPrefix(imageListS390XInstanceDigest, prefix)),
|
||||
ContainSubstring(strings.TrimPrefix(imageListARM64InstanceDigest, prefix)),
|
||||
))
|
||||
err = validateManifestHasAllArchs(filepath.Join(dest, "manifest.json"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("push", func() {
|
||||
|
@ -451,20 +469,9 @@ add_compression = ["zstd"]`), 0o644)
|
|||
session = podmanTest.Podman([]string{"push", "-q", "foo", "dir:" + dest})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
files, err := filepath.Glob(dest + string(os.PathSeparator) + "*")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
check := SystemExec("sha256sum", files)
|
||||
check.WaitWithDefaultTimeout()
|
||||
Expect(check).Should(ExitCleanly())
|
||||
|
||||
prefix := "sha256:"
|
||||
Expect(check.OutputToString()).To(
|
||||
And(
|
||||
ContainSubstring(strings.TrimPrefix(imageListAMD64InstanceDigest, prefix)),
|
||||
ContainSubstring(strings.TrimPrefix(imageListPPC64LEInstanceDigest, prefix)),
|
||||
ContainSubstring(strings.TrimPrefix(imageListS390XInstanceDigest, prefix)),
|
||||
ContainSubstring(strings.TrimPrefix(imageListARM64InstanceDigest, prefix)),
|
||||
))
|
||||
err = validateManifestHasAllArchs(filepath.Join(dest, "manifest.json"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("push with compression-format and compression-level", func() {
|
||||
|
|
Loading…
Reference in New Issue