From 858241956f4dcb7a5e73af8e23fedb7ba95cad42 Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Tue, 7 Jun 2022 13:41:27 -0300 Subject: [PATCH] Add a simple test for TCP connectivity. --- scripts/runtests.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/runtests.sh b/scripts/runtests.sh index e9389034..2eae5cea 100755 --- a/scripts/runtests.sh +++ b/scripts/runtests.sh @@ -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 \