aboutsummaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-02-17 16:49:59 -0500
committerMatthew Heon <matthew.heon@pm.me>2020-02-19 11:29:30 -0500
commit97323808ed57cf52311a80c55339f8927614b7f0 (patch)
treedf628e8025ef95e142e5cab891ab93fcb42b35e5 /test/e2e
parent666d8cf1deeba4113a9b03e0bc208b1a14122733 (diff)
downloadpodman-97323808ed57cf52311a80c55339f8927614b7f0.tar.gz
podman-97323808ed57cf52311a80c55339f8927614b7f0.tar.bz2
podman-97323808ed57cf52311a80c55339f8927614b7f0.zip
Add network options to podman pod create
Enables most of the network-related functionality from `podman run` in `podman pod create`. Custom CNI networks can be specified, host networking is supported, DNS options can be configured. Also enables host networking in `podman play kube`. Fixes #2808 Fixes #3837 Fixes #4432 Fixes #4718 Fixes #4770 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/pod_create_test.go165
1 files changed, 165 insertions, 0 deletions
diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go
index 2efa36141..e0a10c202 100644
--- a/test/e2e/pod_create_test.go
+++ b/test/e2e/pod_create_test.go
@@ -1,7 +1,9 @@
package integration
import (
+ "fmt"
"os"
+ "strings"
. "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
@@ -117,4 +119,167 @@ var _ = Describe("Podman pod create", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(125))
})
+
+ It("podman create pod with --no-hosts", func() {
+ SkipIfRemote()
+ name := "test"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--no-hosts", "--name", name})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(0))
+
+ alpineResolvConf := podmanTest.Podman([]string{"run", "-ti", "--rm", "--no-hosts", ALPINE, "cat", "/etc/hosts"})
+ alpineResolvConf.WaitWithDefaultTimeout()
+ Expect(alpineResolvConf.ExitCode()).To(Equal(0))
+
+ podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/hosts"})
+ podResolvConf.WaitWithDefaultTimeout()
+ Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(podResolvConf.OutputToString()).To(Equal(alpineResolvConf.OutputToString()))
+ })
+
+ It("podman create pod with --no-hosts and no infra should fail", func() {
+ SkipIfRemote()
+ name := "test"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--no-hosts", "--name", name, "--infra=false"})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(125))
+ })
+
+ It("podman create pod with --add-host", func() {
+ SkipIfRemote()
+ name := "test"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--add-host", "test.example.com:12.34.56.78", "--name", name})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(0))
+
+ podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/hosts"})
+ podResolvConf.WaitWithDefaultTimeout()
+ Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(strings.Contains(podResolvConf.OutputToString(), "12.34.56.78 test.example.com")).To(BeTrue())
+ })
+
+ It("podman create pod with --add-host and no infra should fail", func() {
+ SkipIfRemote()
+ name := "test"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--add-host", "test.example.com:12.34.56.78", "--name", name, "--infra=false"})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(125))
+ })
+
+ It("podman create pod with DNS server set", func() {
+ SkipIfRemote()
+ name := "test"
+ server := "12.34.56.78"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--dns", server, "--name", name})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(0))
+
+ podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/resolv.conf"})
+ podResolvConf.WaitWithDefaultTimeout()
+ Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(strings.Contains(podResolvConf.OutputToString(), fmt.Sprintf("nameserver %s", server))).To(BeTrue())
+ })
+
+ It("podman create pod with DNS server set and no infra should fail", func() {
+ SkipIfRemote()
+ name := "test"
+ server := "12.34.56.78"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--dns", server, "--name", name, "--infra=false"})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(125))
+ })
+
+ It("podman create pod with DNS option set", func() {
+ SkipIfRemote()
+ name := "test"
+ option := "attempts:5"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--dns-opt", option, "--name", name})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(0))
+
+ podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/resolv.conf"})
+ podResolvConf.WaitWithDefaultTimeout()
+ Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(strings.Contains(podResolvConf.OutputToString(), fmt.Sprintf("options %s", option))).To(BeTrue())
+ })
+
+ It("podman create pod with DNS option set and no infra should fail", func() {
+ SkipIfRemote()
+ name := "test"
+ option := "attempts:5"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--dns-opt", option, "--name", name, "--infra=false"})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(125))
+ })
+
+ It("podman create pod with DNS search domain set", func() {
+ SkipIfRemote()
+ name := "test"
+ search := "example.com"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--dns-search", search, "--name", name})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(0))
+
+ podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "cat", "/etc/resolv.conf"})
+ podResolvConf.WaitWithDefaultTimeout()
+ Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(strings.Contains(podResolvConf.OutputToString(), fmt.Sprintf("search %s", search))).To(BeTrue())
+ })
+
+ It("podman create pod with DNS search domain set and no infra should fail", func() {
+ SkipIfRemote()
+ name := "test"
+ search := "example.com"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--dns-search", search, "--name", name, "--infra=false"})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(125))
+ })
+
+ It("podman create pod with IP address", func() {
+ SkipIfRemote()
+ SkipIfRootless()
+ name := "test"
+ ip := GetRandomIPAddress()
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--ip", ip, "--name", name})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(0))
+
+ podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "ip", "addr"})
+ podResolvConf.WaitWithDefaultTimeout()
+ Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(strings.Contains(podResolvConf.OutputToString(), ip)).To(BeTrue())
+ })
+
+ It("podman create pod with IP address and no infra should fail", func() {
+ SkipIfRemote()
+ name := "test"
+ ip := GetRandomIPAddress()
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--ip", ip, "--name", name, "--infra=false"})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(125))
+ })
+
+ It("podman create pod with MAC address", func() {
+ SkipIfRemote()
+ SkipIfRootless()
+ name := "test"
+ mac := "92:d0:c6:0a:29:35"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--mac-address", mac, "--name", name})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(0))
+
+ podResolvConf := podmanTest.Podman([]string{"run", "--pod", name, "-ti", "--rm", ALPINE, "ip", "addr"})
+ podResolvConf.WaitWithDefaultTimeout()
+ Expect(podResolvConf.ExitCode()).To(Equal(0))
+ Expect(strings.Contains(podResolvConf.OutputToString(), mac)).To(BeTrue())
+ })
+
+ It("podman create pod with MAC address and no infra should fail", func() {
+ SkipIfRemote()
+ name := "test"
+ mac := "92:d0:c6:0a:29:35"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--mac-address", mac, "--name", name, "--infra=false"})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate.ExitCode()).To(Equal(125))
+ })
})