aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-10-09 15:38:45 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-10-09 20:20:19 -0400
commit77033c4aed90b15a567d12036ec636c53e2c8e15 (patch)
tree0cc4e4aa47edde51687a549dd71c97e36fd2230b /test
parentcec240375d6dceb09c705d6d55e67aeff037327f (diff)
downloadpodman-77033c4aed90b15a567d12036ec636c53e2c8e15.tar.gz
podman-77033c4aed90b15a567d12036ec636c53e2c8e15.tar.bz2
podman-77033c4aed90b15a567d12036ec636c53e2c8e15.zip
Include CNI networks in inspect output when not running
We were only including the CNI Network fields in the output of `podman inspect` when the container was not running. It's simple enough to fix (populate with empty structs, since we can't fill anything without a CNI response to get IP address assigned, etc). This is necessary for Docker compatibility. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/network_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go
index cbfd72da6..9bd16c008 100644
--- a/test/e2e/network_test.go
+++ b/test/e2e/network_test.go
@@ -211,6 +211,43 @@ var _ = Describe("Podman network", func() {
Expect(rmAll.ExitCode()).To(BeZero())
})
+ It("podman inspect container two CNI networks (container not running)", func() {
+ netName1 := "testNetThreeCNI1"
+ network1 := podmanTest.Podman([]string{"network", "create", netName1})
+ network1.WaitWithDefaultTimeout()
+ Expect(network1.ExitCode()).To(BeZero())
+ defer podmanTest.removeCNINetwork(netName1)
+
+ netName2 := "testNetThreeCNI2"
+ network2 := podmanTest.Podman([]string{"network", "create", netName2})
+ network2.WaitWithDefaultTimeout()
+ Expect(network2.ExitCode()).To(BeZero())
+ defer podmanTest.removeCNINetwork(netName2)
+
+ ctrName := "testCtr"
+ container := podmanTest.Podman([]string{"create", "--network", fmt.Sprintf("%s,%s", netName1, netName2), "--name", ctrName, ALPINE, "top"})
+ container.WaitWithDefaultTimeout()
+ Expect(container.ExitCode()).To(BeZero())
+
+ inspect := podmanTest.Podman([]string{"inspect", ctrName})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(BeZero())
+ conData := inspect.InspectContainerToJSON()
+ Expect(len(conData)).To(Equal(1))
+ Expect(len(conData[0].NetworkSettings.Networks)).To(Equal(2))
+ net1, ok := conData[0].NetworkSettings.Networks[netName1]
+ Expect(ok).To(BeTrue())
+ Expect(net1.NetworkID).To(Equal(netName1))
+ net2, ok := conData[0].NetworkSettings.Networks[netName2]
+ Expect(ok).To(BeTrue())
+ Expect(net2.NetworkID).To(Equal(netName2))
+
+ // Necessary to ensure the CNI network is removed cleanly
+ rmAll := podmanTest.Podman([]string{"rm", "-f", ctrName})
+ rmAll.WaitWithDefaultTimeout()
+ Expect(rmAll.ExitCode()).To(BeZero())
+ })
+
It("podman inspect container two CNI networks", func() {
netName1 := "testNetTwoCNI1"
network1 := podmanTest.Podman([]string{"network", "create", "--subnet", "10.50.51.0/25", netName1})