Add a simple test for TCP connectivity.

This commit is contained in:
Carlos Nihelton 2022-06-07 13:41:27 -03:00
parent 7e94f78c0a
commit 858241956f
No known key found for this signature in database
GPG Key ID: 6FE346D245197E9A
1 changed files with 23 additions and 0 deletions

View File

@ -231,6 +231,29 @@ grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades:
# The OOBE doesn't exist in WSL < 20.04
if [ "${RELEASE%.*}" -ge 20 ]; then
# Test TCP connectivity (system_setup only)
clean
port=50321
LANG=C.UTF-8 timeout --foreground 60 \
python3 -m system_setup.cmd.server --dry-run --tcp-port=$port &
subiquity_pid=$!
next_time=3
until [ $next_time -eq 0 ] || [ ! -z "$(ss -Hlt sport = $port)" ]; do
sleep $(( next_time-- ))
done
if [ $next_time -eq 0 ]; then
echo "Timeout reached before Subiquity TCP socket started listening"
exit 1
fi
curl "http://localhost:$port/meta/status"
curl_ec=$?
kill $subiquity_pid
if [ $curl_ec != 0 ]; then
echo "GET Request to meta/status failed with code: $curl_ec"
exit 1
fi
# Test system_setup autoinstall.
for mode in "" "-full" "-no-shutdown"; do
clean
LANG=C.UTF-8 timeout --foreground 60 \