summaryrefslogtreecommitdiff
path: root/test/e2e/run_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e/run_test.go')
-rw-r--r--test/e2e/run_test.go33
1 files changed, 26 insertions, 7 deletions
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() {