mirror of
https://github.com/containers/podman.git
synced 2025-05-20 08:36:23 +08:00
Merge pull request #21671 from mheon/e2e_stop_helper
Add a helper for stopping pods and containers in E2E
This commit is contained in:
@ -142,16 +142,7 @@ var _ = Describe("Podman checkpoint", func() {
|
||||
Expect(inspectOut[0].State.CheckpointLog).To(ContainSubstring("userdata/dump.log"))
|
||||
Expect(inspectOut[0].State.RestoreLog).To(ContainSubstring("userdata/restore.log"))
|
||||
|
||||
result = podmanTest.Podman([]string{
|
||||
"container",
|
||||
"stop",
|
||||
"--timeout",
|
||||
"0",
|
||||
cid,
|
||||
})
|
||||
result.WaitWithDefaultTimeout()
|
||||
|
||||
Expect(result).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(cid)
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||
|
||||
result = podmanTest.Podman([]string{
|
||||
@ -416,10 +407,7 @@ var _ = Describe("Podman checkpoint", func() {
|
||||
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
|
||||
|
||||
// Stop the container
|
||||
result = podmanTest.Podman([]string{"container", "stop", cid})
|
||||
result.WaitWithDefaultTimeout()
|
||||
|
||||
Expect(result).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(cid)
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
|
||||
|
||||
|
@ -454,6 +454,19 @@ func (p *PodmanTestIntegration) InspectContainer(name string) []define.InspectCo
|
||||
return session.InspectContainerToJSON()
|
||||
}
|
||||
|
||||
// StopContainer stops a container with no timeout, ensuring a fast test.
|
||||
func (p *PodmanTestIntegration) StopContainer(nameOrID string) {
|
||||
stop := p.Podman([]string{"stop", "-t0", nameOrID})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
}
|
||||
|
||||
func (p *PodmanTestIntegration) StopPod(nameOrID string) {
|
||||
stop := p.Podman([]string{"pod", "stop", "-t0", nameOrID})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
}
|
||||
|
||||
func processTestResult(r SpecReport) {
|
||||
tr := testResult{length: r.RunTime.Seconds(), name: r.FullText()}
|
||||
_, err := timingsFile.WriteString(fmt.Sprintf("%s\t\t%f\n", tr.name, tr.length))
|
||||
|
@ -87,10 +87,10 @@ var _ = Describe("Podman events", func() {
|
||||
It("podman events with a type", func() {
|
||||
setup := podmanTest.Podman([]string{"run", "-dt", "--pod", "new:foobarpod", ALPINE, "top"})
|
||||
setup.WaitWithDefaultTimeout()
|
||||
stop := podmanTest.Podman([]string{"pod", "stop", "-t0", "foobarpod"})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
Expect(setup).Should(ExitCleanly())
|
||||
|
||||
podmanTest.StopPod("foobarpod")
|
||||
|
||||
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "type=pod", "--filter", "pod=foobarpod"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(ExitCleanly())
|
||||
|
@ -524,9 +524,7 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
|
||||
|
||||
// Ensure that stop with a running detached exec session is
|
||||
// clean.
|
||||
stop := podmanTest.Podman([]string{"stop", ctrName})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(ctrName)
|
||||
})
|
||||
|
||||
It("podman exec with env var secret", func() {
|
||||
|
@ -282,9 +282,7 @@ var _ = Describe("Podman healthcheck run", func() {
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
stop := podmanTest.Podman([]string{"stop", "-t0", "hc"})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer("hc")
|
||||
|
||||
startAgain := podmanTest.Podman([]string{"start", "hc"})
|
||||
startAgain.WaitWithDefaultTimeout()
|
||||
|
@ -179,9 +179,7 @@ var _ = Describe("Podman mount", func() {
|
||||
Expect(lmount).Should(ExitCleanly())
|
||||
Expect(lmount.OutputToString()).To(ContainSubstring(cid))
|
||||
|
||||
stop := podmanTest.Podman([]string{"stop", cid})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(cid)
|
||||
|
||||
lmount = podmanTest.Podman([]string{"mount", "--no-trunc"})
|
||||
lmount.WaitWithDefaultTimeout()
|
||||
|
@ -94,9 +94,7 @@ var _ = Describe("Podman init containers", func() {
|
||||
// Expect(check).Should(Exit(1))
|
||||
Expect(check.ExitCode()).To(Equal(1), "I dont understand why the other way does not work")
|
||||
// Let's double check with a stop and start
|
||||
stopPod := podmanTest.Podman([]string{"pod", "stop", "foobar"})
|
||||
stopPod.WaitWithDefaultTimeout()
|
||||
Expect(stopPod).Should(ExitCleanly())
|
||||
podmanTest.StopPod("foobar")
|
||||
startPod := podmanTest.Podman([]string{"pod", "start", "foobar"})
|
||||
startPod.WaitWithDefaultTimeout()
|
||||
Expect(startPod).Should(ExitCleanly())
|
||||
@ -129,9 +127,7 @@ var _ = Describe("Podman init containers", func() {
|
||||
Expect(checkLog).Should(ExitCleanly())
|
||||
|
||||
// Stop and start the pod
|
||||
stopPod := podmanTest.Podman([]string{"pod", "stop", "foobar"})
|
||||
stopPod.WaitWithDefaultTimeout()
|
||||
Expect(stopPod).Should(ExitCleanly())
|
||||
podmanTest.StopPod("foobar")
|
||||
startPod := podmanTest.Podman([]string{"pod", "start", "foobar"})
|
||||
startPod.WaitWithDefaultTimeout()
|
||||
Expect(startPod).Should(ExitCleanly())
|
||||
|
@ -34,9 +34,7 @@ var _ = Describe("Podman prune", func() {
|
||||
Expect(top).Should(ExitCleanly())
|
||||
cid := top.OutputToString()
|
||||
|
||||
stop := podmanTest.Podman([]string{"stop", cid})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(cid)
|
||||
|
||||
prune := podmanTest.Podman([]string{"container", "prune", "-f"})
|
||||
prune.WaitWithDefaultTimeout()
|
||||
@ -220,9 +218,7 @@ var _ = Describe("Podman prune", func() {
|
||||
session = podmanTest.Podman([]string{"pod", "start", podid1})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
session = podmanTest.Podman([]string{"pod", "stop", "-t0", podid1})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
podmanTest.StopPod(podid1)
|
||||
|
||||
pods := podmanTest.Podman([]string{"pod", "ps"})
|
||||
pods.WaitWithDefaultTimeout()
|
||||
@ -293,9 +289,7 @@ var _ = Describe("Podman prune", func() {
|
||||
session = podmanTest.Podman([]string{"pod", "start", podid1})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
session = podmanTest.Podman([]string{"pod", "stop", "-t0", podid1})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
podmanTest.StopPod(podid1)
|
||||
|
||||
// Create a container. This container should be pruned.
|
||||
create := podmanTest.Podman([]string{"create", "--name", "test", BB})
|
||||
@ -325,9 +319,7 @@ var _ = Describe("Podman prune", func() {
|
||||
session = podmanTest.Podman([]string{"pod", "start", podid1})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
session = podmanTest.Podman([]string{"pod", "stop", "-t0", podid1})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
podmanTest.StopPod(podid1)
|
||||
|
||||
// Start a pod and leave it running
|
||||
session = podmanTest.Podman([]string{"pod", "create"})
|
||||
@ -403,10 +395,7 @@ var _ = Describe("Podman prune", func() {
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
session = podmanTest.Podman([]string{"pod", "stop", podid1})
|
||||
session.WaitWithDefaultTimeout()
|
||||
// FIXME - #20196: Cannot use ExitCleanly()
|
||||
Expect(session).Should(Exit(0))
|
||||
podmanTest.StopPod(podid1)
|
||||
|
||||
// Create a container. This container should be pruned.
|
||||
create := podmanTest.Podman([]string{"create", "--name", "test", BB})
|
||||
|
@ -222,9 +222,7 @@ var _ = Describe("Podman restart", func() {
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2))
|
||||
|
||||
session = podmanTest.Podman([]string{"stop", "--all"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
podmanTest.StopContainer("--all")
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||
|
||||
session = podmanTest.Podman([]string{"restart", "--all"})
|
||||
|
@ -26,9 +26,7 @@ var _ = Describe("Podman run exit", func() {
|
||||
Expect(pmount).Should(ExitCleanly())
|
||||
Expect(pmount.OutputToString()).To(ContainSubstring(cid))
|
||||
|
||||
stop := podmanTest.Podman([]string{"stop", cid})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(cid)
|
||||
|
||||
// We have to force cleanup so the unmount happens
|
||||
podmanCleanupSession := podmanTest.Podman([]string{"container", "cleanup", cid})
|
||||
@ -69,9 +67,7 @@ var _ = Describe("Podman run exit", func() {
|
||||
Expect(pmount).Should(ExitCleanly())
|
||||
Expect(pmount.OutputToString()).To(ContainSubstring(cid))
|
||||
|
||||
stop := podmanTest.Podman([]string{"stop", cid})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(cid)
|
||||
|
||||
// We have to force cleanup so the unmount happens
|
||||
podmanCleanupSession := podmanTest.Podman([]string{"container", "cleanup", cid})
|
||||
|
@ -302,9 +302,7 @@ var _ = Describe("Podman run", func() {
|
||||
Expect(osession).Should(ExitCleanly())
|
||||
Expect(osession.OutputToString()).To(Equal("hello"))
|
||||
|
||||
osession = podmanTest.Podman([]string{"stop", "overlay-foo"})
|
||||
osession.WaitWithDefaultTimeout()
|
||||
Expect(osession).Should(ExitCleanly())
|
||||
podmanTest.StopContainer("overlay-foo")
|
||||
|
||||
startsession := podmanTest.Podman([]string{"start", "--attach", "overlay-foo"})
|
||||
startsession.WaitWithDefaultTimeout()
|
||||
@ -1541,9 +1539,7 @@ VOLUME %s`, ALPINE, volPath, volPath)
|
||||
ctr.WaitWithDefaultTimeout()
|
||||
Expect(ctr).Should(ExitCleanly())
|
||||
|
||||
stop := podmanTest.Podman([]string{"stop", "-t0", ctrName})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(ctrName)
|
||||
|
||||
// This is ugly, but I don't see a better way
|
||||
time.Sleep(10 * time.Second)
|
||||
@ -2093,9 +2089,7 @@ WORKDIR /madethis`, BB)
|
||||
mainContainer.WaitWithDefaultTimeout()
|
||||
Expect(mainContainer).Should(ExitCleanly())
|
||||
|
||||
stop := podmanTest.Podman([]string{"stop", "--all"})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer("--all")
|
||||
|
||||
start := podmanTest.Podman([]string{"start", mainName})
|
||||
start.WaitWithDefaultTimeout()
|
||||
|
@ -386,9 +386,7 @@ var _ = Describe("Podman run with volumes", func() {
|
||||
Expect(mountOut2).To(ContainSubstring(volName))
|
||||
|
||||
// Stop the container to unmount
|
||||
podmanStopSession := podmanTest.Podman([]string{"stop", "--time", "0", ctrName})
|
||||
podmanStopSession.WaitWithDefaultTimeout()
|
||||
Expect(podmanStopSession).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(ctrName)
|
||||
|
||||
// We have to force cleanup so the unmount happens
|
||||
podmanCleanupSession := podmanTest.Podman([]string{"container", "cleanup", ctrName})
|
||||
@ -675,9 +673,7 @@ VOLUME /test/`, ALPINE)
|
||||
session = podmanTest.Podman([]string{"exec", "-l", "ls", "/run/test/container"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
session = podmanTest.Podman([]string{"stop", "-l"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
podmanTest.StopContainer("-l")
|
||||
session = podmanTest.Podman([]string{"start", "-l"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
@ -140,9 +140,7 @@ var _ = Describe("Podman volume plugins", func() {
|
||||
Expect(arrOutput).To(HaveLen(1))
|
||||
Expect(arrOutput[0]).To(ContainSubstring(volName))
|
||||
|
||||
stop := podmanTest.Podman([]string{"stop", "--timeout", "0", ctrName})
|
||||
stop.WaitWithDefaultTimeout()
|
||||
Expect(stop).Should(ExitCleanly())
|
||||
podmanTest.StopContainer(ctrName)
|
||||
|
||||
// Remove should exit non-zero because missing plugin
|
||||
remove := podmanTest.Podman([]string{"volume", "rm", volName})
|
||||
|
Reference in New Issue
Block a user