mirror of
https://github.com/containers/podman.git
synced 2025-06-19 16:33:24 +08:00
podman rm/stop --cidfile
Add a --cidfile flag to podman rm/stop to pass a container ID via a file. Podman run already provides the functionaly to store the ID in a specified file which we now complete with rm/stop. This allows for a better life-cycle management in systemd services. Note that --cdifile can be specified multiple times to rm/stop. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
. "github.com/containers/libpod/test/utils"
|
||||
@ -138,11 +139,86 @@ var _ = Describe("Podman rm", func() {
|
||||
|
||||
})
|
||||
|
||||
It("podman rm --cidfile", func() {
|
||||
SkipIfRemote()
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "")
|
||||
Expect(err).To(BeNil())
|
||||
tmpFile := tmpDir + "cid"
|
||||
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
session := podmanTest.Podman([]string{"create", "--cidfile", tmpFile, ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
cid := session.OutputToStringArray()[0]
|
||||
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||
|
||||
result := podmanTest.Podman([]string{"rm", "--cidfile", tmpFile})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
output := result.OutputToString()
|
||||
Expect(output).To(ContainSubstring(cid))
|
||||
Expect(podmanTest.NumberOfContainers()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman rm multiple --cidfile", func() {
|
||||
SkipIfRemote()
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "")
|
||||
Expect(err).To(BeNil())
|
||||
tmpFile1 := tmpDir + "cid-1"
|
||||
tmpFile2 := tmpDir + "cid-2"
|
||||
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
session := podmanTest.Podman([]string{"create", "--cidfile", tmpFile1, ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
cid1 := session.OutputToStringArray()[0]
|
||||
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||
|
||||
session = podmanTest.Podman([]string{"create", "--cidfile", tmpFile2, ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
cid2 := session.OutputToStringArray()[0]
|
||||
Expect(podmanTest.NumberOfContainers()).To(Equal(2))
|
||||
|
||||
result := podmanTest.Podman([]string{"rm", "--cidfile", tmpFile1, "--cidfile", tmpFile2})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
output := result.OutputToString()
|
||||
Expect(output).To(ContainSubstring(cid1))
|
||||
Expect(output).To(ContainSubstring(cid2))
|
||||
Expect(podmanTest.NumberOfContainers()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman rm invalid --latest and --cidfile and --all", func() {
|
||||
SkipIfRemote()
|
||||
|
||||
result := podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--latest"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(125))
|
||||
|
||||
result = podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--all"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(125))
|
||||
|
||||
result = podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--all", "--latest"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(125))
|
||||
|
||||
result = podmanTest.Podman([]string{"rm", "--latest", "--all"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(125))
|
||||
})
|
||||
|
||||
It("podman rm bogus container", func() {
|
||||
session := podmanTest.Podman([]string{"rm", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(1))
|
||||
})
|
||||
|
||||
It("podman rm bogus container and a running container", func() {
|
||||
session := podmanTest.RunTopContainer("test1")
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
Reference in New Issue
Block a user