aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKarthik Elango <kelango@redhat.com>2022-06-28 15:31:20 -0400
committerKarthik Elango <kelango@redhat.com>2022-07-14 13:18:53 -0400
commita2f6cc74e72edf0b7045c8410ed3f45489999e2b (patch)
tree7424569f997630623d4290ace20ccf63cf743897 /test
parent3637d55191be2e9a5b9e13f8f62db4c27d188741 (diff)
downloadpodman-a2f6cc74e72edf0b7045c8410ed3f45489999e2b.tar.gz
podman-a2f6cc74e72edf0b7045c8410ed3f45489999e2b.tar.bz2
podman-a2f6cc74e72edf0b7045c8410ed3f45489999e2b.zip
Podman stop --filter flag
Filter flag is added for podman stop and podman --remote stop. Filtering logic is implemented in getContainersAndInputByContext(). Start filtering can be manipulated to use this logic as well to limit redundancy. Signed-off-by: Karthik Elango <kelango@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/stop_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go
index 97d8ba701..7a258466a 100644
--- a/test/e2e/stop_test.go
+++ b/test/e2e/stop_test.go
@@ -1,6 +1,7 @@
package integration
import (
+ "fmt"
"io/ioutil"
"os"
"strings"
@@ -363,4 +364,45 @@ var _ = Describe("Podman stop", func() {
Expect(session).Should(Exit(0))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
})
+
+ It("podman stop --filter", func() {
+ session1 := podmanTest.Podman([]string{"container", "create", ALPINE})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1).Should(Exit(0))
+ cid1 := session1.OutputToString()
+
+ session1 = podmanTest.Podman([]string{"container", "create", ALPINE})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1).Should(Exit(0))
+ cid2 := session1.OutputToString()
+
+ session1 = podmanTest.Podman([]string{"container", "create", ALPINE})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1).Should(Exit(0))
+ cid3 := session1.OutputToString()
+ shortCid3 := cid3[0:5]
+
+ session1 = podmanTest.Podman([]string{"start", "--all"})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1).Should(Exit(0))
+
+ session1 = podmanTest.Podman([]string{"stop", cid1, "-f", "status=running"})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1).Should(Exit(125))
+
+ session1 = podmanTest.Podman([]string{"stop", "-a", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1).Should(Exit(0))
+ Expect(session1.OutputToString()).To(HaveLen(0))
+
+ session1 = podmanTest.Podman([]string{"stop", "-a", "--filter", fmt.Sprintf("id=%s", shortCid3)})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1).Should(Exit(0))
+ Expect(session1.OutputToString()).To(BeEquivalentTo(cid3))
+
+ session1 = podmanTest.Podman([]string{"stop", "-f", fmt.Sprintf("id=%s", cid2)})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1).Should(Exit(0))
+ Expect(session1.OutputToString()).To(BeEquivalentTo(cid2))
+ })
})