summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-01-27 15:13:55 +0100
committerPaul Holzinger <pholzing@redhat.com>2022-01-27 16:38:39 +0100
commit6961d912061c81b7a444e7c00163ae240e318c42 (patch)
tree2949cf26bf6a516da58475064e17c932cf273eb6 /test
parent5659b0734c628f3f42fd976b6ce91372be3019ae (diff)
downloadpodman-6961d912061c81b7a444e7c00163ae240e318c42.tar.gz
podman-6961d912061c81b7a444e7c00163ae240e318c42.tar.bz2
podman-6961d912061c81b7a444e7c00163ae240e318c42.zip
network create: allow multiple subnets
podman network create --subnet, --gateway and --ip-range can now be specified multiple times to join the network to more than one subnet. This is very useful if you want to use a dual stack network and assign a fixed ipv4 and ipv6 subnet. The order of the options is important here, the first --gateway/--ip-range will be assigned to the first subnet and so on. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/network_create_test.go78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go
index ade78a308..4a8a24ad7 100644
--- a/test/e2e/network_create_test.go
+++ b/test/e2e/network_create_test.go
@@ -356,4 +356,82 @@ var _ = Describe("Podman network create", func() {
}
})
+ It("podman network create with multiple subnets", func() {
+ name := "subnets-" + stringid.GenerateNonCryptoID()
+ subnet1 := "10.10.0.0/24"
+ subnet2 := "10.10.1.0/24"
+ nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet1, "--subnet", subnet2, name})
+ nc.WaitWithDefaultTimeout()
+ defer podmanTest.removeCNINetwork(name)
+ Expect(nc).To(Exit(0))
+ Expect(nc.OutputToString()).To(Equal(name))
+
+ inspect := podmanTest.Podman([]string{"network", "inspect", name})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect).To(Exit(0))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet1))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet2))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"ipv6_enabled": false`))
+ })
+
+ It("podman network create with multiple subnets dual stack", func() {
+ name := "subnets-" + stringid.GenerateNonCryptoID()
+ subnet1 := "10.10.2.0/24"
+ subnet2 := "fd52:2a5a:747e:3acd::/64"
+ nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet1, "--subnet", subnet2, name})
+ nc.WaitWithDefaultTimeout()
+ defer podmanTest.removeCNINetwork(name)
+ Expect(nc).To(Exit(0))
+ Expect(nc.OutputToString()).To(Equal(name))
+
+ inspect := podmanTest.Podman([]string{"network", "inspect", name})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect).To(Exit(0))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet1))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet2))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"ipv6_enabled": true`))
+ })
+
+ It("podman network create with multiple subnets dual stack with gateway and range", func() {
+ name := "subnets-" + stringid.GenerateNonCryptoID()
+ subnet1 := "10.10.3.0/24"
+ gw1 := "10.10.3.10"
+ range1 := "10.10.3.0/26"
+ subnet2 := "fd52:2a5a:747e:3acd::/64"
+ gw2 := "fd52:2a5a:747e:3acd::10"
+ nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet1, "--gateway", gw1, "--ip-range", range1, "--subnet", subnet2, "--gateway", gw2, name})
+ nc.WaitWithDefaultTimeout()
+ defer podmanTest.removeCNINetwork(name)
+ Expect(nc).To(Exit(0))
+ Expect(nc.OutputToString()).To(Equal(name))
+
+ inspect := podmanTest.Podman([]string{"network", "inspect", name})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect).To(Exit(0))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet1))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"gateway": "` + gw1))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"start_ip": "10.10.3.1",`))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"end_ip": "10.10.3.63"`))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"subnet": "` + subnet2))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"gateway": "` + gw2))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`"ipv6_enabled": true`))
+ })
+
+ It("podman network create invalid options with multiple subnets", func() {
+ name := "subnets-" + stringid.GenerateNonCryptoID()
+ subnet1 := "10.10.3.0/24"
+ gw1 := "10.10.3.10"
+ gw2 := "fd52:2a5a:747e:3acd::10"
+ nc := podmanTest.Podman([]string{"network", "create", "--subnet", subnet1, "--gateway", gw1, "--gateway", gw2, name})
+ nc.WaitWithDefaultTimeout()
+ Expect(nc).To(Exit(125))
+ Expect(nc.ErrorToString()).To(Equal("Error: cannot set more gateways than subnets"))
+
+ range1 := "10.10.3.0/26"
+ range2 := "10.10.3.0/28"
+ nc = podmanTest.Podman([]string{"network", "create", "--subnet", subnet1, "--ip-range", range1, "--ip-range", range2, name})
+ nc.WaitWithDefaultTimeout()
+ Expect(nc).To(Exit(125))
+ Expect(nc.ErrorToString()).To(Equal("Error: cannot set more ranges than subnets"))
+ })
})