summaryrefslogtreecommitdiff
path: root/test/e2e/pod_create_test.go
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2021-07-14 13:55:00 -0600
committerEd Santiago <santiago@redhat.com>2021-07-15 05:06:33 -0600
commit547fff27033a294d1639ee3f9125f775032f39f5 (patch)
tree056f808343188229738ada44c71432babdcbe391 /test/e2e/pod_create_test.go
parent61245884abb181ee4dd46280a56dec5f25d2432d (diff)
downloadpodman-547fff27033a294d1639ee3f9125f775032f39f5.tar.gz
podman-547fff27033a294d1639ee3f9125f775032f39f5.tar.bz2
podman-547fff27033a294d1639ee3f9125f775032f39f5.zip
e2e tests: use Should(Exit()) and ExitWithError()
e2e test failures are rife with messages like: Expected 1 to equal 0 These make me cry. They're anti-helpful, requiring the reader to dive into the source code to figure out what those numbers mean. Solution: Go tests have a '.Should(Exit(NNN))' mechanism. I don't know if it spits out a better diagnostic (I have no way to run e2e tests on my laptop), but I have to fantasize that it will, and given the state of our flakes I assume that at least one test will fail and give me the opportunity to see what the error message looks like. THIS IS NOT REVIEWABLE CODE. There is no way for a human to review it. Don't bother. Maybe look at a few random ones for sanity. If you want to really review, here is a reproducer of what I did: cd test/e2e ! positive assertions. The second is the same as the first, ! with the addition of (unnecessary) parentheses because ! some invocations were written that way. The third is BeZero(). perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(Equal\((\d+)\)\)/Expect($1).Should(Exit($2))/' *_test.go perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(\(Equal\((\d+)\)\)\)/Expect($1).Should(Exit($2))/' *_test.go perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(BeZero\(\)\)/Expect($1).Should(Exit(0))/' *_test.go ! Same as above, but handles three non-numeric exit codes ! in run_exit_test.go perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(Equal\((\S+)\)\)/Expect($1).Should(Exit($2))/' *_test.go ! negative assertions. Difference is the spelling of 'To(Not)', ! 'ToNot', and 'NotTo'. I assume those are all the same. perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(Not\(Equal\((0)\)\)\)/Expect($1).To(ExitWithError())/' *_test.go perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.ToNot\(Equal\((0)\)\)/Expect($1).To(ExitWithError())/' *_test.go perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.NotTo\(Equal\((0)\)\)/Expect($1).To(ExitWithError())/' *_test.go ! negative, old use of BeZero() perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.ToNot\(BeZero\(\)\)/Expect($1).Should(ExitWithError())/' *_test.go Run those on a clean copy of main branch (at the same branch point as my PR, of course), then diff against a checked-out copy of my PR. There should be no differences. Then all you have to review is that my replacements above are sane. UPDATE: nope, that's not enough, you also need to add gomega/gexec to the files that don't have it: perl -pi -e '$_ .= "$1/gexec\"\n" if m!^(.*/onsi/gomega)"!' $(grep -L gomega/gexec $(git log -1 --stat | awk '$1 ~ /test\/e2e\// { print $1}')) UPDATE 2: hand-edit run_volume_test.go UPDATE 3: sigh, add WaitWithDefaultTimeout() to a couple of places UPDATE 4: skip a test due to bug #10935 (race condition) Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/e2e/pod_create_test.go')
-rw-r--r--test/e2e/pod_create_test.go147
1 files changed, 74 insertions, 73 deletions
diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go
index e437c98e6..71fec8d21 100644
--- a/test/e2e/pod_create_test.go
+++ b/test/e2e/pod_create_test.go
@@ -14,6 +14,7 @@ import (
. "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gexec"
)
var _ = Describe("Podman pod create", func() {
@@ -79,7 +80,7 @@ var _ = Describe("Podman pod create", func() {
name := "test"
session := podmanTest.Podman([]string{"create", "--name", name, ALPINE, "ls"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
_, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {name}})
Expect(ec).To(Not(Equal(0)))
@@ -93,52 +94,52 @@ var _ = Describe("Podman pod create", func() {
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--name", name})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
pod := session.OutputToString()
webserver := podmanTest.Podman([]string{"run", "--pod", pod, "-dt", nginx})
webserver.WaitWithDefaultTimeout()
- Expect(webserver.ExitCode()).To(Equal(0))
+ Expect(webserver).Should(Exit(0))
check := SystemExec("nc", []string{"-z", "localhost", "80"})
- Expect(check.ExitCode()).To(Equal(1))
+ Expect(check).Should(Exit(1))
})
It("podman create pod with network portbindings", func() {
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--name", name, "-p", "8080:80"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
pod := session.OutputToString()
webserver := podmanTest.Podman([]string{"run", "--pod", pod, "-dt", nginx})
webserver.WaitWithDefaultTimeout()
- Expect(webserver.ExitCode()).To(Equal(0))
+ Expect(webserver).Should(Exit(0))
check := SystemExec("nc", []string{"-z", "localhost", "8080"})
- Expect(check.ExitCode()).To(Equal(0))
+ Expect(check).Should(Exit(0))
})
It("podman create pod with no infra but portbindings should fail", func() {
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--infra=false", "--name", name, "-p", "80:80"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(125))
+ Expect(session).Should(Exit(125))
})
It("podman create pod with --no-hosts", func() {
name := "test"
podCreate := podmanTest.Podman([]string{"pod", "create", "--no-hosts", "--name", name})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
alpineResolvConf := podmanTest.Podman([]string{"run", "-ti", "--rm", "--no-hosts", ALPINE, "cat", "/etc/hosts"})
alpineResolvConf.WaitWithDefaultTimeout()
- Expect(alpineResolvConf.ExitCode()).To(Equal(0))
+ Expect(alpineResolvConf).Should(Exit(0))
podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/hosts"})
podResolvConf.WaitWithDefaultTimeout()
- Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(podResolvConf).Should(Exit(0))
Expect(podResolvConf.OutputToString()).To(Equal(alpineResolvConf.OutputToString()))
})
@@ -146,18 +147,18 @@ var _ = Describe("Podman pod create", func() {
name := "test"
podCreate := podmanTest.Podman([]string{"pod", "create", "--no-hosts", "--name", name, "--infra=false"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
})
It("podman create pod with --add-host", func() {
name := "test"
podCreate := podmanTest.Podman([]string{"pod", "create", "--add-host", "test.example.com:12.34.56.78", "--name", name})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/hosts"})
podResolvConf.WaitWithDefaultTimeout()
- Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(podResolvConf).Should(Exit(0))
Expect(strings.Contains(podResolvConf.OutputToString(), "12.34.56.78 test.example.com")).To(BeTrue())
})
@@ -165,7 +166,7 @@ var _ = Describe("Podman pod create", func() {
name := "test"
podCreate := podmanTest.Podman([]string{"pod", "create", "--add-host", "test.example.com:12.34.56.78", "--name", name, "--infra=false"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
})
It("podman create pod with DNS server set", func() {
@@ -173,11 +174,11 @@ var _ = Describe("Podman pod create", func() {
server := "12.34.56.78"
podCreate := podmanTest.Podman([]string{"pod", "create", "--dns", server, "--name", name})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/resolv.conf"})
podResolvConf.WaitWithDefaultTimeout()
- Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(podResolvConf).Should(Exit(0))
Expect(strings.Contains(podResolvConf.OutputToString(), fmt.Sprintf("nameserver %s", server))).To(BeTrue())
})
@@ -186,7 +187,7 @@ var _ = Describe("Podman pod create", func() {
server := "12.34.56.78"
podCreate := podmanTest.Podman([]string{"pod", "create", "--dns", server, "--name", name, "--infra=false"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
})
It("podman create pod with DNS option set", func() {
@@ -194,11 +195,11 @@ var _ = Describe("Podman pod create", func() {
option := "attempts:5"
podCreate := podmanTest.Podman([]string{"pod", "create", "--dns-opt", option, "--name", name})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/resolv.conf"})
podResolvConf.WaitWithDefaultTimeout()
- Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(podResolvConf).Should(Exit(0))
Expect(strings.Contains(podResolvConf.OutputToString(), fmt.Sprintf("options %s", option))).To(BeTrue())
})
@@ -207,7 +208,7 @@ var _ = Describe("Podman pod create", func() {
option := "attempts:5"
podCreate := podmanTest.Podman([]string{"pod", "create", "--dns-opt", option, "--name", name, "--infra=false"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
})
It("podman create pod with DNS search domain set", func() {
@@ -215,11 +216,11 @@ var _ = Describe("Podman pod create", func() {
search := "example.com"
podCreate := podmanTest.Podman([]string{"pod", "create", "--dns-search", search, "--name", name})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/resolv.conf"})
podResolvConf.WaitWithDefaultTimeout()
- Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(podResolvConf).Should(Exit(0))
Expect(strings.Contains(podResolvConf.OutputToString(), fmt.Sprintf("search %s", search))).To(BeTrue())
})
@@ -228,7 +229,7 @@ var _ = Describe("Podman pod create", func() {
search := "example.com"
podCreate := podmanTest.Podman([]string{"pod", "create", "--dns-search", search, "--name", name, "--infra=false"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
})
It("podman create pod with IP address", func() {
@@ -238,12 +239,12 @@ var _ = Describe("Podman pod create", func() {
podCreate.WaitWithDefaultTimeout()
// Rootless should error without network
if rootless.IsRootless() {
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
} else {
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "ip", "addr"})
podResolvConf.WaitWithDefaultTimeout()
- Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(podResolvConf).Should(Exit(0))
Expect(strings.Contains(podResolvConf.OutputToString(), ip)).To(BeTrue())
}
})
@@ -255,13 +256,13 @@ var _ = Describe("Podman pod create", func() {
ip := GetRandomIPAddress()
podCreate := podmanTest.Podman([]string{"pod", "create", "--ip", ip, "--name", podName})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podCtr := podmanTest.Podman([]string{"run", "--name", ctrName, "--pod", podName, "-d", "-t", ALPINE, "top"})
podCtr.WaitWithDefaultTimeout()
- Expect(podCtr.ExitCode()).To(Equal(0))
+ Expect(podCtr).Should(Exit(0))
ctrInspect := podmanTest.Podman([]string{"inspect", ctrName})
ctrInspect.WaitWithDefaultTimeout()
- Expect(ctrInspect.ExitCode()).To(Equal(0))
+ Expect(ctrInspect).Should(Exit(0))
ctrJSON := ctrInspect.InspectContainerToJSON()
Expect(ctrJSON[0].NetworkSettings.IPAddress).To(Equal(ip))
})
@@ -271,7 +272,7 @@ var _ = Describe("Podman pod create", func() {
ip := GetRandomIPAddress()
podCreate := podmanTest.Podman([]string{"pod", "create", "--ip", ip, "--name", name, "--infra=false"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
})
It("podman create pod with MAC address", func() {
@@ -281,12 +282,12 @@ var _ = Describe("Podman pod create", func() {
podCreate.WaitWithDefaultTimeout()
// Rootless should error
if rootless.IsRootless() {
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
} else {
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "ip", "addr"})
podResolvConf.WaitWithDefaultTimeout()
- Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(podResolvConf).Should(Exit(0))
Expect(strings.Contains(podResolvConf.OutputToString(), mac)).To(BeTrue())
}
})
@@ -296,7 +297,7 @@ var _ = Describe("Podman pod create", func() {
mac := "92:d0:c6:0a:29:35"
podCreate := podmanTest.Podman([]string{"pod", "create", "--mac-address", mac, "--name", name, "--infra=false"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
})
It("podman create pod and print id to external file", func() {
@@ -314,7 +315,7 @@ var _ = Describe("Podman pod create", func() {
session := podmanTest.Podman([]string{"pod", "create", "--name=abc", "--pod-id-file", targetFile})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
id, _ := ioutil.ReadFile(targetFile)
check := podmanTest.Podman([]string{"pod", "inspect", "abc"})
@@ -327,14 +328,14 @@ var _ = Describe("Podman pod create", func() {
// Make sure we error out with --name.
session := podmanTest.Podman([]string{"pod", "create", "--replace", ALPINE, "/bin/sh"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(125))
+ Expect(session).Should(Exit(125))
// Create and replace 5 times in a row the "same" pod.
podName := "testCtr"
for i := 0; i < 5; i++ {
session = podmanTest.Podman([]string{"pod", "create", "--replace", "--name", podName})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
}
})
@@ -342,22 +343,22 @@ var _ = Describe("Podman pod create", func() {
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--name", name})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
check := podmanTest.Podman([]string{"pod", "inspect", name})
check.WaitWithDefaultTimeout()
- Expect(check.ExitCode()).To(Equal(0))
+ Expect(check).Should(Exit(0))
data := check.InspectPodToJSON()
check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID})
check1.WaitWithDefaultTimeout()
- Expect(check1.ExitCode()).To(Equal(0))
+ Expect(check1).Should(Exit(0))
Expect(check1.OutputToString()).To(Equal("/pause"))
// check the Path and Args
check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID})
check2.WaitWithDefaultTimeout()
- Expect(check2.ExitCode()).To(Equal(0))
+ Expect(check2).Should(Exit(0))
Expect(check2.OutputToString()).To(Equal("/pause:[/pause]"))
})
@@ -365,22 +366,22 @@ var _ = Describe("Podman pod create", func() {
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--infra-command", "/pause1", "--name", name})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
check := podmanTest.Podman([]string{"pod", "inspect", name})
check.WaitWithDefaultTimeout()
- Expect(check.ExitCode()).To(Equal(0))
+ Expect(check).Should(Exit(0))
data := check.InspectPodToJSON()
check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID})
check1.WaitWithDefaultTimeout()
- Expect(check1.ExitCode()).To(Equal(0))
+ Expect(check1).Should(Exit(0))
Expect(check1.OutputToString()).To(Equal("/pause1"))
// check the Path and Args
check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID})
check2.WaitWithDefaultTimeout()
- Expect(check2.ExitCode()).To(Equal(0))
+ Expect(check2).Should(Exit(0))
Expect(check2.OutputToString()).To(Equal("/pause1:[/pause1]"))
})
@@ -392,22 +393,22 @@ entrypoint ["/fromimage"]
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--infra-image", "localhost/infra", "--name", name})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
check := podmanTest.Podman([]string{"pod", "inspect", name})
check.WaitWithDefaultTimeout()
- Expect(check.ExitCode()).To(Equal(0))
+ Expect(check).Should(Exit(0))
data := check.InspectPodToJSON()
check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID})
check1.WaitWithDefaultTimeout()
- Expect(check1.ExitCode()).To(Equal(0))
+ Expect(check1).Should(Exit(0))
Expect(check1.OutputToString()).To(Equal("/fromimage"))
// check the Path and Args
check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID})
check2.WaitWithDefaultTimeout()
- Expect(check2.ExitCode()).To(Equal(0))
+ Expect(check2).Should(Exit(0))
Expect(check2.OutputToString()).To(Equal("/fromimage:[/fromimage]"))
})
@@ -419,22 +420,22 @@ entrypoint ["/fromimage"]
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--infra-image", "localhost/infra", "--infra-command", "/fromcommand", "--name", name})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
check := podmanTest.Podman([]string{"pod", "inspect", name})
check.WaitWithDefaultTimeout()
- Expect(check.ExitCode()).To(Equal(0))
+ Expect(check).Should(Exit(0))
data := check.InspectPodToJSON()
check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID})
check1.WaitWithDefaultTimeout()
- Expect(check1.ExitCode()).To(Equal(0))
+ Expect(check1).Should(Exit(0))
Expect(check1.OutputToString()).To(Equal("/fromcommand"))
// check the Path and Args
check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID})
check2.WaitWithDefaultTimeout()
- Expect(check2.ExitCode()).To(Equal(0))
+ Expect(check2).Should(Exit(0))
Expect(check2.OutputToString()).To(Equal("/fromcommand:[/fromcommand]"))
})
@@ -442,11 +443,11 @@ entrypoint ["/fromimage"]
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--name", name, "--network", "slirp4netns:port_handler=slirp4netns", "-p", "8082:8000"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
check := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{.InfraConfig.NetworkOptions.slirp4netns}}", name})
check.WaitWithDefaultTimeout()
- Expect(check.ExitCode()).To(Equal(0))
+ Expect(check).Should(Exit(0))
Expect(check.OutputToString()).To(Equal("[port_handler=slirp4netns]"))
})
@@ -454,41 +455,41 @@ entrypoint ["/fromimage"]
podName := "testpod"
create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
create.WaitWithDefaultTimeout()
- Expect(create.ExitCode()).To(Equal(0))
+ Expect(create).Should(Exit(0))
status1 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName})
status1.WaitWithDefaultTimeout()
- Expect(status1.ExitCode()).To(Equal(0))
+ Expect(status1).Should(Exit(0))
Expect(strings.Contains(status1.OutputToString(), "Created")).To(BeTrue())
ctr1 := podmanTest.Podman([]string{"run", "--pod", podName, "-d", ALPINE, "top"})
ctr1.WaitWithDefaultTimeout()
- Expect(ctr1.ExitCode()).To(Equal(0))
+ Expect(ctr1).Should(Exit(0))
status2 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName})
status2.WaitWithDefaultTimeout()
- Expect(status2.ExitCode()).To(Equal(0))
+ Expect(status2).Should(Exit(0))
Expect(strings.Contains(status2.OutputToString(), "Running")).To(BeTrue())
ctr2 := podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"})
ctr2.WaitWithDefaultTimeout()
- Expect(ctr2.ExitCode()).To(Equal(0))
+ Expect(ctr2).Should(Exit(0))
status3 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName})
status3.WaitWithDefaultTimeout()
- Expect(status3.ExitCode()).To(Equal(0))
+ Expect(status3).Should(Exit(0))
Expect(strings.Contains(status3.OutputToString(), "Degraded")).To(BeTrue())
})
It("podman create with unsupported network options", func() {
podCreate := podmanTest.Podman([]string{"pod", "create", "--network", "container:doesnotmatter"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
Expect(podCreate.ErrorToString()).To(ContainSubstring("pods presently do not support network mode container"))
podCreate = podmanTest.Podman([]string{"pod", "create", "--network", "ns:/does/not/matter"})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(125))
+ Expect(podCreate).Should(Exit(125))
Expect(podCreate.ErrorToString()).To(ContainSubstring("pods presently do not support network mode path"))
})
@@ -496,11 +497,11 @@ entrypoint ["/fromimage"]
podName := "testPod"
podCreate := podmanTest.Podman([]string{"pod", "create", "--network", "none", "--name", podName})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
session := podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "ip", "-o", "-4", "addr"})
session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring("inet 127.0.0.1/8 scope host lo"))
Expect(len(session.OutputToStringArray())).To(Equal(1))
})
@@ -515,7 +516,7 @@ ENTRYPOINT ["sleep","99999"]
create := podmanTest.Podman([]string{"pod", "create", "--infra-image", iid})
create.WaitWithDefaultTimeout()
- Expect(create.ExitCode()).To(BeZero())
+ Expect(create).Should(Exit(0))
})
It("podman pod create --cpus", func() {
@@ -525,15 +526,15 @@ ENTRYPOINT ["sleep","99999"]
numCPUStr := strconv.Itoa(int(numCPU))
podCreate := podmanTest.Podman([]string{"pod", "create", "--cpus", numCPUStr, "--name", podName})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
contCreate := podmanTest.Podman([]string{"container", "create", "--pod", podName, "alpine"})
contCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podInspect := podmanTest.Podman([]string{"pod", "inspect", podName})
podInspect.WaitWithDefaultTimeout()
- Expect(podInspect.ExitCode()).To(Equal(0))
+ Expect(podInspect).Should(Exit(0))
podJSON := podInspect.InspectPodToJSON()
Expect(podJSON.CPUPeriod).To(Equal(period))
Expect(podJSON.CPUQuota).To(Equal(quota))
@@ -547,15 +548,15 @@ ENTRYPOINT ["sleep","99999"]
in := "0-" + numCPUStr
podCreate := podmanTest.Podman([]string{"pod", "create", "--cpuset-cpus", in, "--name", podName})
podCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
contCreate := podmanTest.Podman([]string{"container", "create", "--name", ctrName, "--pod", podName, "alpine"})
contCreate.WaitWithDefaultTimeout()
- Expect(podCreate.ExitCode()).To(Equal(0))
+ Expect(podCreate).Should(Exit(0))
podInspect := podmanTest.Podman([]string{"pod", "inspect", podName})
podInspect.WaitWithDefaultTimeout()
- Expect(podInspect.ExitCode()).To(Equal(0))
+ Expect(podInspect).Should(Exit(0))
podJSON := podInspect.InspectPodToJSON()
Expect(podJSON.CPUSetCPUs).To(Equal(in))
})