summaryrefslogtreecommitdiff
path: root/test/system/500-networking.bats
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 /test/system/500-networking.bats
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 'test/system/500-networking.bats')
-rw-r--r--test/system/500-networking.bats73
1 files changed, 49 insertions, 24 deletions
diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats
index bdedfae19..ef00d0366 100644
--- a/test/system/500-networking.bats
+++ b/test/system/500-networking.bats
@@ -6,7 +6,7 @@
load helpers
@test "podman network - basic tests" {
- heading="*NETWORK*ID*NAME*VERSION*PLUGINS*"
+ heading="*NETWORK*ID*NAME*DRIVER*"
run_podman network ls
if [[ ${output} != ${heading} ]]; then
die "network ls expected heading is not available"
@@ -151,7 +151,7 @@ load helpers
local mysubnet=$(random_rfc1918_subnet)
run_podman network create --subnet "${mysubnet}.0/24" $mynetname
- is "$output" ".*/cni/net.d/$mynetname.conflist" "output of 'network create'"
+ is "$output" "$mynetname" "output of 'network create'"
# (Assert that output is formatted, not a one-line blob: #8011)
run_podman network inspect $mynetname
@@ -189,7 +189,7 @@ load helpers
# Cannot create network with the same name
run_podman 125 network create $mynetname
- is "$output" "Error: the network name $mynetname is already used" \
+ is "$output" "Error: network name $mynetname already used: network already exists" \
"Trying to create an already-existing network"
run_podman rm $cid
@@ -208,14 +208,8 @@ load helpers
INDEX1=$PODMAN_TMPDIR/hello.txt
echo $random_1 > $INDEX1
- # use default network for root
+ # use default network
local netname=podman
- # for rootless we have to create a custom network since there is no default network
- if is_rootless; then
- netname=testnet-$(random_string 10)
- run_podman network create $netname
- is "$output" ".*/cni/net.d/$netname.conflist" "output of 'network create'"
- fi
# Bind-mount this file with a different name to a container running httpd
run_podman run -d --name myweb -p "$HOST_PORT:80" \
@@ -226,9 +220,9 @@ load helpers
cid=$output
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}"
- ip="$output"
+ ip1="$output"
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
- mac="$output"
+ mac1="$output"
# Verify http contents: curl from localhost
run curl -s $SERVER/index.txt
@@ -248,22 +242,51 @@ load helpers
# reload the network to recreate the iptables rules
run_podman network reload $cid
- is "$output" "$cid" "Output does not match container ID"
+ is "$output" "$cid" "Output does match container ID"
# check that we still have the same mac and ip
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}"
- is "$output" "$ip" "IP address changed after podman network reload"
+ is "$output" "$ip1" "IP address changed after podman network reload"
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
- is "$output" "$mac" "MAC address changed after podman network reload"
+ is "$output" "$mac1" "MAC address changed after podman network reload"
# check that we can still curl
run curl -s $SERVER/index.txt
is "$output" "$random_1" "curl 127.0.0.1:/index.txt"
+ # create second network
+ netname2=testnet-$(random_string 10)
+ # TODO add --ipv6 and uncomment the ipv6 checks below once cni plugins 1.0 is available on ubuntu CI VMs.
+ run_podman network create $netname2
+ is "$output" "$netname2" "output of 'network create'"
+
+ # connect the container to the second network
+ run_podman network connect $netname2 $cid
+
+ run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}}"
+ ip2="$output"
+ #run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}}"
+ #is "$output" "fd.*:.*" "IPv6 address should start with fd..."
+ #ipv6="$output"
+ run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}"
+ mac2="$output"
+
# make sure --all is working and that this
# cmd also works if the iptables still exists
run_podman network reload --all
- is "$output" "$cid" "Output does not match container ID"
+ is "$output" "$cid" "Output does match container ID"
+
+ # check that both network keep there ip and mac
+ run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}"
+ is "$output" "$ip1" "IP address changed after podman network reload ($netname)"
+ run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
+ is "$output" "$mac1" "MAC address changed after podman network reload ($netname)"
+ run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").IPAddress}}"
+ is "$output" "$ip2" "IP address changed after podman network reload ($netname2)"
+ #run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").GlobalIPv6Address}}"
+ #is "$output" "$ipv6" "IPv6 address changed after podman network reload ($netname2)"
+ run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").MacAddress}}"
+ is "$output" "$mac2" "MAC address changed after podman network reload ($netname2)"
# check that we can still curl
run curl -s $SERVER/index.txt
@@ -272,9 +295,11 @@ load helpers
# cleanup the container
run_podman rm -f $cid
- if is_rootless; then
- run_podman network rm -f $netname
- fi
+ # test that we cannot remove the default network
+ run_podman 125 network rm -f $netname
+ is "$output" "Error: default network $netname cannot be removed" "Remove default network"
+
+ run_podman network rm -f $netname2
}
@test "podman rootless cni adds /usr/sbin to PATH" {
@@ -325,7 +350,7 @@ load helpers
local netname=testnet-$(random_string 10)
run_podman network create --subnet $mysubnet.0/24 $netname
- is "$output" ".*/cni/net.d/$netname.conflist" "output of 'network create'"
+ is "$output" "$netname" "output of 'network create'"
run_podman run --rm --network $netname $IMAGE cat /etc/resolv.conf
if grep -E "$ipv6_regex" <<< $output; then
@@ -339,7 +364,7 @@ load helpers
netname=testnet-$(random_string 10)
run_podman network create --subnet $mysubnet $netname
- is "$output" ".*/cni/net.d/$netname.conflist" "output of 'network create'"
+ is "$output" "$netname" "output of 'network create'"
run_podman run --rm --network $netname $IMAGE cat /etc/resolv.conf
# "is" does not like the ipv6 regex
@@ -362,11 +387,11 @@ load helpers
local netname=testnet-$(random_string 10)
run_podman network create $netname
- is "$output" ".*/cni/net.d/$netname.conflist" "output of 'network create'"
+ is "$output" "$netname" "output of 'network create'"
local netname2=testnet2-$(random_string 10)
run_podman network create $netname2
- is "$output" ".*/cni/net.d/$netname2.conflist" "output of 'network create'"
+ is "$output" "$netname2" "output of 'network create'"
# First, run a container in background to ensure that the rootless cni ns
# is not destroyed after network disconnect.
@@ -447,7 +472,7 @@ load helpers
local netname=testnet-$(random_string 10)
run_podman network create $netname
- is "$output" ".*/cni/net.d/$netname.conflist" "output of 'network create'"
+ is "$output" "$netname" "output of 'network create'"
for network in "slirp4netns" "$netname"; do
# Start container with the restart always policy