Skip to content

Commit

Permalink
??? Work around zstd:chunked images in health checks
Browse files Browse the repository at this point in the history
Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Oct 30, 2024
1 parent a17988e commit 5345c94
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/e2e/healthcheck_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,23 @@ var _ = Describe("Podman healthcheck run", func() {
session := podmanTest.Podman([]string{"create", "-q", "--name", "hc", "quay.io/libpod/healthcheck:config-only", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

inspect := podmanTest.Podman([]string{"image", "inspect", "quay.io/libpod/healthcheck:config-only", "--format", "{{.ManifestType}}"})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(ExitCleanly())
manifestType := inspect.OutputToString()

hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Healthcheck}}", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(ExitCleanly())
Expect(hc.OutputToString()).To(Equal("{[CMD-SHELL curl -f http://localhost/ || exit 1] 0s 0s 5m0s 3s 0}"))
switch manifestType {
case "application/vnd.docker.distribution.manifest.v2+json":
Expect(hc.OutputToString()).To(Equal("{[CMD-SHELL curl -f http://localhost/ || exit 1] 0s 0s 5m0s 3s 0}"))
case "application/vnd.oci.image.manifest.v1+json": // The image was converted to OCI. This rather defeats the point of the test.
Expect(hc.OutputToString()).To(Equal("<nil>"))
default:
Fail(fmt.Sprintf("Unexpected manifest type %q", manifestType))
}
})

It("podman disable healthcheck with --health-cmd=none on valid container", func() {
Expand Down Expand Up @@ -113,6 +126,19 @@ var _ = Describe("Podman healthcheck run", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

inspect := podmanTest.Podman([]string{"image", "inspect", "quay.io/libpod/badhealthcheck:latest", "--format", "{{.ManifestType}}"})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(ExitCleanly())
manifestType := inspect.OutputToString()
switch manifestType {
case "application/vnd.docker.distribution.manifest.v2+json":
// Proceed
case "application/vnd.oci.image.manifest.v1+json": // The image was converted to OCI. This rather defeats the point of the test.
Skip("Test image was converted to OCI")
default:
Fail(fmt.Sprintf("Unexpected manifest type %q", manifestType))
}

hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(ExitWithError(1, ""))
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ var _ = Describe("Podman inspect", func() {
session := podmanTest.Podman([]string{"inspect", "--format=json", HEALTHCHECK_IMAGE})
session.WaitWithDefaultTimeout()
imageData := session.InspectImageJSON()
switch imageData[0].ManifestType {
case "application/vnd.docker.distribution.manifest.v2+json":
// Proceed
case "application/vnd.oci.image.manifest.v1+json": // The image was converted to OCI. This rather defeats the point of the test.
Skip("Test image was converted to OCI")
default:
Fail(fmt.Sprintf("Unexpected manifest type %q", imageData[0].ManifestType))
}
Expect(imageData[0].HealthCheck.Timeout).To(BeNumerically("==", 3000000000))
Expect(imageData[0].HealthCheck.Interval).To(BeNumerically("==", 60000000000))
Expect(imageData[0].HealthCheck).To(HaveField("Test", []string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"}))
Expand Down

0 comments on commit 5345c94

Please sign in to comment.