Skip to content

Commit

Permalink
Define, and use, PodmanExitCleanlyWithOptions
Browse files Browse the repository at this point in the history
This is a generalization of PodmanExitCleanly, scalable
to an arbitrary number of possible options.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Jan 22, 2025
1 parent 91fc5ea commit 5fc2200
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
9 changes: 8 additions & 1 deletion test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,14 @@ func (s *PodmanSessionIntegration) InspectImageJSON() []inspect.ImageData {
// It returns the session (to allow consuming output if desired).
func (p *PodmanTestIntegration) PodmanExitCleanly(args ...string) *PodmanSessionIntegration {
GinkgoHelper()
session := p.Podman(args)
return p.PodmanExitCleanlyWithOptions(PodmanExecOptions{}, args...)
}

// PodmanExicCleanlyWithOptions runs a podman command with (optinos, args), and expects it to ExitCleanly within the default timeout.
// It returns the session (to allow consuming output if desired).
func (p *PodmanTestIntegration) PodmanExitCleanlyWithOptions(options PodmanExecOptions, args ...string) *PodmanSessionIntegration {
GinkgoHelper()
session := p.PodmanWithOptions(options, args...)
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
return session
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,9 @@ var _ = Describe("Podman exec", func() {
files := []*os.File{
devNull,
}
session := podmanTest.PodmanWithOptions(PodmanExecOptions{
podmanTest.PodmanExitCleanlyWithOptions(PodmanExecOptions{
ExtraFiles: files,
}, "exec", "--preserve-fds", "1", "test1", "ls")
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})

It("podman exec preserves --group-add groups", func() {
Expand Down
10 changes: 4 additions & 6 deletions test/e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1710,18 +1710,16 @@ VOLUME %s`, ALPINE, volPath, volPath)
if isRootless() {
scopeOptions.Wrapper = append(scopeOptions.Wrapper, "--user")
}
container := podmanTest.PodmanWithOptions(scopeOptions, "run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup")
container.WaitWithDefaultTimeout()
Expect(container).Should(Exit(0))
container := podmanTest.PodmanExitCleanlyWithOptions(scopeOptions,
"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup")
checkLines(container.OutputToStringArray())
Expect(container.ErrorToString()).To(Or(
ContainSubstring("Running scope as unit: "), // systemd < 255
ContainSubstring("Running as unit: "))) // systemd >= 255

// check that --cgroups=split is honored also when a container runs in a pod
container = podmanTest.PodmanWithOptions(scopeOptions, "run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup")
container.WaitWithDefaultTimeout()
Expect(container).Should(Exit(0))
container = podmanTest.PodmanExitCleanlyWithOptions(scopeOptions,
"run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup")
checkLines(container.OutputToStringArray())
Expect(container.ErrorToString()).To(Or(
ContainSubstring("Running scope as unit: "), // systemd < 255
Expand Down

0 comments on commit 5fc2200

Please sign in to comment.