Skip to content

Commit

Permalink
Merge pull request #22455 from edsantiago/e2e-stop-littering
Browse files Browse the repository at this point in the history
e2e tests: stop littering
  • Loading branch information
openshift-merge-bot[bot] authored Apr 22, 2024
2 parents 6d34792 + ac04cb4 commit 318437f
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 101 deletions.
4 changes: 1 addition & 3 deletions test/e2e/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,9 @@ var _ = Describe("Podman create", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitWithError(125, "cannot specify both --pod and --pod-id-file"))

tmpDir := GinkgoT().TempDir()

podName := "rudolph"
ctrName := "prancer"
podIDFile := tmpDir + "pod-id-file"
podIDFile := filepath.Join(tempdir, "pod-id-file")

// Now, let's create a pod with --pod-id-file.
session = podmanTest.Podman([]string{"pod", "create", "--pod-id-file", podIDFile, "--name", podName})
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/generate_systemd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"os"
"path/filepath"
"strings"

. "github.com/containers/podman/v5/test/utils"
Expand Down Expand Up @@ -537,8 +538,7 @@ var _ = Describe("Podman generate systemd", func() {
})

It("podman generate systemd pod with containers --new", func() {
tmpDir := GinkgoT().TempDir()
tmpFile := tmpDir + "podID"
tmpFile := filepath.Join(tempdir, "podID")

n := podmanTest.Podman([]string{"pod", "create", "--pod-id-file", tmpFile, "--name", "foo"})
n.WaitWithDefaultTimeout()
Expand Down
22 changes: 10 additions & 12 deletions test/e2e/kill_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration

import (
"path/filepath"

. "github.com/containers/podman/v5/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -126,15 +128,14 @@ var _ = Describe("Podman kill", func() {
})

It("podman kill --cidfile", func() {
tmpDir := GinkgoT().TempDir()
tmpFile := tmpDir + "cid"
cidFile := filepath.Join(tempdir, "cid")

session := podmanTest.Podman([]string{"run", "-dt", "--cidfile", tmpFile, ALPINE, "top"})
session := podmanTest.Podman([]string{"run", "-dt", "--cidfile", cidFile, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
cid := session.OutputToStringArray()[0]

kill := podmanTest.Podman([]string{"kill", "--cidfile", tmpFile})
kill := podmanTest.Podman([]string{"kill", "--cidfile", cidFile})
kill.WaitWithDefaultTimeout()
Expect(kill).Should(ExitCleanly())

Expand All @@ -144,23 +145,20 @@ var _ = Describe("Podman kill", func() {
})

It("podman kill multiple --cidfile", func() {
tmpDir1 := GinkgoT().TempDir()
tmpFile1 := tmpDir1 + "cid"

tmpDir2 := GinkgoT().TempDir()
tmpFile2 := tmpDir2 + "cid"
cidFile1 := filepath.Join(tempdir, "cid1")
cidFile2 := filepath.Join(tempdir, "cid2")

session := podmanTest.Podman([]string{"run", "-dt", "--cidfile", tmpFile1, ALPINE, "top"})
session := podmanTest.Podman([]string{"run", "-dt", "--cidfile", cidFile1, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
cid1 := session.OutputToStringArray()[0]

session2 := podmanTest.Podman([]string{"run", "-dt", "--cidfile", tmpFile2, ALPINE, "top"})
session2 := podmanTest.Podman([]string{"run", "-dt", "--cidfile", cidFile2, ALPINE, "top"})
session2.WaitWithDefaultTimeout()
Expect(session2).Should(ExitCleanly())
cid2 := session2.OutputToStringArray()[0]

kill := podmanTest.Podman([]string{"kill", "--cidfile", tmpFile1, "--cidfile", tmpFile2})
kill := podmanTest.Podman([]string{"kill", "--cidfile", cidFile1, "--cidfile", cidFile2})
kill.WaitWithDefaultTimeout()
Expect(kill).Should(ExitCleanly())

Expand Down
24 changes: 10 additions & 14 deletions test/e2e/pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,9 @@ var _ = Describe("Podman pause", func() {
})

It("podman pause --cidfile", func() {
tmpDir := GinkgoT().TempDir()
tmpFile := tmpDir + "cid"
cidFile := filepath.Join(tempdir, "cid")

session := podmanTest.Podman([]string{"create", "--cidfile", tmpFile, ALPINE, "top"})
session := podmanTest.Podman([]string{"create", "--cidfile", cidFile, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
cid := session.OutputToStringArray()[0]
Expand All @@ -333,47 +332,44 @@ var _ = Describe("Podman pause", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

result := podmanTest.Podman([]string{"pause", "--cidfile", tmpFile})
result := podmanTest.Podman([]string{"pause", "--cidfile", cidFile})
result.WaitWithDefaultTimeout()
Expect(result).Should(ExitCleanly())
output := result.OutputToString()
Expect(output).To(ContainSubstring(cid))

result = podmanTest.Podman([]string{"unpause", "--cidfile", tmpFile})
result = podmanTest.Podman([]string{"unpause", "--cidfile", cidFile})
result.WaitWithDefaultTimeout()
Expect(result).Should(ExitCleanly())
output = result.OutputToString()
Expect(output).To(ContainSubstring(cid))
})

It("podman pause multiple --cidfile", func() {
tmpDir := GinkgoT().TempDir()
tmpFile1 := tmpDir + "cid-1"
tmpFile2 := tmpDir + "cid-2"
cidFile1 := filepath.Join(tempdir, "cid-1")
cidFile2 := filepath.Join(tempdir, "cid-2")

defer os.RemoveAll(tmpDir)

session := podmanTest.Podman([]string{"run", "--cidfile", tmpFile1, "-d", ALPINE, "top"})
session := podmanTest.Podman([]string{"run", "--cidfile", cidFile1, "-d", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
cid1 := session.OutputToStringArray()[0]
Expect(podmanTest.NumberOfContainers()).To(Equal(1))

session = podmanTest.Podman([]string{"run", "--cidfile", tmpFile2, "-d", ALPINE, "top"})
session = podmanTest.Podman([]string{"run", "--cidfile", cidFile2, "-d", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
cid2 := session.OutputToStringArray()[0]
Expect(podmanTest.NumberOfContainers()).To(Equal(2))

result := podmanTest.Podman([]string{"pause", "--cidfile", tmpFile1, "--cidfile", tmpFile2})
result := podmanTest.Podman([]string{"pause", "--cidfile", cidFile1, "--cidfile", cidFile2})
result.WaitWithDefaultTimeout()
Expect(result).Should(ExitCleanly())
output := result.OutputToString()
Expect(output).To(ContainSubstring(cid1))
Expect(output).To(ContainSubstring(cid2))
Expect(podmanTest.NumberOfContainers()).To(Equal(2))

result = podmanTest.Podman([]string{"unpause", "--cidfile", tmpFile1, "--cidfile", tmpFile2})
result = podmanTest.Podman([]string{"unpause", "--cidfile", cidFile1, "--cidfile", cidFile2})
result.WaitWithDefaultTimeout()
Expect(result).Should(ExitCleanly())
output = result.OutputToString()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/play_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3624,7 +3624,7 @@ VOLUME %s`, CITEST_IMAGE, hostPathDir+"/")
kube.WaitWithDefaultTimeout()
Expect(kube).Should(ExitCleanly())

result := podmanTest.Podman([]string{"exec", getCtrNameInPod(pod), "ls", hostPathDir + "/" + testfile})
result := podmanTest.Podman([]string{"exec", getCtrNameInPod(pod), "ls", filepath.Join(hostPathDir, testfile)})
result.WaitWithDefaultTimeout()
Expect(result).Should(ExitCleanly())

Expand Down
17 changes: 7 additions & 10 deletions test/e2e/pod_rm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,12 @@ var _ = Describe("Podman pod rm", func() {
})

It("podman pod start/remove single pod via --pod-id-file", func() {
tmpDir := GinkgoT().TempDir()
tmpFile := tmpDir + "podID"
podIDFile := filepath.Join(tempdir, "podID")

podName := "rudolph"

// Create a pod with --pod-id-file.
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile})
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", podIDFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

Expand All @@ -230,26 +229,24 @@ var _ = Describe("Podman pod rm", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", tmpFile})
session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", podIDFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) // infra+top

session = podmanTest.Podman([]string{"pod", "rm", "-t", "0", "--pod-id-file", tmpFile, "--force"})
session = podmanTest.Podman([]string{"pod", "rm", "-t", "0", "--pod-id-file", podIDFile, "--force"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
})

It("podman pod start/remove multiple pods via --pod-id-file", func() {
tmpDir := GinkgoT().TempDir()

podIDFiles := []string{}
for _, i := range "0123456789" {
tmpFile := tmpDir + "cid" + string(i)
cidFile := filepath.Join(tempdir, "cid"+string(i))
podName := "rudolph" + string(i)
// Create a pod with --pod-id-file.
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile})
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", cidFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

Expand All @@ -260,7 +257,7 @@ var _ = Describe("Podman pod rm", func() {

// Append the id files along with the command.
podIDFiles = append(podIDFiles, "--pod-id-file")
podIDFiles = append(podIDFiles, tmpFile)
podIDFiles = append(podIDFiles, cidFile)
}

cmd := []string{"pod", "start"}
Expand Down
23 changes: 10 additions & 13 deletions test/e2e/pod_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integration
import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"

Expand Down Expand Up @@ -153,13 +154,12 @@ var _ = Describe("Podman pod start", func() {
})

It("podman pod start single pod via --pod-id-file", func() {
tmpDir := GinkgoT().TempDir()
tmpFile := tmpDir + "podID"
podIDFile := filepath.Join(tempdir, "podID")

podName := "rudolph"

// Create a pod with --pod-id-file.
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile})
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", podIDFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

Expand All @@ -168,21 +168,19 @@ var _ = Describe("Podman pod start", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", tmpFile})
session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", podIDFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) // infra+top
})

It("podman pod start multiple pods via --pod-id-file", func() {
tmpDir := GinkgoT().TempDir()

podIDFiles := []string{}
for _, i := range "0123456789" {
tmpFile := tmpDir + "cid" + string(i)
cidFile := filepath.Join(tempdir, "cid"+string(i))
podName := "rudolph" + string(i)
// Create a pod with --pod-id-file.
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile})
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", cidFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

Expand All @@ -193,7 +191,7 @@ var _ = Describe("Podman pod start", func() {

// Append the id files along with the command.
podIDFiles = append(podIDFiles, "--pod-id-file")
podIDFiles = append(podIDFiles, tmpFile)
podIDFiles = append(podIDFiles, cidFile)
}

cmd := []string{"pod", "start"}
Expand All @@ -205,12 +203,11 @@ var _ = Describe("Podman pod start", func() {
})

It("podman pod create --infra-conmon-pod create + start", func() {
tmpDir := GinkgoT().TempDir()
tmpFile := tmpDir + "podID"
pidFile := filepath.Join(tempdir, "podID")

podName := "rudolph"
// Create a pod with --infra-conmon-pid.
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--infra-conmon-pidfile", tmpFile})
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--infra-conmon-pidfile", pidFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

Expand All @@ -227,7 +224,7 @@ var _ = Describe("Podman pod start", func() {

// Read the infra-conmon-pidfile and perform some sanity checks
// on the pid.
infraConmonPID := readFirstLine(tmpFile)
infraConmonPID := readFirstLine(pidFile)
_, err = strconv.Atoi(infraConmonPID) // Make sure it's a proper integer
Expect(err).ToNot(HaveOccurred())

Expand Down
19 changes: 9 additions & 10 deletions test/e2e/pod_stop_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration

import (
"path/filepath"

. "github.com/containers/podman/v5/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -157,13 +159,12 @@ var _ = Describe("Podman pod stop", func() {
})

It("podman pod start/stop single pod via --pod-id-file", func() {
tmpDir := GinkgoT().TempDir()
tmpFile := tmpDir + "podID"
podIDFile := filepath.Join(tempdir, "podID")

podName := "rudolph"

// Create a pod with --pod-id-file.
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile})
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", podIDFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

Expand All @@ -172,26 +173,24 @@ var _ = Describe("Podman pod stop", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", tmpFile})
session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", podIDFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) // infra+top

session = podmanTest.Podman([]string{"pod", "stop", "--pod-id-file", tmpFile})
session = podmanTest.Podman([]string{"pod", "stop", "--pod-id-file", podIDFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
})

It("podman pod start/stop multiple pods via --pod-id-file", func() {
tmpDir := GinkgoT().TempDir()

podIDFiles := []string{}
for _, i := range "0123456789" {
tmpFile := tmpDir + "cid" + string(i)
podIDFile := filepath.Join(tempdir, "cid"+string(i))
podName := "rudolph" + string(i)
// Create a pod with --pod-id-file.
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile})
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", podIDFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

Expand All @@ -202,7 +201,7 @@ var _ = Describe("Podman pod stop", func() {

// Append the id files along with the command.
podIDFiles = append(podIDFiles, "--pod-id-file")
podIDFiles = append(podIDFiles, tmpFile)
podIDFiles = append(podIDFiles, podIDFile)
}

cmd := []string{"pod", "start"}
Expand Down
Loading

1 comment on commit 318437f

@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.