e2e: more ExitCleanly(): dumb string replacements

Ongoing steps toward RUN-1907: replace Exit(0) with ExitCleanly()

Commit 1 of 2: simple automated string-replace, plus fixes
to includes.

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago
2023-09-12 16:40:48 -06:00
parent e8c4d7966b
commit cb1cb338c0
11 changed files with 271 additions and 275 deletions

View File

@ -7,10 +7,10 @@ import (
"time"
"github.com/containers/podman/v4/libpod/events"
. "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("Podman events", func() {
@ -25,7 +25,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman events with an event filter", func() {
@ -33,7 +33,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).ToNot(BeEmpty(), "Number of events")
date := time.Now().Format("2006-01-02")
Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix(date)), "event log has correct timestamp")
@ -47,13 +47,13 @@ var _ = Describe("Podman events", func() {
resultPrefix := podmanTest.Podman([]string{"events", "--stream=false", "--filter", fmt.Sprintf("volume=%s", vname[:5])})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
events := result.OutputToStringArray()
Expect(events).To(HaveLen(1), "number of events")
Expect(events[0]).To(ContainSubstring(vname), "event log includes volume name")
resultPrefix.WaitWithDefaultTimeout()
Expect(resultPrefix).Should(Exit(0))
Expect(resultPrefix).Should(ExitCleanly())
events = resultPrefix.OutputToStringArray()
Expect(events).To(HaveLen(1), "number of events")
Expect(events[0]).To(ContainSubstring(vname), "event log includes volume name")
@ -67,7 +67,7 @@ var _ = Describe("Podman events", func() {
time.Sleep(5 * time.Second)
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start", "--filter", fmt.Sprintf("container=%s", cid)})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
events := result.OutputToStringArray()
Expect(events).To(HaveLen(1), "number of events")
Expect(events[0]).To(ContainSubstring(cid), "event log includes CID")
@ -79,7 +79,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "type=pod", "--filter", fmt.Sprintf("container=%s", cid)})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(BeEmpty())
})
@ -88,11 +88,11 @@ var _ = Describe("Podman events", func() {
setup.WaitWithDefaultTimeout()
stop := podmanTest.Podman([]string{"pod", "stop", "foobarpod"})
stop.WaitWithDefaultTimeout()
Expect(stop).Should(Exit(0))
Expect(setup).Should(Exit(0))
Expect(stop).Should(ExitCleanly())
Expect(setup).Should(ExitCleanly())
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "type=pod", "--filter", "pod=foobarpod"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
events := result.OutputToStringArray()
GinkgoWriter.Println(events)
Expect(len(events)).To(BeNumerically(">=", 2), "Number of events")
@ -106,7 +106,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false", "--since", "1m"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman events --until", func() {
@ -114,7 +114,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false", "--until", "1h"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman events format", func() {
@ -123,7 +123,7 @@ var _ = Describe("Podman events", func() {
test := podmanTest.Podman([]string{"events", "--stream=false", "--format", "json"})
test.WaitWithDefaultTimeout()
Expect(test).To(Exit(0))
Expect(test).To(ExitCleanly())
jsonArr := test.OutputToStringArray()
Expect(test.OutputToStringArray()).ShouldNot(BeEmpty())
@ -134,7 +134,7 @@ var _ = Describe("Podman events", func() {
test = podmanTest.Podman([]string{"events", "--stream=false", "--format", "{{json.}}"})
test.WaitWithDefaultTimeout()
Expect(test).To(Exit(0))
Expect(test).To(ExitCleanly())
jsonArr = test.OutputToStringArray()
Expect(test.OutputToStringArray()).ShouldNot(BeEmpty())
@ -145,7 +145,7 @@ var _ = Describe("Podman events", func() {
test = podmanTest.Podman([]string{"events", "--stream=false", "--filter=type=container", "--format", "ID: {{.ID}}"})
test.WaitWithDefaultTimeout()
Expect(test).To(Exit(0))
Expect(test).To(ExitCleanly())
arr := test.OutputToStringArray()
Expect(len(arr)).To(BeNumerically(">", 1))
Expect(arr[0]).To(MatchRegexp("ID: [a-fA-F0-9]{64}"))
@ -157,7 +157,7 @@ var _ = Describe("Podman events", func() {
name3 := stringid.GenerateRandomID()
session := podmanTest.Podman([]string{"create", "--name", name1, ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
var wg sync.WaitGroup
wg.Add(1)
@ -169,17 +169,17 @@ var _ = Describe("Podman events", func() {
time.Sleep(time.Second * 2)
session = podmanTest.Podman([]string{"create", "--name", name2, ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"create", "--name", name3, ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
}()
// unix timestamp in 10 seconds
until := time.Now().Add(time.Second * 10).Unix()
result := podmanTest.Podman([]string{"events", "--since", "30s", "--until", fmt.Sprint(until)})
result.Wait(11)
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(ContainSubstring(name1))
Expect(result.OutputToString()).To(ContainSubstring(name2))
Expect(result.OutputToString()).To(ContainSubstring(name3))
@ -188,7 +188,7 @@ var _ = Describe("Podman events", func() {
untilT := time.Now().Add(time.Second * 9)
result = podmanTest.Podman([]string{"events", "--since", "30s", "--until", "10s"})
result.Wait(11)
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
tEnd := time.Now()
outDur := tEnd.Sub(untilT)
Expect(outDur.Seconds()).To(BeNumerically(">", 0), "duration")
@ -202,29 +202,29 @@ var _ = Describe("Podman events", func() {
It("podman events pod creation", func() {
create := podmanTest.Podman([]string{"pod", "create", "--infra=false", "--name", "foobarpod"})
create.WaitWithDefaultTimeout()
Expect(create).Should(Exit(0))
Expect(create).Should(ExitCleanly())
id := create.OutputToString()
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "pod=" + id})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(HaveLen(1))
Expect(result.OutputToString()).To(ContainSubstring("create"))
ctrName := "testCtr"
run := podmanTest.Podman([]string{"create", "--pod", id, "--name", ctrName, ALPINE, "top"})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
Expect(run).Should(ExitCleanly())
result2 := podmanTest.Podman([]string{"events", "--stream=false", "--filter", fmt.Sprintf("container=%s", ctrName), "--since", "30s"})
result2.WaitWithDefaultTimeout()
Expect(result2).Should(Exit(0))
Expect(result2).Should(ExitCleanly())
Expect(result2.OutputToString()).To(ContainSubstring(fmt.Sprintf("pod_id=%s", id)))
})
It("podman events health_status generated", func() {
session := podmanTest.Podman([]string{"run", "--name", "test-hc", "-dt", "--health-cmd", "echo working", "busybox"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
for i := 0; i < 5; i++ {
hc := podmanTest.Podman([]string{"healthcheck", "run", "test-hc"})
@ -238,7 +238,7 @@ var _ = Describe("Podman events", func() {
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=health_status", "--since", "1m"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).ToNot(BeEmpty(), "Number of health_status events")
})