diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-11-17 12:45:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 12:45:50 +0100 |
commit | 7d067afac716927b26c452d4d75478b9f13abd62 (patch) | |
tree | fce10e3d5f3aa0d0ec9470c70af02e728cd79067 /test | |
parent | d30f9ae8b6a21fbef6704e372e9ec74fc689875e (diff) | |
parent | 4ca4234af1aa02c80bf44fe8cca6b5a4e62be2c6 (diff) | |
download | podman-7d067afac716927b26c452d4d75478b9f13abd62.tar.gz podman-7d067afac716927b26c452d4d75478b9f13abd62.tar.bz2 podman-7d067afac716927b26c452d4d75478b9f13abd62.zip |
Merge pull request #8347 from rhatdan/hostname
Make sure /etc/hosts populated correctly with networks
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/run_networking_test.go | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index e9c1bab21..3e80e953e 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -551,6 +551,10 @@ var _ = Describe("Podman run networking", func() { run.WaitWithDefaultTimeout() Expect(run.ExitCode()).To(BeZero()) Expect(run.OutputToString()).To(ContainSubstring(ipAddr)) + + create = podmanTest.Podman([]string{"network", "rm", netName}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(BeZero()) }) It("podman run with new:pod and static-ip", func() { @@ -588,7 +592,7 @@ var _ = Describe("Podman run networking", func() { Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) }) - It("podman run with --net=none adds hostname to /etc/hosts", func() { + It("podman run with --net=none sets hostname", func() { hostname := "testctr" run := podmanTest.Podman([]string{"run", "--net=none", "--hostname", hostname, ALPINE, "hostname"}) run.WaitWithDefaultTimeout() @@ -596,6 +600,37 @@ var _ = Describe("Podman run networking", func() { Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) }) + It("podman run with --net=none adds hostname to /etc/hosts", func() { + hostname := "testctr" + run := podmanTest.Podman([]string{"run", "--net=none", "--hostname", hostname, ALPINE, "cat", "/etc/hosts"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(BeZero()) + Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) + }) + + ping_test := func(netns string) { + hostname := "testctr" + run := podmanTest.Podman([]string{"run", netns, "--hostname", hostname, ALPINE, "ping", "-c", "1", hostname}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(BeZero()) + + run = podmanTest.Podman([]string{"run", netns, "--hostname", hostname, "--name", "test", ALPINE, "ping", "-c", "1", "test"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(BeZero()) + } + + It("podman attempt to ping container name and hostname --net=none", func() { + ping_test("--net=none") + }) + + It("podman attempt to ping container name and hostname --net=host", func() { + ping_test("--net=host") + }) + + It("podman attempt to ping container name and hostname --net=private", func() { + ping_test("--net=private") + }) + It("podman run check dnsname plugin", func() { pod := "testpod" session := podmanTest.Podman([]string{"pod", "create", "--name", pod}) @@ -621,10 +656,10 @@ var _ = Describe("Podman run networking", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(BeZero()) - session = podmanTest.Podman([]string{"run", "--name", "con3", "--pod", pod2, ALPINE, "nslookup", "con3"}) + session = podmanTest.Podman([]string{"run", "--name", "con3", "--pod", pod2, ALPINE, "nslookup", "con1"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(1)) - Expect(session.ErrorToString()).To(ContainSubstring("can't resolve 'con3'")) + Expect(session.ErrorToString()).To(ContainSubstring("can't resolve 'con1'")) session = podmanTest.Podman([]string{"run", "--name", "con4", "--network", net, ALPINE, "nslookup", pod2}) session.WaitWithDefaultTimeout() |