aboutsummaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-02-20 13:34:51 -0500
committerMatthew Heon <matthew.heon@pm.me>2020-02-25 13:20:25 -0500
commitf9fc9a7b7b0e5633cf279273b614a5d3e4c68906 (patch)
tree3e089830787caf5276424aec748326b7fe569c3e /test/e2e
parent3d37dc639d87e4469a6457cf4592ff5b773d0777 (diff)
downloadpodman-f9fc9a7b7b0e5633cf279273b614a5d3e4c68906.tar.gz
podman-f9fc9a7b7b0e5633cf279273b614a5d3e4c68906.tar.bz2
podman-f9fc9a7b7b0e5633cf279273b614a5d3e4c68906.zip
Add support for multiple CNI networks in podman inspect
When inspecting containers, info on CNI networks added to the container by name (e.g. --net=name1) should be displayed separately from the configuration of the default network, in a separate map called Networks. This patch adds this separation, improving our Docker compatibility and also adding the ability to see if a container has more than one IPv4 and IPv6 address and more than one MAC address. Fixes #4907 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/network_test.go80
1 files changed, 77 insertions, 3 deletions
diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go
index 9aed5351a..440d307b5 100644
--- a/test/e2e/network_test.go
+++ b/test/e2e/network_test.go
@@ -4,13 +4,15 @@ package integration
import (
"fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+
. "github.com/containers/libpod/test/utils"
"github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "io/ioutil"
- "os"
- "path/filepath"
)
func writeConf(conf []byte, confPath string) {
@@ -155,4 +157,76 @@ var _ = Describe("Podman network", func() {
Expect(session.IsJSONOutputValid()).To(BeTrue())
})
+ It("podman inspect container single CNI network", func() {
+ SkipIfRootless()
+ netName := "testNetSingleCNI"
+ network := podmanTest.Podman([]string{"network", "create", "--subnet", "10.50.50.0/24", netName})
+ network.WaitWithDefaultTimeout()
+ Expect(network.ExitCode()).To(BeZero())
+ defer podmanTest.removeCNINetwork(netName)
+
+ ctrName := "testCtr"
+ container := podmanTest.Podman([]string{"run", "-dt", "--network", netName, "--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(1))
+ net, ok := conData[0].NetworkSettings.Networks[netName]
+ Expect(ok).To(BeTrue())
+ Expect(net.NetworkID).To(Equal(netName))
+ Expect(net.IPPrefixLen).To(Equal(24))
+ Expect(strings.HasPrefix(net.IPAddress, "10.50.50.")).To(BeTrue())
+
+ // 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() {
+ SkipIfRootless()
+ netName1 := "testNetTwoCNI1"
+ network1 := podmanTest.Podman([]string{"network", "create", "--subnet", "10.50.51.0/25", netName1})
+ network1.WaitWithDefaultTimeout()
+ Expect(network1.ExitCode()).To(BeZero())
+ defer podmanTest.removeCNINetwork(netName1)
+
+ netName2 := "testNetTwoCNI2"
+ network2 := podmanTest.Podman([]string{"network", "create", "--subnet", "10.50.51.128/26", netName2})
+ network2.WaitWithDefaultTimeout()
+ Expect(network2.ExitCode()).To(BeZero())
+ defer podmanTest.removeCNINetwork(netName2)
+
+ ctrName := "testCtr"
+ container := podmanTest.Podman([]string{"run", "-dt", "--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))
+ Expect(net1.IPPrefixLen).To(Equal(25))
+ Expect(strings.HasPrefix(net1.IPAddress, "10.50.51.")).To(BeTrue())
+ net2, ok := conData[0].NetworkSettings.Networks[netName2]
+ Expect(ok).To(BeTrue())
+ Expect(net2.NetworkID).To(Equal(netName2))
+ Expect(net2.IPPrefixLen).To(Equal(26))
+ Expect(strings.HasPrefix(net2.IPAddress, "10.50.51.")).To(BeTrue())
+
+ // Necessary to ensure the CNI network is removed cleanly
+ rmAll := podmanTest.Podman([]string{"rm", "-f", ctrName})
+ rmAll.WaitWithDefaultTimeout()
+ Expect(rmAll.ExitCode()).To(BeZero())
+ })
})