From faf450ea18179bb0e4ae1213d3ca6c126b04b452 Mon Sep 17 00:00:00 2001
From: Valentin Rothberg <rothberg@redhat.com>
Date: Tue, 9 Nov 2021 14:43:55 +0100
Subject: support health checks from image configs

Health checks may be defined in the container config or the config of an
image.  So far, Podman only looked at the container config.

The plumbing happened in libimage but add a regression test to Podman as
well to make sure the glue code will not regress.

Note that I am pinning github.com/onsi/gomega to v1.16.0 since v1.17.0
requires go 1.16 which in turn is breaking CI.

Fixes: #12226
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
---
 test/e2e/healthcheck_run_test.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'test/e2e')

diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go
index b2666c789..c9a6f926f 100644
--- a/test/e2e/healthcheck_run_test.go
+++ b/test/e2e/healthcheck_run_test.go
@@ -52,6 +52,18 @@ var _ = Describe("Podman healthcheck run", func() {
 		Expect(hc).Should(Exit(125))
 	})
 
+	It("podman healthcheck from image's config (not container config)", func() {
+		// Regression test for #12226: a health check may be defined in
+		// the container or the container-config of an image.
+		session := podmanTest.Podman([]string{"create", "--name", "hc", "quay.io/libpod/healthcheck:config-only", "ls"})
+		session.WaitWithDefaultTimeout()
+		Expect(session).Should(Exit(0))
+		hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Healthcheck}}", "hc"})
+		hc.WaitWithDefaultTimeout()
+		Expect(hc).Should(Exit(0))
+		Expect(hc.OutputToString()).To(Equal("{[CMD-SHELL curl -f http://localhost/ || exit 1] 0s 5m0s 3s 0}"))
+	})
+
 	It("podman disable healthcheck with --health-cmd=none on valid container", func() {
 		session := podmanTest.Podman([]string{"run", "-dt", "--health-cmd", "none", "--name", "hc", healthcheck})
 		session.WaitWithDefaultTimeout()
-- 
cgit v1.2.3-54-g00ecf