Skip to content

Commit

Permalink
Merge pull request #20048 from edsantiago/e2e_check_stderr__more
Browse files Browse the repository at this point in the history
e2e: ExitCleanly(): more low-hanging fruit
  • Loading branch information
openshift-merge-robot authored Sep 20, 2023
2 parents 26f25d3 + 0ac9817 commit 07f8d44
Show file tree
Hide file tree
Showing 35 changed files with 585 additions and 591 deletions.
76 changes: 38 additions & 38 deletions test/e2e/run_aardvark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"strings"

. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Podman run networking", func() {
Expand All @@ -20,24 +20,24 @@ var _ = Describe("Podman run networking", func() {
session := podmanTest.Podman([]string{"network", "create", netName})
session.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

ctrID := podmanTest.Podman([]string{"run", "-dt", "--name", "aone", "--network", netName, NGINX_IMAGE})
ctrID.WaitWithDefaultTimeout()
Expect(ctrID).Should(Exit(0))
Expect(ctrID).Should(ExitCleanly())
cid := ctrID.OutputToString()

ctrIP := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netName), cid})
ctrIP.WaitWithDefaultTimeout()
Expect(ctrIP).Should(Exit(0))
Expect(ctrIP).Should(ExitCleanly())
cip := ctrIP.OutputToString()
Expect(cip).To(MatchRegexp(IPRegex))

digShort(cid, "aone", cip, podmanTest)

reverseLookup := podmanTest.Podman([]string{"exec", cid, "dig", "+short", "-x", cip})
reverseLookup.WaitWithDefaultTimeout()
Expect(reverseLookup).Should(Exit(0))
Expect(reverseLookup).Should(ExitCleanly())
revListArray := reverseLookup.OutputToStringArray()
Expect(revListArray).Should(HaveLen(2))
Expect(strings.TrimRight(revListArray[0], ".")).To(Equal("aone"))
Expand All @@ -50,27 +50,27 @@ var _ = Describe("Podman run networking", func() {
session := podmanTest.Podman([]string{"network", "create", netName})
session.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

ctr1 := podmanTest.Podman([]string{"run", "-dt", "--name", "aone", "--network", netName, NGINX_IMAGE})
ctr1.WaitWithDefaultTimeout()
Expect(ctr1).Should(Exit(0))
Expect(ctr1).Should(ExitCleanly())
cid1 := ctr1.OutputToString()

ctrIP1 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netName), cid1})
ctrIP1.WaitWithDefaultTimeout()
Expect(ctrIP1).Should(Exit(0))
Expect(ctrIP1).Should(ExitCleanly())
cip1 := ctrIP1.OutputToString()
Expect(cip1).To(MatchRegexp(IPRegex))

ctr2 := podmanTest.Podman([]string{"run", "-dt", "--name", "atwo", "--network", netName, NGINX_IMAGE})
ctr2.WaitWithDefaultTimeout()
Expect(ctr2).Should(Exit(0))
Expect(ctr2).Should(ExitCleanly())
cid2 := ctr2.OutputToString()

ctrIP2 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netName), cid2})
ctrIP2.WaitWithDefaultTimeout()
Expect(ctrIP2).Should(Exit(0))
Expect(ctrIP2).Should(ExitCleanly())
cip2 := ctrIP2.OutputToString()
Expect(cip2).To(MatchRegexp(IPRegex))

Expand All @@ -80,15 +80,15 @@ var _ = Describe("Podman run networking", func() {

reverseLookup12 := podmanTest.Podman([]string{"exec", cid1, "dig", "+short", "-x", cip2})
reverseLookup12.WaitWithDefaultTimeout()
Expect(reverseLookup12).Should(Exit(0))
Expect(reverseLookup12).Should(ExitCleanly())
revListArray12 := reverseLookup12.OutputToStringArray()
Expect(revListArray12).Should(HaveLen(2))
Expect(strings.TrimRight(revListArray12[0], ".")).To(Equal("atwo"))
Expect(strings.TrimRight(revListArray12[1], ".")).To(Equal(cid2[:12]))

reverseLookup21 := podmanTest.Podman([]string{"exec", cid2, "dig", "+short", "-x", cip1})
reverseLookup21.WaitWithDefaultTimeout()
Expect(reverseLookup21).Should(Exit(0))
Expect(reverseLookup21).Should(ExitCleanly())
revListArray21 := reverseLookup21.OutputToStringArray()
Expect(revListArray21).Should(HaveLen(2))
Expect(strings.TrimRight(revListArray21[0], ".")).To(Equal("aone"))
Expand All @@ -101,25 +101,25 @@ var _ = Describe("Podman run networking", func() {
session := podmanTest.Podman([]string{"network", "create", netName})
session.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

ctr1 := podmanTest.Podman([]string{"run", "-dt", "--name", "aone", "--network", netName, "--network-alias", "alias_a1,alias_1a", NGINX_IMAGE})
ctr1.WaitWithDefaultTimeout()
Expect(ctr1).Should(Exit(0))
Expect(ctr1).Should(ExitCleanly())

ctrIP1 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netName), "aone"})
ctrIP1.WaitWithDefaultTimeout()
Expect(ctrIP1).Should(Exit(0))
Expect(ctrIP1).Should(ExitCleanly())
cip1 := ctrIP1.OutputToString()
Expect(cip1).To(MatchRegexp(IPRegex))

ctr2 := podmanTest.Podman([]string{"run", "-dt", "--name", "atwo", "--network", netName, "--network-alias", "alias_a2,alias_2a", NGINX_IMAGE})
ctr2.WaitWithDefaultTimeout()
Expect(ctr2).Should(Exit(0))
Expect(ctr2).Should(ExitCleanly())

ctrIP2 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netName), "atwo"})
ctrIP2.WaitWithDefaultTimeout()
Expect(ctrIP2).Should(Exit(0))
Expect(ctrIP2).Should(ExitCleanly())
cip2 := ctrIP2.OutputToString()
Expect(cip2).To(MatchRegexp(IPRegex))

Expand All @@ -142,13 +142,13 @@ var _ = Describe("Podman run networking", func() {
sessionA := podmanTest.Podman([]string{"network", "create", netNameA})
sessionA.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netNameA)
Expect(sessionA).Should(Exit(0))
Expect(sessionA).Should(ExitCleanly())

netNameB := createNetworkName("TestB")
sessionB := podmanTest.Podman([]string{"network", "create", netNameB})
sessionB.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netNameB)
Expect(sessionB).Should(Exit(0))
Expect(sessionB).Should(ExitCleanly())

ctrA1 := podmanTest.Podman([]string{"run", "-dt", "--name", "aone", "--network", netNameA, NGINX_IMAGE})
ctrA1.WaitWithDefaultTimeout()
Expand All @@ -160,24 +160,24 @@ var _ = Describe("Podman run networking", func() {

ctrIPA1 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netNameA), cidA1})
ctrIPA1.WaitWithDefaultTimeout()
Expect(ctrIPA1).Should(Exit(0))
Expect(ctrIPA1).Should(ExitCleanly())
cipA1 := ctrIPA1.OutputToString()
Expect(cipA1).To(MatchRegexp(IPRegex))

ctrIPB1 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netNameB), cidB1})
ctrIPB1.WaitWithDefaultTimeout()
Expect(ctrIPB1).Should(Exit(0))
Expect(ctrIPB1).Should(ExitCleanly())
cipB1 := ctrIPB1.OutputToString()
Expect(cipB1).To(MatchRegexp(IPRegex))

resA1B1 := podmanTest.Podman([]string{"exec", "aone", "dig", "+short", "bone"})
resA1B1.WaitWithDefaultTimeout()
Expect(resA1B1).Should(Exit(0))
Expect(resA1B1).Should(ExitCleanly())
Expect(resA1B1.OutputToString()).To(Equal(""))

resB1A1 := podmanTest.Podman([]string{"exec", "bone", "dig", "+short", "aone"})
resB1A1.WaitWithDefaultTimeout()
Expect(resB1A1).Should(Exit(0))
Expect(resB1A1).Should(ExitCleanly())
Expect(resB1A1.OutputToString()).To(Equal(""))
})

Expand All @@ -186,21 +186,21 @@ var _ = Describe("Podman run networking", func() {
sessionA := podmanTest.Podman([]string{"network", "create", netNameA})
sessionA.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netNameA)
Expect(sessionA).Should(Exit(0))
Expect(sessionA).Should(ExitCleanly())

netNameB := createNetworkName("TestB")
sessionB := podmanTest.Podman([]string{"network", "create", netNameB})
sessionB.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netNameB)
Expect(sessionB).Should(Exit(0))
Expect(sessionB).Should(ExitCleanly())

ctrA1 := podmanTest.Podman([]string{"run", "-dt", "--name", "aone", "--network", netNameA, NGINX_IMAGE})
ctrA1.WaitWithDefaultTimeout()
cidA1 := ctrA1.OutputToString()

ctrIPA1 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netNameA), cidA1})
ctrIPA1.WaitWithDefaultTimeout()
Expect(ctrIPA1).Should(Exit(0))
Expect(ctrIPA1).Should(ExitCleanly())
cipA1 := ctrIPA1.OutputToString()
Expect(cipA1).To(MatchRegexp(IPRegex))

Expand All @@ -210,7 +210,7 @@ var _ = Describe("Podman run networking", func() {

ctrIPB1 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netNameB), cidB1})
ctrIPB1.WaitWithDefaultTimeout()
Expect(ctrIPB1).Should(Exit(0))
Expect(ctrIPB1).Should(ExitCleanly())
cipB1 := ctrIPB1.OutputToString()
Expect(cipB1).To(MatchRegexp(IPRegex))

Expand All @@ -220,13 +220,13 @@ var _ = Describe("Podman run networking", func() {

ctrIPA2B21 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netNameA), cidA2B2})
ctrIPA2B21.WaitWithDefaultTimeout()
Expect(ctrIPA2B21).Should(Exit(0))
Expect(ctrIPA2B21).Should(ExitCleanly())
cipA2B21 := ctrIPA2B21.OutputToString()
Expect(cipA2B21).To(MatchRegexp(IPRegex))

ctrIPA2B22 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netNameB), cidA2B2})
ctrIPA2B22.WaitWithDefaultTimeout()
Expect(ctrIPA2B22).Should(Exit(0))
Expect(ctrIPA2B22).Should(ExitCleanly())
cipA2B22 := ctrIPA2B22.OutputToString()
Expect(cipA2B22).To(MatchRegexp(IPRegex))

Expand All @@ -244,44 +244,44 @@ var _ = Describe("Podman run networking", func() {
sessionA := podmanTest.Podman([]string{"network", "create", netNameA})
sessionA.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netNameA)
Expect(sessionA).Should(Exit(0))
Expect(sessionA).Should(ExitCleanly())

netNameB := createNetworkName("TestB")
sessionB := podmanTest.Podman([]string{"network", "create", netNameB})
sessionB.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netNameB)
Expect(sessionB).Should(Exit(0))
Expect(sessionB).Should(ExitCleanly())

netNameC := createNetworkName("TestC")
sessionC := podmanTest.Podman([]string{"network", "create", netNameC})
sessionC.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netNameC)
Expect(sessionC).Should(Exit(0))
Expect(sessionC).Should(ExitCleanly())

ctrA := podmanTest.Podman([]string{"run", "-dt", "--name", "aone", "--network", netNameA, NGINX_IMAGE})
ctrA.WaitWithDefaultTimeout()
Expect(ctrA).Should(Exit(0))
Expect(ctrA).Should(ExitCleanly())

ctrC := podmanTest.Podman([]string{"run", "-dt", "--name", "cone", "--network", netNameC, NGINX_IMAGE})
ctrC.WaitWithDefaultTimeout()
Expect(ctrC).Should(Exit(0))
Expect(ctrC).Should(ExitCleanly())

ctrnetAB1 := podmanTest.Podman([]string{"network", "connect", "--alias", "testB1_nw", netNameB, "aone"})
ctrnetAB1.WaitWithDefaultTimeout()
Expect(ctrnetAB1).Should(Exit(0))
Expect(ctrnetAB1).Should(ExitCleanly())

ctrIPAB1 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netNameB), "aone"})
ctrIPAB1.WaitWithDefaultTimeout()
Expect(ctrIPAB1).Should(Exit(0))
Expect(ctrIPAB1).Should(ExitCleanly())
cipAB1 := ctrIPAB1.OutputToString()

ctrnetCB2 := podmanTest.Podman([]string{"network", "connect", "--alias", "testB2_nw", netNameB, "cone"})
ctrnetCB2.WaitWithDefaultTimeout()
Expect(ctrnetCB2).Should(Exit(0))
Expect(ctrnetCB2).Should(ExitCleanly())

ctrIPCB2 := podmanTest.Podman([]string{"inspect", "--format", fmt.Sprintf(`{{.NetworkSettings.Networks.%s.IPAddress}}`, netNameB), "cone"})
ctrIPCB2.WaitWithDefaultTimeout()
Expect(ctrIPCB2).Should(Exit(0))
Expect(ctrIPCB2).Should(ExitCleanly())
cipCB2 := ctrIPCB2.OutputToString()

digShort("aone", "testB2_nw", cipCB2, podmanTest)
Expand Down
17 changes: 8 additions & 9 deletions test/e2e/run_apparmor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

// wip
Expand All @@ -33,7 +32,7 @@ var _ = Describe("Podman run", func() {
skipIfAppArmorDisabled()
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

cid := session.OutputToString()
// Verify that apparmor.Profile is being set
Expand All @@ -45,7 +44,7 @@ var _ = Describe("Podman run", func() {
skipIfAppArmorDisabled()
session := podmanTest.Podman([]string{"create", "--privileged", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

cid := session.OutputToString()
// Verify that apparmor.Profile is being set
Expand All @@ -57,7 +56,7 @@ var _ = Describe("Podman run", func() {
skipIfAppArmorDisabled()
session := podmanTest.Podman([]string{"create", "--security-opt", fmt.Sprintf("apparmor=%s", apparmor.Profile), "--privileged", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

cid := session.OutputToString()
// Verify that apparmor.Profile is being set
Expand All @@ -84,11 +83,11 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) {
aaFile := filepath.Join(os.TempDir(), "aaFile")
Expect(os.WriteFile(aaFile, []byte(aaProfile), 0755)).To(Succeed())
parse := SystemExec("apparmor_parser", []string{"-Kr", aaFile})
Expect(parse).Should(Exit(0))
Expect(parse).Should(ExitCleanly())

session := podmanTest.Podman([]string{"create", "--security-opt", "apparmor=aa-test-profile", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

cid := session.OutputToString()
// Verify that apparmor.Profile is being set
Expand All @@ -107,7 +106,7 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) {
skipIfAppArmorDisabled()
session := podmanTest.Podman([]string{"create", "--security-opt", "apparmor=unconfined", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

cid := session.OutputToString()
// Verify that apparmor.Profile is being set
Expand All @@ -128,7 +127,7 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) {
// Should succeed if user specifies apparmor on disabled system
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

cid := session.OutputToString()
// Verify that apparmor.Profile is being set
Expand All @@ -141,7 +140,7 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) {

session := podmanTest.Podman([]string{"create", "--security-opt", "apparmor=unconfined", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())

cid := session.OutputToString()
// Verify that apparmor.Profile is being set
Expand Down
Loading

0 comments on commit 07f8d44

Please sign in to comment.