Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/system: fix wait_for_port() to wait for bind #17707

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/system/272-system-connection.bats
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ $c2[ ]\+tcp://localhost:54321[ ]\+true" \
system service -t 99 tcp://localhost:$_SERVICE_PORT &
_SERVICE_PID=$!
# Wait for the port and the podman-service to be ready.
wait_for_port localhost $_SERVICE_PORT
wait_for_port 127.0.0.1 $_SERVICE_PORT
local timeout=10
while [[ $timeout -gt 1 ]]; do
_run_podman_remote '?' info --format '{{.Host.RemoteSocket.Path}}'
Expand Down
7 changes: 4 additions & 3 deletions test/system/helpers.network.bash
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ function __ipv4_to_procfs() {
# ipv4_to_procfs() - IPv4 address representation to big-endian procfs format
# $1: Text representation of IPv4 address
function ipv4_to_procfs() {
IFS='.' __ipv4_to_procfs ${1}
IFS='.' read -r o1 o2 o3 o4 <<< $1
__ipv4_to_procfs $o1 $o2 $o3 $o4
}


Expand Down Expand Up @@ -268,7 +269,7 @@ function port_is_free() {
! port_is_bound ${@}
}

# wait_for_port() - Return once port is available on the host
# wait_for_port() - Return once port is bound (available for use by clients)
# $1: Host or address to check for possible binding
# $2: Port number
# $3: Optional timeout, 5 seconds if not given
Expand All @@ -279,7 +280,7 @@ function wait_for_port() {

# Wait
while [ $_timeout -gt 0 ]; do
port_is_free ${port} "${host}" && return
port_is_bound ${port} "${host}" && return
sleep 1
_timeout=$(( $_timeout - 1 ))
done
Expand Down