From fdcf633a33bbbfbc99268965ef5da03a4770619b Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 29 Mar 2018 11:01:47 -0400 Subject: Add hooks support to podman Signed-off-by: Daniel J Walsh Closes: #155 Approved by: mheon --- test/e2e/hooks/checkhook.json | 5 +++++ test/e2e/hooks/checkhook.sh | 4 ++++ test/e2e/libpod_suite_test.go | 3 +++ test/e2e/run_test.go | 14 ++++++++++++++ test/hooks/checkhook.json | 5 ----- test/hooks/checkhook.sh | 4 ---- 6 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 test/e2e/hooks/checkhook.json create mode 100755 test/e2e/hooks/checkhook.sh delete mode 100644 test/hooks/checkhook.json delete mode 100755 test/hooks/checkhook.sh (limited to 'test') diff --git a/test/e2e/hooks/checkhook.json b/test/e2e/hooks/checkhook.json new file mode 100644 index 000000000..5a9bc86d1 --- /dev/null +++ b/test/e2e/hooks/checkhook.json @@ -0,0 +1,5 @@ +{ + "cmd" : [".*"], + "hook" : "/tmp/checkhook.sh", + "stage" : [ "prestart" ] +} diff --git a/test/e2e/hooks/checkhook.sh b/test/e2e/hooks/checkhook.sh new file mode 100755 index 000000000..8b755cb40 --- /dev/null +++ b/test/e2e/hooks/checkhook.sh @@ -0,0 +1,4 @@ +#!/bin/sh +echo $@ >> /run/hookscheck +read line +echo $line >> /run/hookscheck diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index 5bdc112fb..a902949ba 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -156,6 +156,9 @@ func (p *PodmanTest) MakeOptions() []string { // Podman is the exec call to podman on the filesystem func (p *PodmanTest) Podman(args []string) *PodmanSession { podmanOptions := p.MakeOptions() + if os.Getenv("HOOK_OPTION") != "" { + podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) + } podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...) podmanOptions = append(podmanOptions, args...) fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " ")) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 16fae5898..21c577d9a 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" + "github.com/mrunalp/fileutils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -217,6 +218,19 @@ var _ = Describe("Podman run", func() { Expect(session.ExitCode()).To(Equal(0)) }) + It("podman test hooks", func() { + hcheck := "/run/hookscheck" + hooksDir := "/tmp/hooks" + os.Mkdir(hooksDir, 0755) + fileutils.CopyFile("hooks/hooks.json", hooksDir) + os.Setenv("HOOK_OPTION", fmt.Sprintf("--hooks-dir-path=%s", hooksDir)) + os.Remove(hcheck) + session := podmanTest.Podman([]string{"run", ALPINE, "ls"}) + session.Wait(10) + os.Unsetenv("HOOK_OPTION") + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman run with secrets", func() { containersDir := "/usr/share/containers" err := os.MkdirAll(containersDir, 0755) diff --git a/test/hooks/checkhook.json b/test/hooks/checkhook.json deleted file mode 100644 index 50ff23727..000000000 --- a/test/hooks/checkhook.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "cmd" : [".*"], - "hook" : "HOOKSDIR/checkhook.sh", - "stage" : [ "prestart" ] -} diff --git a/test/hooks/checkhook.sh b/test/hooks/checkhook.sh deleted file mode 100755 index 8b755cb40..000000000 --- a/test/hooks/checkhook.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -echo $@ >> /run/hookscheck -read line -echo $line >> /run/hookscheck -- cgit v1.2.3-54-g00ecf