summaryrefslogtreecommitdiff
path: root/test/e2e/run_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-04-29 11:31:39 -0400
committerGitHub <noreply@github.com>2022-04-29 11:31:39 -0400
commit95ff349de22e01eaa76cfc19891cc37952789b82 (patch)
treeddfaeb501528c01a93624e357774116f4819f210 /test/e2e/run_test.go
parent73836e0c6a22d919dd8be297bafd137f1bd8ec9e (diff)
parente6557bf0a291f4462081e50461b1b9b8715d1da3 (diff)
downloadpodman-95ff349de22e01eaa76cfc19891cc37952789b82.tar.gz
podman-95ff349de22e01eaa76cfc19891cc37952789b82.tar.bz2
podman-95ff349de22e01eaa76cfc19891cc37952789b82.zip
Merge pull request #14031 from Luap99/errcheck
enable errcheck linter
Diffstat (limited to 'test/e2e/run_test.go')
-rw-r--r--test/e2e/run_test.go38
1 files changed, 29 insertions, 9 deletions
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 386a27a2f..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"
@@ -36,7 +35,6 @@ var _ = Describe("Podman run", func() {
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
- podmanTest.SeedImages()
})
AfterEach(func() {
@@ -812,16 +810,38 @@ USER bin`, BB)
})
It("podman test hooks", func() {
- hcheck := "/run/hookscheck"
+ SkipIfRemote("--hooks-dir does not work with remote")
hooksDir := tempdir + "/hooks"
- os.Mkdir(hooksDir, 0755)
- fileutils.CopyFile("hooks/hooks.json", hooksDir)
- os.Setenv("HOOK_OPTION", fmt.Sprintf("--hooks-dir=%s", hooksDir))
- os.Remove(hcheck)
- session := podmanTest.Podman([]string{"run", ALPINE, "ls"})
+ err := os.Mkdir(hooksDir, 0755)
+ Expect(err).ToNot(HaveOccurred())
+ 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())
+
+ 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() {