From c5ea73ede4842eab64dabdef33c905c7a692b4a7 Mon Sep 17 00:00:00 2001 From: James Hewitt Date: Mon, 25 Nov 2024 16:10:56 +0000 Subject: [PATCH] Add a test for forcing compression and v2s2 format This highlights a bug in common where the compression format is reset if the format is v2s2, even if its a valid compression format. Signed-off-by: James Hewitt --- test/e2e/push_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index d18e87ae0b..1b4ae01db0 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -141,6 +141,47 @@ var _ = Describe("Podman push", func() { Expect(output).To(ContainSubstring("zstd")) }) + It("push test --force-compression --format=v2s2", func() { + if podmanTest.Host.Arch == "ppc64le" { + Skip("No registry image for ppc64le") + } + if isRootless() { + err := podmanTest.RestoreArtifact(REGISTRY_IMAGE) + Expect(err).ToNot(HaveOccurred()) + } + lock := GetPortLock("5005") + defer lock.Unlock() + session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5005:5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(ExitCleanly()) + + if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) { + Skip("Cannot start docker registry.") + } + + session = podmanTest.Podman([]string{"build", "-t", "imageone", "build/basicalpine"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(ExitCleanly()) + + push := podmanTest.Podman([]string{"push", "-q", "--tls-verify=false", "--force-compression=true", "--compression-format", "gzip", "--format", "v2s2", "--remove-signatures", "imageone", "localhost:5005/image"}) + push.WaitWithDefaultTimeout() + Expect(push).Should(ExitCleanly()) + + skopeoInspect := []string{"inspect", "--tls-verify=false", "--raw", "docker://localhost:5005/image:latest"} + skopeo := SystemExec("skopeo", skopeoInspect) + skopeo.WaitWithDefaultTimeout() + Expect(skopeo).Should(ExitCleanly()) + output := skopeo.OutputToString() + Expect(output).To(ContainSubstring("gzip")) + + push = podmanTest.Podman([]string{"push", "-q", "--tls-verify=false", "--force-compression=true", "--compression-format", "zstd", "--format", "v2s2", "--remove-signatures", "imageone", "localhost:5005/image"}) + push.WaitWithDefaultTimeout() + // the command is asking for an impossible thing; per containers/common#1869, we should detect + // that and fail with a precise error, but that does not exist, so we end up reporting this + // misleading text. When that is resolved, this test will need updating. + Expect(push).Should(ExitWithError(125, "cannot use ForceCompressionFormat with undefined default compression format")) + }) + It("podman push to local registry", func() { if podmanTest.Host.Arch == "ppc64le" { Skip("No registry image for ppc64le")