Skip to content

Commit

Permalink
Merge pull request #20022 from edsantiago/e2e_check_stderr__more
Browse files Browse the repository at this point in the history
more ExitCleanly()
  • Loading branch information
openshift-merge-robot authored Sep 19, 2023
2 parents c585197 + e6cf09b commit 0293e64
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 132 deletions.
99 changes: 50 additions & 49 deletions test/e2e/network_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.12.0/24", "--ip-range", "10.11.12.0/26", netName})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand All @@ -51,7 +51,7 @@ var _ = Describe("Podman network create", func() {

try := podmanTest.Podman([]string{"run", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"})
try.WaitWithDefaultTimeout()
Expect(try).To(Exit(0))
Expect(try).To(ExitCleanly())

_, subnet, err := net.ParseCIDR("10.11.12.0/24")
Expect(err).ToNot(HaveOccurred())
Expand All @@ -76,12 +76,12 @@ var _ = Describe("Podman network create", func() {
})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand Down Expand Up @@ -117,12 +117,12 @@ var _ = Describe("Podman network create", func() {
})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand Down Expand Up @@ -160,12 +160,12 @@ var _ = Describe("Podman network create", func() {
})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand Down Expand Up @@ -205,12 +205,12 @@ var _ = Describe("Podman network create", func() {
})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand Down Expand Up @@ -246,12 +246,12 @@ var _ = Describe("Podman network create", func() {
})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand All @@ -276,12 +276,12 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:1:2:3:4::/64", netName})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand All @@ -300,7 +300,7 @@ var _ = Describe("Podman network create", func() {

try := podmanTest.Podman([]string{"run", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | grep global | awk ' /inet6 / {print $2}'"})
try.WaitWithDefaultTimeout()
Expect(try).To(Exit(0))
Expect(try).To(ExitCleanly())

_, subnet, err := net.ParseCIDR("fd00:1:2:3:4::/64")
Expect(err).ToNot(HaveOccurred())
Expand All @@ -315,12 +315,12 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:4:3:2::/64", "--ipv6", netName})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand Down Expand Up @@ -348,12 +348,12 @@ var _ = Describe("Podman network create", func() {
nc = podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:10:3:2::/64", "--ipv6", netName2})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName2)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect = podmanTest.Podman([]string{"network", "inspect", netName2})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
err = json.Unmarshal([]byte(inspect.OutputToString()), &results)
Expand Down Expand Up @@ -401,12 +401,12 @@ var _ = Describe("Podman network create", func() {
name := stringid.GenerateRandomID()
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.14.0/24", "--ipv6", name})
nc.WaitWithDefaultTimeout()
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
defer podmanTest.removeNetwork(name)

nc = podmanTest.Podman([]string{"network", "inspect", name})
nc.WaitWithDefaultTimeout()
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(ContainSubstring(`::/64`))
Expect(nc.OutputToString()).To(ContainSubstring(`10.11.14.0/24`))
})
Expand All @@ -415,12 +415,12 @@ var _ = Describe("Podman network create", func() {
name := stringid.GenerateRandomID()
nc := podmanTest.Podman([]string{"network", "create", "--ipv6", name})
nc.WaitWithDefaultTimeout()
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
defer podmanTest.removeNetwork(name)

nc = podmanTest.Podman([]string{"network", "inspect", name})
nc.WaitWithDefaultTimeout()
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(ContainSubstring(`::/64`))
Expect(nc.OutputToString()).To(ContainSubstring(`.0/24`))
})
Expand All @@ -442,7 +442,7 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", netName})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

ncFail := podmanTest.Podman([]string{"network", "create", netName})
ncFail.WaitWithDefaultTimeout()
Expand All @@ -454,7 +454,7 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.13.0/24", netName1})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName1)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

netName2 := "sub2-" + stringid.GenerateRandomID()
ncFail := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.13.0/24", netName2})
Expand All @@ -468,7 +468,7 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:4:4:4:4::/64", "--ipv6", netName1})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName1)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

netName2 := "subipv62-" + stringid.GenerateRandomID()
ncFail := podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:4:4:4:4::/64", "--ipv6", netName2})
Expand All @@ -488,11 +488,11 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--opt", "mtu=9000", net})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(net)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

nc = podmanTest.Podman([]string{"network", "inspect", net})
nc.WaitWithDefaultTimeout()
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())
Expect(nc.OutputToString()).To(ContainSubstring(`"mtu": "9000"`))
})

Expand All @@ -501,11 +501,11 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--opt", "vlan=9", net})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(net)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

nc = podmanTest.Podman([]string{"network", "inspect", net})
nc.WaitWithDefaultTimeout()
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())
Expect(nc.OutputToString()).To(ContainSubstring(`"vlan": "9"`))
})

Expand All @@ -523,6 +523,7 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--internal", net})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(net)
// Cannot ExitCleanly(): "dnsname and internal networks are incompatible"
Expect(nc).Should(Exit(0))
// Not performing this check on remote tests because it is a logrus error which does
// not come back via stderr on the remote client.
Expand All @@ -531,7 +532,7 @@ var _ = Describe("Podman network create", func() {
}
nc = podmanTest.Podman([]string{"network", "inspect", net})
nc.WaitWithDefaultTimeout()
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())
Expect(nc.OutputToString()).ToNot(ContainSubstring("dnsname"))
})

Expand All @@ -541,15 +542,15 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--internal", net})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(net)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())
// Not performing this check on remote tests because it is a logrus error which does
// not come back via stderr on the remote client.
if !IsRemote() {
Expect(nc.ErrorToString()).To(BeEmpty())
}
nc = podmanTest.Podman([]string{"network", "inspect", net})
nc.WaitWithDefaultTimeout()
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())
Expect(nc.OutputToString()).To(ContainSubstring(`"dns_enabled": true`))
})

Expand All @@ -569,12 +570,12 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet1, "--subnet", subnet2, name})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(name)
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(Equal(name))

inspect := podmanTest.Podman([]string{"network", "inspect", name})
inspect.WaitWithDefaultTimeout()
Expect(inspect).To(Exit(0))
Expect(inspect).To(ExitCleanly())
Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet1))
Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet2))
Expect(inspect.OutputToString()).To(ContainSubstring(`"ipv6_enabled": false`))
Expand All @@ -587,12 +588,12 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet1, "--subnet", subnet2, name})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(name)
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(Equal(name))

inspect := podmanTest.Podman([]string{"network", "inspect", name})
inspect.WaitWithDefaultTimeout()
Expect(inspect).To(Exit(0))
Expect(inspect).To(ExitCleanly())
Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet1))
Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet2))
Expect(inspect.OutputToString()).To(ContainSubstring(`"ipv6_enabled": true`))
Expand All @@ -608,12 +609,12 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet1, "--gateway", gw1, "--ip-range", range1, "--subnet", subnet2, "--gateway", gw2, name})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(name)
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(Equal(name))

inspect := podmanTest.Podman([]string{"network", "inspect", name})
inspect.WaitWithDefaultTimeout()
Expect(inspect).To(Exit(0))
Expect(inspect).To(ExitCleanly())
Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet1))
Expect(inspect.OutputToString()).To(ContainSubstring(`"gateway": "` + gw1))
Expect(inspect.OutputToString()).To(ContainSubstring(`"start_ip": "10.10.3.1",`))
Expand Down Expand Up @@ -647,7 +648,7 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman(networkCreateCommand)
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(name)
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(Equal(name))

nc = podmanTest.Podman(networkCreateCommand)
Expand All @@ -661,12 +662,12 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman(networkCreateCommand)
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(name)
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(Equal(name))

nc = podmanTest.Podman(networkCreateCommand)
nc.WaitWithDefaultTimeout()
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(Equal(name))
})

Expand All @@ -676,17 +677,17 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--interface-name", bridgeName, netName})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).To(Exit(0))
Expect(nc).To(ExitCleanly())
Expect(nc.OutputToString()).To(Equal(netName))

session := podmanTest.Podman([]string{"network", "inspect", "--format", "{{.NetworkInterface}}", netName})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
Expect(session).To(ExitCleanly())
Expect(session.OutputToString()).To(Equal(bridgeName))

session = podmanTest.Podman([]string{"run", "-d", "--network", netName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
Expect(session).To(ExitCleanly())

// can only check this as root
if !isRootless() {
Expand All @@ -702,12 +703,12 @@ var _ = Describe("Podman network create", func() {
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.16.0/24", "--ip-range", "10.11.16.11-10.11.16.12", netName})
nc.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(netName)
Expect(nc).Should(Exit(0))
Expect(nc).Should(ExitCleanly())

// Inspect the network configuration
inspect := podmanTest.Podman([]string{"network", "inspect", netName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())

// JSON the network configuration into something usable
var results []types.Network
Expand All @@ -725,7 +726,7 @@ var _ = Describe("Podman network create", func() {

try := podmanTest.Podman([]string{"run", "--rm", "--network", netName, ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"})
try.WaitWithDefaultTimeout()
Expect(try).To(Exit(0))
Expect(try).To(ExitCleanly())

containerIP, _, err := net.ParseCIDR(try.OutputToString())
Expect(err).ToNot(HaveOccurred())
Expand Down
Loading

0 comments on commit 0293e64

Please sign in to comment.