From c93ad3762c402c56d6cbb1c7a6f1202b4962eeb4 Mon Sep 17 00:00:00 2001
From: Matthew Heon <mheon@redhat.com>
Date: Tue, 11 Dec 2018 18:05:25 -0500
Subject: Add test for sharing resolv and hosts with netns

Signed-off-by: Matthew Heon <mheon@redhat.com>
---
 test/e2e/run_networking_test.go | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

(limited to 'test')

diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index 1b05ac031..68b1f06de 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -9,7 +9,7 @@ import (
 	. "github.com/onsi/gomega"
 )
 
-var _ = Describe("Podman rmi", func() {
+var _ = Describe("Podman run networking", func() {
 	var (
 		tempdir     string
 		err         error
@@ -145,4 +145,35 @@ var _ = Describe("Podman rmi", func() {
 		match, _ := session.GrepString("foobar")
 		Expect(match).Should(BeTrue())
 	})
+
+	It("podman run --net container: copies hosts and resolv", func() {
+		ctrName := "ctr1"
+		ctr1 := podmanTest.RunTopContainer(ctrName)
+		ctr1.WaitWithDefaultTimeout()
+		Expect(ctr1.ExitCode()).To(Equal(0))
+
+		// Exec in and modify /etc/resolv.conf and /etc/hosts
+		exec1 := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "echo nameserver 192.0.2.1 > /etc/resolv.conf"})
+		exec1.WaitWithDefaultTimeout()
+		Expect(exec1.ExitCode()).To(Equal(0))
+
+		exec2 := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "echo 192.0.2.2 test1 > /etc/hosts"})
+		exec2.WaitWithDefaultTimeout()
+		Expect(exec2.ExitCode()).To(Equal(0))
+
+		ctrName2 := "ctr2"
+		ctr2 := podmanTest.Podman([]string{"run", "-d", "--net=container:" + ctrName, "--name", ctrName2, ALPINE, "top"})
+		ctr2.WaitWithDefaultTimeout()
+		Expect(ctr2.ExitCode()).To(Equal(0))
+
+		exec3 := podmanTest.Podman([]string{"exec", "-i", ctrName2, "cat", "/etc/resolv.conf"})
+		exec3.WaitWithDefaultTimeout()
+		Expect(exec3.ExitCode()).To(Equal(0))
+		Expect(exec3.OutputToString()).To(ContainSubstring("nameserver 192.0.2.1"))
+
+		exec4 := podmanTest.Podman([]string{"exec", "-i", ctrName2, "cat", "/etc/hosts"})
+		exec4.WaitWithDefaultTimeout()
+		Expect(exec4.ExitCode()).To(Equal(0))
+		Expect(exec4.OutputToString()).To(ContainSubstring("192.0.2.2 test1"))
+	})
 })
-- 
cgit v1.2.3-54-g00ecf