Skip to content

Commit

Permalink
Merge pull request #23864 from edsantiago/run-hook-sigpipe
Browse files Browse the repository at this point in the history
e2e: flake fix: SIGPIPE in hook test
  • Loading branch information
openshift-merge-bot[bot] authored Sep 5, 2024
2 parents 04ad9b6 + 579e8b2 commit ba7d4ed
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,29 @@ USER bin`, BB)
random := stringid.GenerateRandomID()

hookScript := fmt.Sprintf(`#!/bin/sh
echo -n %s >%s
teststring="%s"
tmpfile="%s"
# Hook gets invoked with config.json in stdin.
# Flush it, otherwise caller may get SIGPIPE.
cat >$tmpfile.json
# Check for required fields in our given json.
# Hooks have no visibility -- our output goes nowhere -- so
# use unique exit codes to give test code reader a hint as
# to what went wrong. Podman will exit 126, but will emit
# "crun: error executing hook .... (exit code: X)"
rc=1
for s in ociVersion id pid root bundle status annotations io.container.manager; do
grep -w $s $tmpfile.json || exit $rc
rc=$((rc + 1))
done
rm -f $tmpfile.json
# json contains all required keys. We're good so far.
# Now write a modified teststring to our tmpfile. Our
# caller will confirm.
echo -n madeit-$teststring >$tmpfile
`, random, targetFile)
err = os.WriteFile(hookScriptPath, []byte(hookScript), 0755)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -968,7 +990,7 @@ echo -n %s >%s

b, err := os.ReadFile(targetFile)
Expect(err).ToNot(HaveOccurred())
Expect(string(b)).To(Equal(random))
Expect(string(b)).To(Equal("madeit-" + random))
})

It("podman run with subscription secrets", func() {
Expand Down

1 comment on commit ba7d4ed

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.