diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-09-20 13:19:50 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2021-09-23 14:44:34 +0200 |
commit | 1199733754b1185d0d2a7a3d832c57565864d0f4 (patch) | |
tree | 20f7a33df89744836959f308e2faa8fa07f6ef95 /test | |
parent | aa628b82b1c2f04fb3a9a9207bb6d6bddb497fbb (diff) | |
download | podman-1199733754b1185d0d2a7a3d832c57565864d0f4.tar.gz podman-1199733754b1185d0d2a7a3d832c57565864d0f4.tar.bz2 podman-1199733754b1185d0d2a7a3d832c57565864d0f4.zip |
podman inspect add State.Health field for docker compat
podman inspect shows the healthcheck status in `.State.Healthcheck`,
docker uses `.State.Health`. To make sure docker scripts work we
should add the `Health` key. Because we do not want to display both keys
by default we only use the new `Health` key. This is a breaking change
for podman users but matches what docker does. To provide some form of
compatibility users can still use `--format {{.State.Healthcheck}}`. IT
is just not shown by default.
Fixes #11645
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/apiv2/python/rest_api/test_v2_0_0_container.py | 2 | ||||
-rw-r--r-- | test/e2e/healthcheck_run_test.go | 21 | ||||
-rw-r--r-- | test/system/220-healthcheck.bats | 4 |
3 files changed, 15 insertions, 12 deletions
diff --git a/test/apiv2/python/rest_api/test_v2_0_0_container.py b/test/apiv2/python/rest_api/test_v2_0_0_container.py index dbad6824f..853e9da88 100644 --- a/test/apiv2/python/rest_api/test_v2_0_0_container.py +++ b/test/apiv2/python/rest_api/test_v2_0_0_container.py @@ -56,7 +56,7 @@ class ContainerTestCase(APITestCase): self.assertEqual(r.status_code, 200, r.text) self.assertId(r.content) out = r.json() - self.assertIsNone(out["State"].get("Health")) + self.assertIsNotNone(out["State"].get("Health")) self.assertListEqual(["CMD", "pidof", "top"], out["Config"]["Healthcheck"]["Test"]) self.assertEqual(5000000000, out["Config"]["Healthcheck"]["Interval"]) self.assertEqual(2000000000, out["Config"]["Healthcheck"]["Timeout"]) diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 1445a634b..2826f2b34 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -117,7 +117,7 @@ var _ = Describe("Podman healthcheck run", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Healthcheck.Status).To(Equal("starting")) + Expect(inspect[0].State.Health.Status).To(Equal("starting")) }) It("podman healthcheck failed checks in start-period should not change status", func() { @@ -138,7 +138,9 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(1)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Healthcheck.Status).To(Equal("starting")) + Expect(inspect[0].State.Health.Status).To(Equal("starting")) + // test old podman compat (see #11645) + Expect(inspect[0].State.Healthcheck().Status).To(Equal("starting")) }) It("podman healthcheck failed checks must reach retries before unhealthy ", func() { @@ -151,15 +153,16 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(1)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Healthcheck.Status).To(Equal("starting")) + Expect(inspect[0].State.Health.Status).To(Equal("starting")) hc = podmanTest.Podman([]string{"healthcheck", "run", "hc"}) hc.WaitWithDefaultTimeout() Expect(hc).Should(Exit(1)) inspect = podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Healthcheck.Status).To(Equal(define.HealthCheckUnhealthy)) - + Expect(inspect[0].State.Health.Status).To(Equal(define.HealthCheckUnhealthy)) + // test old podman compat (see #11645) + Expect(inspect[0].State.Healthcheck().Status).To(Equal(define.HealthCheckUnhealthy)) }) It("podman healthcheck good check results in healthy even in start-period", func() { @@ -172,7 +175,7 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(0)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Healthcheck.Status).To(Equal(define.HealthCheckHealthy)) + Expect(inspect[0].State.Health.Status).To(Equal(define.HealthCheckHealthy)) }) It("podman healthcheck unhealthy but valid arguments check", func() { @@ -195,14 +198,14 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(1)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Healthcheck.Status).To(Equal("starting")) + Expect(inspect[0].State.Health.Status).To(Equal("starting")) hc = podmanTest.Podman([]string{"healthcheck", "run", "hc"}) hc.WaitWithDefaultTimeout() Expect(hc).Should(Exit(1)) inspect = podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Healthcheck.Status).To(Equal(define.HealthCheckUnhealthy)) + Expect(inspect[0].State.Health.Status).To(Equal(define.HealthCheckUnhealthy)) foo := podmanTest.Podman([]string{"exec", "hc", "touch", "/foo"}) foo.WaitWithDefaultTimeout() @@ -213,7 +216,7 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(0)) inspect = podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Healthcheck.Status).To(Equal(define.HealthCheckHealthy)) + Expect(inspect[0].State.Health.Status).To(Equal(define.HealthCheckHealthy)) // Test podman ps --filter heath is working (#11687) ps := podmanTest.Podman([]string{"ps", "--filter", "health=healthy"}) diff --git a/test/system/220-healthcheck.bats b/test/system/220-healthcheck.bats index e416629e6..e5a0e7e88 100644 --- a/test/system/220-healthcheck.bats +++ b/test/system/220-healthcheck.bats @@ -12,13 +12,13 @@ function _check_health { local testname="$1" local tests="$2" - run_podman inspect --format json healthcheck_c + run_podman inspect --format "{{json .State.Healthcheck}}" healthcheck_c parse_table "$tests" | while read field expect;do # (kludge to deal with parse_table and empty strings) if [ "$expect" = "''" ]; then expect=""; fi - actual=$(jq -r ".[0].State.Healthcheck.$field" <<<"$output") + actual=$(jq -r ".$field" <<<"$output") is "$actual" "$expect" "$testname - .State.Healthcheck.$field" done } |