summaryrefslogtreecommitdiff
path: root/libpod/network/cni/config_test.go
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-09-16 14:03:49 +0200
committerPaul Holzinger <pholzing@redhat.com>2021-09-16 14:53:33 +0200
commitc20f61148cfc7c51f72bf266e154d1903db68c6a (patch)
treec12439f97a2c9ba211273cd24421964dfe5febc3 /libpod/network/cni/config_test.go
parent9119a578e782b92bd344f093f5491c318bc20d69 (diff)
downloadpodman-c20f61148cfc7c51f72bf266e154d1903db68c6a.tar.gz
podman-c20f61148cfc7c51f72bf266e154d1903db68c6a.tar.bz2
podman-c20f61148cfc7c51f72bf266e154d1903db68c6a.zip
CNI: network create support macvlan modes
Support setting the macvlan mode with `podman network create -d macvlan --opt mode=bridge`. This will correctly set the specified macvlan mode in the cni conflist file. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/network/cni/config_test.go')
-rw-r--r--libpod/network/cni/config_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/libpod/network/cni/config_test.go b/libpod/network/cni/config_test.go
index 11ad71870..62b6ef837 100644
--- a/libpod/network/cni/config_test.go
+++ b/libpod/network/cni/config_test.go
@@ -250,6 +250,39 @@ var _ = Describe("Config", func() {
grepInFile(path, `"type": "host-local"`)
})
+ It("create macvlan config with mode", func() {
+ for _, mode := range []string{"bridge", "private", "vepa", "passthru"} {
+ network := types.Network{
+ Driver: "macvlan",
+ Options: map[string]string{
+ "mode": mode,
+ },
+ }
+ network1, err := libpodNet.NetworkCreate(network)
+ Expect(err).To(BeNil())
+ Expect(network1.Name).ToNot(BeEmpty())
+ path := filepath.Join(cniConfDir, network1.Name+".conflist")
+ Expect(path).To(BeARegularFile())
+ Expect(network1.Driver).To(Equal("macvlan"))
+ Expect(network1.Options).To(HaveKeyWithValue("mode", mode))
+ Expect(network1.IPAMOptions).ToNot(BeEmpty())
+ Expect(network1.IPAMOptions).To(HaveKeyWithValue("driver", "dhcp"))
+ grepInFile(path, `"mode": "`+mode+`"`)
+ }
+ })
+
+ It("create macvlan config with invalid mode", func() {
+ network := types.Network{
+ Driver: "macvlan",
+ Options: map[string]string{
+ "mode": "test",
+ },
+ }
+ _, err := libpodNet.NetworkCreate(network)
+ Expect(err).To(HaveOccurred())
+ Expect(err.Error()).To(ContainSubstring(`unknown macvlan mode "test"`))
+ })
+
It("create macvlan config with invalid device", func() {
network := types.Network{
Driver: "macvlan",