mirror of
https://github.com/containers/podman.git
synced 2025-10-13 01:06:10 +08:00
test: use ncat over nc
nc can be provided by either ncat (nmap) or netcat (OpenBSD), we only work with the nmap version so make sure we always use that one and not the short alias which can be resolved to either one. It is not clear to me what changed on rawhide but it seemsv netcat is preferred even though we have nmap-ncat installed. Note this only changes the host side nc calls, the Alpine based images only have nc as command so we must continue to use it inside. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
# create tempfile to store nc output
|
||||
OUTFILE=$(mktemp)
|
||||
# listen on a port, the container will try to connect to it
|
||||
nc -l 5001 > $OUTFILE &
|
||||
ncat -l 5001 > $OUTFILE &
|
||||
|
||||
nc_pid=$!
|
||||
|
@ -1131,7 +1131,7 @@ spec:
|
||||
EOF
|
||||
|
||||
# Bind the port to force a an error when starting the pod
|
||||
timeout --foreground -v --kill=10 10 nc -l 127.0.0.1 $port &
|
||||
timeout --foreground -v --kill=10 10 ncat -l 127.0.0.1 $port &
|
||||
nc_pid=$!
|
||||
|
||||
# Create the Quadlet file
|
||||
|
@ -791,7 +791,7 @@ nameserver 8.8.8.8" "nameserver order is correct"
|
||||
cid="$output"
|
||||
|
||||
# make sure binding the same port fails
|
||||
run timeout 5 nc -l 127.0.0.1 $port
|
||||
run timeout 5 ncat -l 127.0.0.1 $port
|
||||
assert "$status" -eq 2 "ncat unexpected exit code"
|
||||
assert "$output" =~ "127.0.0.1:$port: Address already in use" "ncat error message"
|
||||
|
||||
@ -803,10 +803,7 @@ nameserver 8.8.8.8" "nameserver order is correct"
|
||||
# port is bound in the container, https://github.com/containers/podman/issues/21561.
|
||||
retries=5
|
||||
while [[ $retries -gt 0 ]]; do
|
||||
# -w 1 adds a 1 second timeout. For some reason, ubuntu's ncat
|
||||
# doesn't close the connection on EOF, and other options to
|
||||
# change this are not portable across distros. -w seems to work.
|
||||
run nc -w 1 127.0.0.1 $port <<<$random
|
||||
run ncat 127.0.0.1 $port <<<$random
|
||||
if [[ $status -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
|
Reference in New Issue
Block a user