summaryrefslogtreecommitdiff
path: root/test/e2e/stats_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e/stats_test.go')
-rw-r--r--test/e2e/stats_test.go49
1 files changed, 25 insertions, 24 deletions
diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go
index 7ab3dabc9..e32d515a0 100644
--- a/test/e2e/stats_test.go
+++ b/test/e2e/stats_test.go
@@ -11,6 +11,7 @@ import (
. "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gexec"
)
// TODO: we need to check the output. Currently, we only check the exit codes
@@ -43,62 +44,62 @@ var _ = Describe("Podman stats", func() {
It("podman stats with bogus container", func() {
session := podmanTest.Podman([]string{"stats", "--no-stream", "123"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(125))
+ Expect(session).Should(Exit(125))
})
It("podman stats on a running container", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
cid := session.OutputToString()
session = podmanTest.Podman([]string{"stats", "--no-stream", cid})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
})
It("podman stats on all containers", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"stats", "--no-stream", "-a"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
})
It("podman stats on all running containers", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"stats", "--no-stream"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
})
It("podman stats only output cids", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "\"{{.ID}}\""})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
})
It("podman stats only output CPU data", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "\"{{.ID}} {{.UpTime}} {{.AVGCPU}}\""})
session.WaitWithDefaultTimeout()
Expect(session.LineInOutputContains("UpTime")).To(BeTrue())
Expect(session.LineInOutputContains("AVGCPU")).To(BeTrue())
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
})
It("podman stats with json output", func() {
var found bool
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
for i := 0; i < 5; i++ {
ps := podmanTest.Podman([]string{"ps", "-q"})
ps.WaitWithDefaultTimeout()
@@ -111,42 +112,42 @@ var _ = Describe("Podman stats", func() {
Expect(found).To(BeTrue())
stats := podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "json"})
stats.WaitWithDefaultTimeout()
- Expect(stats.ExitCode()).To(Equal(0))
+ Expect(stats).Should(Exit(0))
Expect(stats.IsJSONOutputValid()).To(BeTrue())
})
It("podman stats on a container with no net ns", func() {
session := podmanTest.Podman([]string{"run", "-d", "--net", "none", ALPINE, "top"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"stats", "--no-stream", "-a"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
})
It("podman stats on a container that joined another's net ns", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
cid := session.OutputToString()
session = podmanTest.Podman([]string{"run", "-d", "--net", fmt.Sprintf("container:%s", cid), ALPINE, "top"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"stats", "--no-stream", "-a"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
})
It("podman stats on container with forced slirp4netns", func() {
// This will force the slirp4netns net mode to be tested as root
session := podmanTest.Podman([]string{"run", "-d", "--net", "slirp4netns", ALPINE, "top"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"stats", "--no-stream", "-a"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
})
// Regression test for #8265
@@ -160,19 +161,19 @@ var _ = Describe("Podman stats", func() {
session := podmanTest.Podman([]string{"run", "-d", "--name", ctrNoLimit0, ALPINE, "top"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"run", "-d", "--name", ctrNoLimit1, ALPINE, "top"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"run", "-d", "--name", ctrWithLimit, "--memory", "50m", ALPINE, "top"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"stats", "--no-stream", "--format", "{{.MemLimit}}", ctrNoLimit0, ctrNoLimit1, ctrWithLimit})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
// We have three containers. The unlimited ones need to have
// the same limit, the limited one a lower one.