summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2021-12-15 13:32:57 -0600
committerBrent Baude <bbaude@redhat.com>2022-01-06 13:56:54 -0600
commit2a524fcaec4e6f66461d7cdda1bb73ed7c50f026 (patch)
treea9aa7d871da64cb5c70b5d139bdde3cc4481184f /test
parent2fd6c2ee89e92ced8568d7ed3ea3f04017b154ed (diff)
downloadpodman-2a524fcaec4e6f66461d7cdda1bb73ed7c50f026.tar.gz
podman-2a524fcaec4e6f66461d7cdda1bb73ed7c50f026.tar.bz2
podman-2a524fcaec4e6f66461d7cdda1bb73ed7c50f026.zip
fix healthcheck timeouts and ut8 coercion
this commit fixes two bugs and adds regression tests. when getting healthcheck values from an image, if the image does not have a timeout defined, this resulted in a 0 value for timeout. The default as described in the man pages is 30s. when inspecting a container with a healthcheck command, a customer observed that the &, <, and > characters were being converted into a unicode escape value. It turns out json marshalling will by default coerce string values to ut8. Fixes: bz2028408 Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/healthcheck_run_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go
index c2084a6fd..6a79006b6 100644
--- a/test/e2e/healthcheck_run_test.go
+++ b/test/e2e/healthcheck_run_test.go
@@ -2,7 +2,9 @@ package integration
import (
"fmt"
+ "io/ioutil"
"os"
+ "path/filepath"
"time"
define "github.com/containers/podman/v3/libpod/define"
@@ -258,4 +260,40 @@ var _ = Describe("Podman healthcheck run", func() {
Expect(startAgain.OutputToString()).To(Equal("hc"))
Expect(startAgain.ErrorToString()).To(Equal(""))
})
+
+ It("Verify default time is used and no utf-8 escapes", func() {
+ cwd, err := os.Getwd()
+ Expect(err).To(BeNil())
+
+ podmanTest.AddImageToRWStore(ALPINE)
+ // Write target and fake files
+ targetPath, err := CreateTempDirInTempDir()
+ Expect(err).To(BeNil())
+ containerfile := fmt.Sprintf(`FROM %s
+HEALTHCHECK CMD ls -l / 2>&1`, ALPINE)
+ containerfilePath := filepath.Join(targetPath, "Containerfile")
+ err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644)
+ Expect(err).To(BeNil())
+ defer func() {
+ Expect(os.Chdir(cwd)).To(BeNil())
+ Expect(os.RemoveAll(targetPath)).To(BeNil())
+ }()
+
+ // make cwd as context root path
+ Expect(os.Chdir(targetPath)).To(BeNil())
+
+ session := podmanTest.Podman([]string{"build", "--format", "docker", "-t", "test", "."})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ run := podmanTest.Podman([]string{"run", "-dt", "--name", "hctest", "test", "ls"})
+ run.WaitWithDefaultTimeout()
+ Expect(run).Should(Exit(0))
+
+ inspect := podmanTest.InspectContainer("hctest")
+ // Check to make sure a default time value was added
+ Expect(inspect[0].Config.Healthcheck.Timeout).To(BeNumerically("==", 30000000000))
+ // Check to make sure characters were not coerced to utf8
+ Expect(inspect[0].Config.Healthcheck.Test).To(Equal([]string{"CMD-SHELL", "ls -l / 2>&1"}))
+ })
})