diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-22 16:56:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 16:56:43 -0500 |
commit | d999328920ce826e5d1ef824c811374bb65ce26b (patch) | |
tree | 12952a1caffc6e2bfae40ec17ff36a66521b16d3 /test/e2e | |
parent | c69decc305d746066824701ff073d5b34b744693 (diff) | |
parent | 9d818be7329929b05b93e432c408ee65726ec2c0 (diff) | |
download | podman-d999328920ce826e5d1ef824c811374bb65ce26b.tar.gz podman-d999328920ce826e5d1ef824c811374bb65ce26b.tar.bz2 podman-d999328920ce826e5d1ef824c811374bb65ce26b.zip |
Merge pull request #9455 from Luap99/fix-network-ids
Fix podman network IDs handling
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/create_test.go | 12 | ||||
-rw-r--r-- | test/e2e/network_connect_disconnect_test.go | 85 |
2 files changed, 94 insertions, 3 deletions
diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 43da95a9d..1f1786dbe 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -9,6 +9,7 @@ import ( "strings" . "github.com/containers/podman/v3/test/utils" + "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -576,15 +577,20 @@ var _ = Describe("Podman create", func() { Expect(session.ExitCode()).ToNot(BeZero()) }) - It("create container in pod with network should fail", func() { + It("create container in pod with network should not fail", func() { name := "createwithnetwork" pod := podmanTest.RunTopContainerInPod("", "new:"+name) pod.WaitWithDefaultTimeout() Expect(pod.ExitCode()).To(BeZero()) - session := podmanTest.Podman([]string{"create", "--pod", name, "--network", "foobar", ALPINE, "top"}) + netName := "pod" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + session = podmanTest.Podman([]string{"create", "--pod", name, "--network", netName, ALPINE, "top"}) session.WaitWithDefaultTimeout() - //Expect(session.ExitCode()).ToNot(BeZero()) Expect(session.ExitCode()).To(BeZero()) }) diff --git a/test/e2e/network_connect_disconnect_test.go b/test/e2e/network_connect_disconnect_test.go index ab42a592f..3be95e254 100644 --- a/test/e2e/network_connect_disconnect_test.go +++ b/test/e2e/network_connect_disconnect_test.go @@ -195,6 +195,55 @@ var _ = Describe("Podman network connect and disconnect", func() { Expect(exec.ExitCode()).To(BeZero()) }) + It("podman network connect and run with network ID", func() { + SkipIfRemote("remote flakes to much I will fix this in another PR") + SkipIfRootless("network connect and disconnect are only rootful") + netName := "ID" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + session = podmanTest.Podman([]string{"network", "ls", "--format", "{{.ID}}", "--filter", "name=" + netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + netID := session.OutputToString() + + ctr := podmanTest.Podman([]string{"run", "-dt", "--name", "test", "--network", netID, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + + // Create a second network + newNetName := "ID2" + stringid.GenerateNonCryptoID() + session = podmanTest.Podman([]string{"network", "create", newNetName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(newNetName) + + session = podmanTest.Podman([]string{"network", "ls", "--format", "{{.ID}}", "--filter", "name=" + newNetName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + newNetID := session.OutputToString() + + connect := podmanTest.Podman([]string{"network", "connect", newNetID, "test"}) + connect.WaitWithDefaultTimeout() + Expect(connect.ExitCode()).To(BeZero()) + + inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{.NetworkSettings.Networks}}"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(BeZero()) + Expect(inspect.OutputToString()).To(ContainSubstring(netName)) + Expect(inspect.OutputToString()).To(ContainSubstring(newNetName)) + + exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + }) + It("podman network disconnect when not running", func() { SkipIfRootless("network connect and disconnect are only rootful") netName1 := "aliasTest" + stringid.GenerateNonCryptoID() @@ -234,4 +283,40 @@ var _ = Describe("Podman network connect and disconnect", func() { exec.WaitWithDefaultTimeout() Expect(exec.ExitCode()).ToNot(BeZero()) }) + + It("podman network disconnect and run with network ID", func() { + SkipIfRemote("remote flakes to much I will fix this in another PR") + SkipIfRootless("network connect and disconnect are only rootful") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + session = podmanTest.Podman([]string{"network", "ls", "--format", "{{.ID}}", "--filter", "name=" + netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + netID := session.OutputToString() + + ctr := podmanTest.Podman([]string{"run", "-dt", "--name", "test", "--network", netID, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + + dis := podmanTest.Podman([]string{"network", "disconnect", netID, "test"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).To(BeZero()) + + inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(BeZero()) + Expect(inspect.OutputToString()).To(Equal("0")) + + exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).ToNot(BeZero()) + }) }) |