summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-01-09 15:54:07 +0100
committerPaul Holzinger <paul.holzinger@web.de>2021-01-09 17:03:32 +0100
commit1242e7b7a612b1dcae0e09a7fd10e266d34cf9e2 (patch)
treee50592f434cfbae3935ea8973fdc6e1b76f6b94e /test
parent49db79e735acd2c693762eaff62680cd9a8cb60b (diff)
downloadpodman-1242e7b7a612b1dcae0e09a7fd10e266d34cf9e2.tar.gz
podman-1242e7b7a612b1dcae0e09a7fd10e266d34cf9e2.tar.bz2
podman-1242e7b7a612b1dcae0e09a7fd10e266d34cf9e2.zip
Add network filter for podman ps and pod ps
Allow to filter on the network name or full id. For pod ps it will filter on the infra container networks. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/pod_ps_test.go25
-rw-r--r--test/e2e/ps_test.go25
2 files changed, 50 insertions, 0 deletions
diff --git a/test/e2e/pod_ps_test.go b/test/e2e/pod_ps_test.go
index 225da785c..6a740ed09 100644
--- a/test/e2e/pod_ps_test.go
+++ b/test/e2e/pod_ps_test.go
@@ -6,6 +6,7 @@ import (
"sort"
. "github.com/containers/podman/v2/test/utils"
+ "github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
@@ -280,6 +281,30 @@ var _ = Describe("Podman ps", func() {
Expect(session.OutputToString()).To(Not(ContainSubstring(podid3)))
})
+ It("podman pod ps filter network", func() {
+ net := stringid.GenerateNonCryptoID()
+ session := podmanTest.Podman([]string{"network", "create", net})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ defer podmanTest.removeCNINetwork(net)
+
+ session = podmanTest.Podman([]string{"pod", "create", "--network", net})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ podWithNet := session.OutputToString()
+
+ session = podmanTest.Podman([]string{"pod", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ podWithoutNet := session.OutputToString()
+
+ session = podmanTest.Podman([]string{"pod", "ps", "--no-trunc", "--filter", "network=" + net})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ Expect(session.OutputToString()).To(ContainSubstring(podWithNet))
+ Expect(session.OutputToString()).To(Not(ContainSubstring(podWithoutNet)))
+ })
+
It("pod no infra should ps", func() {
session := podmanTest.Podman([]string{"pod", "create", "--infra=false"})
session.WaitWithDefaultTimeout()
diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go
index 0c5d817ba..0d2bed485 100644
--- a/test/e2e/ps_test.go
+++ b/test/e2e/ps_test.go
@@ -8,6 +8,7 @@ import (
"strings"
. "github.com/containers/podman/v2/test/utils"
+ "github.com/containers/storage/pkg/stringid"
"github.com/docker/go-units"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -724,4 +725,28 @@ var _ = Describe("Podman ps", func() {
})
+ It("podman ps filter network", func() {
+ net := stringid.GenerateNonCryptoID()
+ session := podmanTest.Podman([]string{"network", "create", net})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ defer podmanTest.removeCNINetwork(net)
+
+ session = podmanTest.Podman([]string{"create", "--network", net, ALPINE})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ ctrWithNet := session.OutputToString()
+
+ session = podmanTest.Podman([]string{"create", ALPINE})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ ctrWithoutNet := session.OutputToString()
+
+ session = podmanTest.Podman([]string{"ps", "--all", "--no-trunc", "--filter", "network=" + net})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ Expect(session.OutputToString()).To(ContainSubstring(ctrWithNet))
+ Expect(session.OutputToString()).To(Not(ContainSubstring(ctrWithoutNet)))
+ })
+
})