mirror of
https://github.com/containers/podman.git
synced 2025-09-19 12:56:57 +08:00

There is no reason to define the same code every time in each file, just use global nodes. This diff should speak for itself. CleanupSecrets()/Volume() no longer call Cleanup() directly, as the global AfterEach node will always call Cleanup() this is no longer necessary. If one AfterEach() node fails it will still run the others. Also always unset the CONTAINERS_CONF env vars. This prevents people from forgetting to unset it. And fix the special CONTAINERS_CONF logic in the system connection tests, we do not want to preserve CONTAINERS_CONF anyway so just remove this logic. Ginkgo orders the BeforeEach and AfterEach nodes. They will be executed from the outer-most defined to inner-most. This means our global BeforeEach is always first. Only then the inner one (in the Describe() function in each file). For AfterEach it is inverted, from the inner to the outer. Also see https://onsi.github.io/ginkgo/#organizing-specs-with-container-nodes Signed-off-by: Paul Holzinger <pholzing@redhat.com>
132 lines
4.0 KiB
Go
132 lines
4.0 KiB
Go
package integration
|
|
|
|
import (
|
|
. "github.com/containers/podman/v4/test/utils"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
. "github.com/onsi/gomega/gexec"
|
|
)
|
|
|
|
var _ = Describe("Podman pod kill", func() {
|
|
|
|
It("podman pod kill bogus", func() {
|
|
session := podmanTest.Podman([]string{"pod", "kill", "foobar"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).To(ExitWithError())
|
|
})
|
|
|
|
It("podman pod kill a pod by id", func() {
|
|
_, ec, podid := podmanTest.CreatePod(nil)
|
|
Expect(ec).To(Equal(0))
|
|
|
|
session := podmanTest.RunTopContainerInPod("", podid)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
session = podmanTest.RunTopContainerInPod("", podid)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
result := podmanTest.Podman([]string{"pod", "kill", podid})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(0))
|
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pod kill a pod by id with TERM", func() {
|
|
_, ec, podid := podmanTest.CreatePod(nil)
|
|
Expect(ec).To(Equal(0))
|
|
|
|
session := podmanTest.RunTopContainerInPod("", podid)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
result := podmanTest.Podman([]string{"pod", "kill", "-s", "9", podid})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(0))
|
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pod kill a pod by name", func() {
|
|
_, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {"test1"}})
|
|
Expect(ec).To(Equal(0))
|
|
|
|
session := podmanTest.RunTopContainerInPod("", podid)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
result := podmanTest.Podman([]string{"pod", "kill", "test1"})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(0))
|
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pod kill a pod by id with a bogus signal", func() {
|
|
_, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {"test1"}})
|
|
Expect(ec).To(Equal(0))
|
|
|
|
session := podmanTest.RunTopContainerInPod("", podid)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
result := podmanTest.Podman([]string{"pod", "kill", "-s", "bogus", "test1"})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(125))
|
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
|
})
|
|
|
|
It("podman pod kill latest pod", func() {
|
|
_, ec, podid := podmanTest.CreatePod(nil)
|
|
Expect(ec).To(Equal(0))
|
|
|
|
session := podmanTest.RunTopContainerInPod("", podid)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
_, ec, podid2 := podmanTest.CreatePod(nil)
|
|
Expect(ec).To(Equal(0))
|
|
|
|
session = podmanTest.RunTopContainerInPod("", podid2)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
session = podmanTest.RunTopContainerInPod("", podid2)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
if !IsRemote() {
|
|
podid2 = "-l"
|
|
}
|
|
result := podmanTest.Podman([]string{"pod", "kill", podid2})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(0))
|
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
|
})
|
|
|
|
It("podman pod kill all", func() {
|
|
SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1")
|
|
_, ec, podid := podmanTest.CreatePod(nil)
|
|
Expect(ec).To(Equal(0))
|
|
|
|
session := podmanTest.RunTopContainerInPod("", podid)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
session = podmanTest.RunTopContainerInPod("", podid)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
_, ec, podid2 := podmanTest.CreatePod(nil)
|
|
Expect(ec).To(Equal(0))
|
|
|
|
session = podmanTest.RunTopContainerInPod("", podid2)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
|
|
result := podmanTest.Podman([]string{"pod", "kill", "-a"})
|
|
result.WaitWithDefaultTimeout()
|
|
GinkgoWriter.Println(result.OutputToString(), result.ErrorToString())
|
|
Expect(result).Should(Exit(0))
|
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
|
})
|
|
})
|