summaryrefslogtreecommitdiff
path: root/libpod/network/create_test.go
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-08-16 16:11:26 +0200
committerPaul Holzinger <pholzing@redhat.com>2021-09-15 20:00:20 +0200
commit85e8fbf7f33717ef6a0d6cf9e2143b52c874c2de (patch)
tree82b0c29102d2779c18ea8a6f10df5dc1139e3817 /libpod/network/create_test.go
parent218f132fdf4939d9e0374ef860d534f19e71df54 (diff)
downloadpodman-85e8fbf7f33717ef6a0d6cf9e2143b52c874c2de.tar.gz
podman-85e8fbf7f33717ef6a0d6cf9e2143b52c874c2de.tar.bz2
podman-85e8fbf7f33717ef6a0d6cf9e2143b52c874c2de.zip
Wire network interface into libpod
Make use of the new network interface in libpod. This commit contains several breaking changes: - podman network create only outputs the new network name and not file path. - podman network ls shows the network driver instead of the cni version and plugins. - podman network inspect outputs the new network struct and not the cni conflist. - The bindings and libpod api endpoints have been changed to use the new network structure. The container network status is stored in a new field in the state. The status should be received with the new `c.getNetworkStatus`. This will migrate the old status to the new format. Therefore old containers should contine to work correctly in all cases even when network connect/ disconnect is used. New features: - podman network reload keeps the ip and mac for more than one network. - podman container restore keeps the ip and mac for more than one network. - The network create compat endpoint can now use more than one ipam config. The man pages and the swagger doc are updated to reflect the latest changes. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/network/create_test.go')
-rw-r--r--libpod/network/create_test.go130
1 files changed, 0 insertions, 130 deletions
diff --git a/libpod/network/create_test.go b/libpod/network/create_test.go
deleted file mode 100644
index c3824bd91..000000000
--- a/libpod/network/create_test.go
+++ /dev/null
@@ -1,130 +0,0 @@
-package network
-
-import (
- "net"
- "testing"
-
- "github.com/containers/podman/v3/pkg/domain/entities"
-)
-
-func Test_validateBridgeOptions(t *testing.T) {
- tests := []struct {
- name string
- subnet net.IPNet
- ipRange net.IPNet
- gateway net.IP
- isIPv6 bool
- wantErr bool
- }{
- {
- name: "IPv4 subnet only",
- subnet: net.IPNet{IP: net.IPv4(192, 168, 0, 0), Mask: net.IPv4Mask(255, 255, 255, 0)},
- },
- {
- name: "IPv4 subnet and range",
- subnet: net.IPNet{IP: net.IPv4(192, 168, 0, 0), Mask: net.IPv4Mask(255, 255, 255, 0)},
- ipRange: net.IPNet{IP: net.IPv4(192, 168, 0, 128), Mask: net.IPv4Mask(255, 255, 255, 128)},
- },
- {
- name: "IPv4 subnet and gateway",
- subnet: net.IPNet{IP: net.IPv4(192, 168, 0, 0), Mask: net.IPv4Mask(255, 255, 255, 0)},
- gateway: net.ParseIP("192.168.0.10"),
- },
- {
- name: "IPv4 subnet, range and gateway",
- subnet: net.IPNet{IP: net.IPv4(192, 168, 0, 0), Mask: net.IPv4Mask(255, 255, 255, 0)},
- ipRange: net.IPNet{IP: net.IPv4(192, 168, 0, 128), Mask: net.IPv4Mask(255, 255, 255, 128)},
- gateway: net.ParseIP("192.168.0.10"),
- },
- {
- name: "IPv6 subnet only",
- subnet: net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
- },
- {
- name: "IPv6 subnet and range",
- subnet: net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
- ipRange: net.IPNet{IP: net.ParseIP("2001:DB8:0:0:1::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff:ffff::"))},
- isIPv6: true,
- },
- {
- name: "IPv6 subnet and gateway",
- subnet: net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
- gateway: net.ParseIP("2001:DB8::2"),
- isIPv6: true,
- },
- {
- name: "IPv6 subnet, range and gateway",
- subnet: net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
- ipRange: net.IPNet{IP: net.ParseIP("2001:DB8:0:0:1::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff:ffff::"))},
- gateway: net.ParseIP("2001:DB8::2"),
- isIPv6: true,
- },
- {
- name: "IPv6 subnet, range and gateway without IPv6 option (PODMAN SUPPORTS IT UNLIKE DOCKER)",
- subnet: net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
- ipRange: net.IPNet{IP: net.ParseIP("2001:DB8:0:0:1::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff:ffff::"))},
- gateway: net.ParseIP("2001:DB8::2"),
- isIPv6: false,
- },
- {
- name: "range provided but not subnet",
- ipRange: net.IPNet{IP: net.IPv4(192, 168, 0, 128), Mask: net.IPv4Mask(255, 255, 255, 128)},
- wantErr: true,
- },
- {
- name: "gateway provided but not subnet",
- gateway: net.ParseIP("192.168.0.10"),
- wantErr: true,
- },
- {
- name: "IPv4 subnet but IPv6 required",
- subnet: net.IPNet{IP: net.IPv4(192, 168, 0, 0), Mask: net.IPv4Mask(255, 255, 255, 0)},
- ipRange: net.IPNet{IP: net.IPv4(192, 168, 0, 128), Mask: net.IPv4Mask(255, 255, 255, 128)},
- gateway: net.ParseIP("192.168.0.10"),
- isIPv6: true,
- wantErr: true,
- },
- {
- name: "IPv6 required but IPv4 options used",
- subnet: net.IPNet{IP: net.IPv4(192, 168, 0, 0), Mask: net.IPv4Mask(255, 255, 255, 0)},
- ipRange: net.IPNet{IP: net.IPv4(192, 168, 0, 128), Mask: net.IPv4Mask(255, 255, 255, 128)},
- gateway: net.ParseIP("192.168.0.10"),
- isIPv6: true,
- wantErr: true,
- },
- {
- name: "IPv6 required but not subnet provided",
- isIPv6: true,
- wantErr: true,
- },
- {
- name: "range out of the subnet",
- subnet: net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
- ipRange: net.IPNet{IP: net.ParseIP("2001:1:1::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff:ffff::"))},
- gateway: net.ParseIP("2001:DB8::2"),
- isIPv6: true,
- wantErr: true,
- },
- {
- name: "gateway out of the subnet",
- subnet: net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
- gateway: net.ParseIP("2001::2"),
- isIPv6: true,
- wantErr: true,
- },
- }
- for _, tt := range tests {
- tt := tt
- t.Run(tt.name, func(t *testing.T) {
- options := entities.NetworkCreateOptions{
- Subnet: tt.subnet,
- Range: tt.ipRange,
- Gateway: tt.gateway,
- IPv6: tt.isIPv6,
- }
- if err := validateBridgeOptions(options); (err != nil) != tt.wantErr {
- t.Errorf("validateBridgeOptions() error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
-}