summaryrefslogtreecommitdiff
path: root/test/system/500-networking.bats
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-04-19 18:47:32 +0200
committerPaul Holzinger <pholzing@redhat.com>2022-04-22 13:05:53 +0200
commitcf1b0c1965c9cc7f3b6d870720ba78865c8602e4 (patch)
treece4a5f7c43dabcd562488b6a74cb8b1344e6deba /test/system/500-networking.bats
parent128086639c6317c324c32423765c72f38c115f74 (diff)
downloadpodman-cf1b0c1965c9cc7f3b6d870720ba78865c8602e4.tar.gz
podman-cf1b0c1965c9cc7f3b6d870720ba78865c8602e4.tar.bz2
podman-cf1b0c1965c9cc7f3b6d870720ba78865c8602e4.zip
network dis-/connect: update /etc/hosts
When we connect or disconnect from a network we also have to update /etc/hosts to ensure we only have valid entries in there. This also fixes problems with docker-compose since this makes use of network connect/disconnect. Fixes #12533 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'test/system/500-networking.bats')
-rw-r--r--test/system/500-networking.bats15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats
index f57c3dbd7..274af7ec5 100644
--- a/test/system/500-networking.bats
+++ b/test/system/500-networking.bats
@@ -469,9 +469,17 @@ load helpers
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").Aliases}}"
is "$output" "[${cid:0:12}]" "short container id in network aliases"
+ # check /etc/hosts for our entry
+ run_podman exec $cid cat /etc/hosts
+ is "$output" ".*$ip.*" "hosts contain expected ip"
+
run_podman network disconnect $netname $cid
is "$output" "" "Output should be empty (no errors)"
+ # check /etc/hosts again, the entry should be gone now
+ run_podman exec $cid cat /etc/hosts
+ assert "$output" !~ "$ip" "IP ($ip) should no longer be in /etc/hosts"
+
# check that we cannot curl (timeout after 3 sec)
run curl --max-time 3 -s $SERVER/index.txt
assert $status -ne 0 \
@@ -487,13 +495,18 @@ load helpers
# check that we have a new ip and mac
# if the ip is still the same this whole test turns into a nop
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}"
- assert "$output" != "$ip" \
+ new_ip="$output"
+ assert "$new_ip" != "$ip" \
"IP address did not change after podman network disconnect/connect"
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
assert "$output" != "$mac" \
"MAC address did not change after podman network disconnect/connect"
+ # check /etc/hosts for the new entry
+ run_podman exec $cid cat /etc/hosts
+ is "$output" ".*$new_ip.*" "hosts contain expected new ip"
+
# Disconnect/reconnect of a container *with no ports* should succeed quietly
run_podman network disconnect $netname $background_cid
is "$output" "" "disconnect of container with no open ports"