mirror of
https://github.com/containers/podman.git
synced 2025-06-21 09:28:09 +08:00
Merge pull request #19053 from edsantiago/pasta_test_cleanup
pasta system tests: cleanup, fixes, sanity check
This commit is contained in:
@ -50,6 +50,68 @@ function pasta_test_do() {
|
|||||||
local bind_type="${6}"
|
local bind_type="${6}"
|
||||||
local bytes="${7}"
|
local bytes="${7}"
|
||||||
|
|
||||||
|
# DO NOT ADD ANY CODE ABOVE THIS LINE! Especially skips: that could
|
||||||
|
# lead to the crossreference check not running in CI.
|
||||||
|
#
|
||||||
|
# BATS has no table-driven test generation mechanism, so there's a
|
||||||
|
# disturbing but unavoidable amount of duplication in the test
|
||||||
|
# invocations. The code below is a desperate sanity check to confirm
|
||||||
|
# that the BATS test name agrees with the parameters we're invoked with.
|
||||||
|
# This test can never, ever fail in gating. It can only fail in CI
|
||||||
|
# when a new test is added, and should be trivial to fix & re-push.
|
||||||
|
#
|
||||||
|
# TODO: a better idea might be to go the other direction: eliminate
|
||||||
|
# the function args entirely, and determine them from $BATS_TEST_NAME.
|
||||||
|
# We would still need a way to get $range and $bytes.
|
||||||
|
local expected_test_name=
|
||||||
|
if [[ $bytes -eq 1 ]]; then
|
||||||
|
# The usual case: a single-byte transfer test. This has many
|
||||||
|
# variations depending on our input args
|
||||||
|
if [[ $range -eq 1 ]]; then
|
||||||
|
# e.g., Single TCP port forwarding, IPv4, loopback
|
||||||
|
if [[ $delta -ne 0 ]]; then
|
||||||
|
expected_test_name+="Translated"
|
||||||
|
elif [[ "${bind_type}" = "port" ]]; then
|
||||||
|
expected_test_name+="Single"
|
||||||
|
else
|
||||||
|
expected_test_name+="${bind_type^}-bound"
|
||||||
|
fi
|
||||||
|
expected_test_name+=" ${proto^^} port"
|
||||||
|
else
|
||||||
|
# e.g., TCP translated port range forwarding, IPv4, tap
|
||||||
|
expected_test_name+="${proto^^}"
|
||||||
|
if [[ $delta -ne 0 ]]; then
|
||||||
|
expected_test_name+=" translated"
|
||||||
|
fi
|
||||||
|
expected_test_name+=" port range"
|
||||||
|
fi
|
||||||
|
expected_test_name+=" forwarding, IPv${ip_ver}, ${iftype}"
|
||||||
|
else
|
||||||
|
# Multi-byte. 2k is the common size for small, all else is large
|
||||||
|
local size="large"
|
||||||
|
if [[ $bytes = "2k" ]]; then
|
||||||
|
size="small"
|
||||||
|
fi
|
||||||
|
expected_test_name="${proto^^}/IPv${ip_ver} $size transfer, ${iftype}"
|
||||||
|
|
||||||
|
# No other input args are variable.
|
||||||
|
assert "$range" = "1" "range must = 1 on multibyte transfers"
|
||||||
|
assert "$delta" = "0" "delta must = 0 on multibyte transfers"
|
||||||
|
assert "$bind_type" = "port" "bind_type must = 'port' on multibyte transfers"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Normalize test name back to human-readable form: strip common prefix,
|
||||||
|
# convert '-XX' to chr (dashes, commas) and underscore to space.
|
||||||
|
# Sorry this is so convoluted.
|
||||||
|
local actual_test_name=$(printf "$(sed \
|
||||||
|
-e 's/^test_podman_networking_with_pasta-281-29_-2d_//' \
|
||||||
|
-e 's/-\([0-9a-f]\{2\}\)/\\x\1/gI' \
|
||||||
|
-e 's/_/ /g' \
|
||||||
|
<<<"${BATS_TEST_NAME}")")
|
||||||
|
|
||||||
|
assert "$actual_test_name" = "$expected_test_name" \
|
||||||
|
"INTERNAL ERROR! Mismatch between BATS test name and test args!"
|
||||||
|
|
||||||
# Calculate and set addresses,
|
# Calculate and set addresses,
|
||||||
if [ ${ip_ver} -eq 4 ]; then
|
if [ ${ip_ver} -eq 4 ]; then
|
||||||
skip_if_no_ipv4 "IPv4 not routable on the host"
|
skip_if_no_ipv4 "IPv4 not routable on the host"
|
||||||
@ -75,7 +137,7 @@ function pasta_test_do() {
|
|||||||
local xseq="$(echo ${xport} | tr '-' ' ')"
|
local xseq="$(echo ${xport} | tr '-' ' ')"
|
||||||
else
|
else
|
||||||
local port=$(random_free_port "" ${address} ${proto})
|
local port=$(random_free_port "" ${address} ${proto})
|
||||||
local xport="$((port + port_delta))"
|
local xport="$((port + delta))"
|
||||||
local seq="${port} ${port}"
|
local seq="${port} ${port}"
|
||||||
local xseq="${xport} ${xport}"
|
local xseq="${xport} ${xport}"
|
||||||
fi
|
fi
|
||||||
@ -99,9 +161,6 @@ function pasta_test_do() {
|
|||||||
recv="EXEC:md5sum"
|
recv="EXEC:md5sum"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# socat first address
|
|
||||||
send="OPEN:${XFER_FILE}"
|
|
||||||
|
|
||||||
# and port forwarding configuration for Podman and pasta.
|
# and port forwarding configuration for Podman and pasta.
|
||||||
#
|
#
|
||||||
# TODO: Use Podman options once/if
|
# TODO: Use Podman options once/if
|
||||||
@ -145,7 +204,7 @@ function pasta_test_do() {
|
|||||||
local connect="${proto_upper}${ip_ver}:[${addr}]:${one_port}"
|
local connect="${proto_upper}${ip_ver}:[${addr}]:${one_port}"
|
||||||
[ "${proto}" = "udp" ] && connect="${connect},shut-null"
|
[ "${proto}" = "udp" ] && connect="${connect},shut-null"
|
||||||
|
|
||||||
(while sleep ${delay} && ! socat -u "${send}" "${connect}"; do :
|
(while sleep ${delay} && ! socat -u "OPEN:${XFER_FILE}" "${connect}"; do :
|
||||||
done) &
|
done) &
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -715,9 +774,13 @@ function teardown() {
|
|||||||
mac="9a:dd:31:ea:92:98"
|
mac="9a:dd:31:ea:92:98"
|
||||||
cat >$containersconf <<EOF
|
cat >$containersconf <<EOF
|
||||||
[network]
|
[network]
|
||||||
|
default_rootless_network_cmd = "pasta"
|
||||||
pasta_options = ["-I", "myname", "--ns-mac-addr", "$mac"]
|
pasta_options = ["-I", "myname", "--ns-mac-addr", "$mac"]
|
||||||
EOF
|
EOF
|
||||||
CONTAINERS_CONF_OVERRIDE=$containersconf run_podman run --net=pasta $IMAGE ip link show myname
|
|
||||||
|
# 2023-06-29 DO NOT INCLUDE "--net=pasta" on this line!
|
||||||
|
# This tests containers.conf:default_rootless_network_cmd (pr #19032)
|
||||||
|
CONTAINERS_CONF_OVERRIDE=$containersconf run_podman run $IMAGE ip link show myname
|
||||||
assert "$output" =~ "$mac" "mac address is set on custom interface"
|
assert "$output" =~ "$mac" "mac address is set on custom interface"
|
||||||
|
|
||||||
# now, again but this time overwrite a option on the cli.
|
# now, again but this time overwrite a option on the cli.
|
||||||
|
Reference in New Issue
Block a user