Skip to content

Commit b5a0c49

Browse files
Merge pull request #26920 from ricardobranco777/socat
tests: Replace ncat for socat
2 parents cb59650 + 0ff079d commit b5a0c49

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

test/system/252-quadlet.bats

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,8 @@ spec:
11881188
EOF
11891189

11901190
# Bind the port to force a an error when starting the pod
1191-
timeout --foreground -v --kill=10 10 ncat -l 127.0.0.1 $port &
1192-
nc_pid=$!
1191+
timeout --foreground -v --kill=10 10 socat TCP-LISTEN:$port,bind=127.0.0.1,fork - &
1192+
socat_pid=$!
11931193

11941194
# Create the Quadlet file
11951195
local quadlet_file=$PODMAN_TMPDIR/start_err_$(safename).kube
@@ -1214,7 +1214,7 @@ EOF
12141214
run -0 journalctl -eu $QUADLET_SERVICE_NAME
12151215
assert "$output" =~ "$port: bind: address already in use" "journal contains the real podman start error"
12161216

1217-
kill "$nc_pid"
1217+
kill "$socat_pid"
12181218
}
12191219

12201220
# https://github.com/containers/podman/issues/25786

test/system/500-networking.bats

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -806,26 +806,26 @@ nameserver 8.8.8.8" "nameserver order is correct"
806806
cid="$output"
807807

808808
# make sure binding the same port fails
809-
run timeout 5 ncat -l 127.0.0.1 $port
810-
assert "$status" -eq 2 "ncat unexpected exit code"
811-
assert "$output" =~ "127.0.0.1:$port: Address already in use" "ncat error message"
809+
run timeout 5 socat TCP-LISTEN:$port,bind=127.0.0.1,fork -
810+
assert "$status" -eq 1 "socat unexpected exit code"
811+
assert "$output" =~ ".* 127.0.0.1:$port.* Address already in use" "socat error message"
812812

813813
for port in $(seq $port $end_port); do
814814
run_podman exec -d $cid nc -l -p $port -e /bin/cat
815815

816-
# we have to rety ncat as it can flake as we exec in the background so nc -l
816+
# we have to retry socat as it can flake as we exec in the background so nc -l
817817
# might not have bound the port yet, retry seems simpler than checking if the
818818
# port is bound in the container, https://github.com/containers/podman/issues/21561.
819819
retries=5
820820
while [[ $retries -gt 0 ]]; do
821-
run ncat 127.0.0.1 $port <<<$random
821+
run socat - TCP:127.0.0.1:$port <<<$random
822822
if [[ $status -eq 0 ]]; then
823823
break
824824
fi
825825
sleep 0.5
826826
retries=$((retries -1))
827827
done
828-
is "$output" "$random" "ncat got data back (netmode=$netmode port=$port)"
828+
is "$output" "$random" "socat got data back (netmode=$netmode port=$port)"
829829
done
830830

831831
run_podman rm -f -t0 $cid

test/system/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ Requirements
8686
- bats
8787
- jq
8888
- skopeo
89-
- nmap-ncat
9089
- httpd-tools
9190
- openssl
9291
- socat

0 commit comments

Comments
 (0)