mirror of
https://github.com/containers/podman.git
synced 2025-10-16 18:53:19 +08:00
Merge pull request #26920 from ricardobranco777/socat
tests: Replace ncat for socat
This commit is contained in:
@ -1188,8 +1188,8 @@ spec:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Bind the port to force a an error when starting the pod
|
# Bind the port to force a an error when starting the pod
|
||||||
timeout --foreground -v --kill=10 10 ncat -l 127.0.0.1 $port &
|
timeout --foreground -v --kill=10 10 socat TCP-LISTEN:$port,bind=127.0.0.1,fork - &
|
||||||
nc_pid=$!
|
socat_pid=$!
|
||||||
|
|
||||||
# Create the Quadlet file
|
# Create the Quadlet file
|
||||||
local quadlet_file=$PODMAN_TMPDIR/start_err_$(safename).kube
|
local quadlet_file=$PODMAN_TMPDIR/start_err_$(safename).kube
|
||||||
@ -1214,7 +1214,7 @@ EOF
|
|||||||
run -0 journalctl -eu $QUADLET_SERVICE_NAME
|
run -0 journalctl -eu $QUADLET_SERVICE_NAME
|
||||||
assert "$output" =~ "$port: bind: address already in use" "journal contains the real podman start error"
|
assert "$output" =~ "$port: bind: address already in use" "journal contains the real podman start error"
|
||||||
|
|
||||||
kill "$nc_pid"
|
kill "$socat_pid"
|
||||||
}
|
}
|
||||||
|
|
||||||
# https://github.com/containers/podman/issues/25786
|
# https://github.com/containers/podman/issues/25786
|
||||||
|
@ -806,26 +806,26 @@ nameserver 8.8.8.8" "nameserver order is correct"
|
|||||||
cid="$output"
|
cid="$output"
|
||||||
|
|
||||||
# make sure binding the same port fails
|
# make sure binding the same port fails
|
||||||
run timeout 5 ncat -l 127.0.0.1 $port
|
run timeout 5 socat TCP-LISTEN:$port,bind=127.0.0.1,fork -
|
||||||
assert "$status" -eq 2 "ncat unexpected exit code"
|
assert "$status" -eq 1 "socat unexpected exit code"
|
||||||
assert "$output" =~ "127.0.0.1:$port: Address already in use" "ncat error message"
|
assert "$output" =~ ".* 127.0.0.1:$port.* Address already in use" "socat error message"
|
||||||
|
|
||||||
for port in $(seq $port $end_port); do
|
for port in $(seq $port $end_port); do
|
||||||
run_podman exec -d $cid nc -l -p $port -e /bin/cat
|
run_podman exec -d $cid nc -l -p $port -e /bin/cat
|
||||||
|
|
||||||
# we have to rety ncat as it can flake as we exec in the background so nc -l
|
# we have to retry socat as it can flake as we exec in the background so nc -l
|
||||||
# might not have bound the port yet, retry seems simpler than checking if the
|
# might not have bound the port yet, retry seems simpler than checking if the
|
||||||
# port is bound in the container, https://github.com/containers/podman/issues/21561.
|
# port is bound in the container, https://github.com/containers/podman/issues/21561.
|
||||||
retries=5
|
retries=5
|
||||||
while [[ $retries -gt 0 ]]; do
|
while [[ $retries -gt 0 ]]; do
|
||||||
run ncat 127.0.0.1 $port <<<$random
|
run socat - TCP:127.0.0.1:$port <<<$random
|
||||||
if [[ $status -eq 0 ]]; then
|
if [[ $status -eq 0 ]]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
retries=$((retries -1))
|
retries=$((retries -1))
|
||||||
done
|
done
|
||||||
is "$output" "$random" "ncat got data back (netmode=$netmode port=$port)"
|
is "$output" "$random" "socat got data back (netmode=$netmode port=$port)"
|
||||||
done
|
done
|
||||||
|
|
||||||
run_podman rm -f -t0 $cid
|
run_podman rm -f -t0 $cid
|
||||||
|
@ -86,7 +86,6 @@ Requirements
|
|||||||
- bats
|
- bats
|
||||||
- jq
|
- jq
|
||||||
- skopeo
|
- skopeo
|
||||||
- nmap-ncat
|
|
||||||
- httpd-tools
|
- httpd-tools
|
||||||
- openssl
|
- openssl
|
||||||
- socat
|
- socat
|
||||||
|
Reference in New Issue
Block a user