diff options
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/common_test.go | 3 | ||||
-rw-r--r-- | test/e2e/hooks/checkhook.json | 5 | ||||
-rwxr-xr-x | test/e2e/hooks/checkhook.sh | 4 | ||||
-rw-r--r-- | test/e2e/libpod_suite_remote_test.go | 3 | ||||
-rw-r--r-- | test/e2e/run_test.go | 33 |
5 files changed, 26 insertions, 22 deletions
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 59252fcb0..a61ef8640 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -861,9 +861,6 @@ func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache boo podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --network-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s", debug, p.Root, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.NetworkConfigDir, p.CgroupManager, p.TmpDir, eventsType), " ") - if os.Getenv("HOOK_OPTION") != "" { - podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) - } if !p.RemoteTest { podmanOptions = append(podmanOptions, "--network-backend", p.NetworkBackend.ToString()) diff --git a/test/e2e/hooks/checkhook.json b/test/e2e/hooks/checkhook.json deleted file mode 100644 index 5a9bc86d1..000000000 --- a/test/e2e/hooks/checkhook.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "cmd" : [".*"], - "hook" : "/tmp/checkhook.sh", - "stage" : [ "prestart" ] -} diff --git a/test/e2e/hooks/checkhook.sh b/test/e2e/hooks/checkhook.sh deleted file mode 100755 index 8b755cb40..000000000 --- a/test/e2e/hooks/checkhook.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -echo $@ >> /run/hookscheck -read line -echo $line >> /run/hookscheck diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go index 8357246a5..19affbc6d 100644 --- a/test/e2e/libpod_suite_remote_test.go +++ b/test/e2e/libpod_suite_remote_test.go @@ -138,9 +138,6 @@ func getRemoteOptions(p *PodmanTestIntegration, args []string) []string { networkDir := p.NetworkConfigDir podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --network-config-dir %s --cgroup-manager %s", p.Root, p.RunRoot, p.OCIRuntime, p.ConmonBinary, networkDir, p.CgroupManager), " ") - if os.Getenv("HOOK_OPTION") != "" { - podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) - } if p.NetworkBackend.ToString() == "netavark" { podmanOptions = append(podmanOptions, "--network-backend", "netavark") } diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index afcca6ff0..182ae1888 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -16,7 +16,6 @@ import ( "github.com/containers/podman/v4/pkg/rootless" . "github.com/containers/podman/v4/test/utils" "github.com/containers/storage/pkg/stringid" - "github.com/mrunalp/fileutils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" @@ -811,18 +810,38 @@ USER bin`, BB) }) It("podman test hooks", func() { - hcheck := "/run/hookscheck" + SkipIfRemote("--hooks-dir does not work with remote") hooksDir := tempdir + "/hooks" err := os.Mkdir(hooksDir, 0755) Expect(err).ToNot(HaveOccurred()) - err = fileutils.CopyFile("hooks/hooks.json", hooksDir) + hookJSONPath := filepath.Join(hooksDir, "checkhooks.json") + hookScriptPath := filepath.Join(hooksDir, "checkhooks.sh") + targetFile := filepath.Join(hooksDir, "target") + + hookJSON := fmt.Sprintf(`{ + "cmd" : [".*"], + "hook" : "%s", + "stage" : [ "prestart" ] +} +`, hookScriptPath) + err = ioutil.WriteFile(hookJSONPath, []byte(hookJSON), 0644) Expect(err).ToNot(HaveOccurred()) - os.Setenv("HOOK_OPTION", fmt.Sprintf("--hooks-dir=%s", hooksDir)) - os.Remove(hcheck) - session := podmanTest.Podman([]string{"run", ALPINE, "ls"}) + + random := stringid.GenerateNonCryptoID() + + hookScript := fmt.Sprintf(`#!/bin/sh +echo -n %s >%s +`, random, targetFile) + err = ioutil.WriteFile(hookScriptPath, []byte(hookScript), 0755) + Expect(err).ToNot(HaveOccurred()) + + session := podmanTest.Podman([]string{"--hooks-dir", hooksDir, "run", ALPINE, "ls"}) session.Wait(10) - os.Unsetenv("HOOK_OPTION") Expect(session).Should(Exit(0)) + + b, err := ioutil.ReadFile(targetFile) + Expect(err).ToNot(HaveOccurred()) + Expect(string(b)).To(Equal(random)) }) It("podman run with subscription secrets", func() { |