From 81ef4ce00325d4a1ff7a2326174b14f743fde37a Mon Sep 17 00:00:00 2001 From: Maxb <bittmanmax@gmail.com> Date: Thu, 29 Aug 2024 11:46:54 -0700 Subject: [PATCH] Add reconnect integration test We can easily check that the obfsvpn client will reconnect to our obfsvpn host servers by restarting the server docker containers in our integration test after the initial successful connection and then assuring that they are able to connect again after a reasonable time :) --- scripts/integration-test.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/integration-test.sh b/scripts/integration-test.sh index 7174e37..62e4125 100755 --- a/scripts/integration-test.sh +++ b/scripts/integration-test.sh @@ -46,18 +46,38 @@ docker compose -p "$mode" build --parallel --no-cache docker compose -p "$mode" --env-file $env_file up -d --build # need to wait for openvpn to generate configs -max_retry=40 +max_initial_retry=40 counter=0 # Testing bridged tunnel until docker compose -p "$mode" --env-file $env_file exec client ping -c 3 -I tun0 8.8.8.8 do ((counter++)) - [[ counter -eq $max_retry ]] && echo "Failed!" | tee -a $logfile && exit 1 + [[ counter -eq $max_initial_retry ]] && echo "Failed!" | tee -a $logfile && exit 1 echo "Pinging in client container with config $(cat ${env_file} | grep KCP) and $(cat ${env_file} | grep HOP_PT) failed. Trying again. Try #$counter" | tee -a $logfile sleep 30 done +counter=0 +max_reconnect_retry=10 + +if [[ "$LIVE_TEST" == "0" ]]; then + echo "Testing reconnect" + + # We can't just restart the obfsvpn servers because of some very odd way that key material is being generated so we go down and up instead 🤷 + docker compose -p "$mode" --env-file $env_file down obfsvpn-1 obfsvpn-2 + docker compose -p "$mode" --env-file $env_file up -d obfsvpn-1 obfsvpn-2 + + until docker compose -p "$mode" --env-file $env_file exec client ping -c 3 -I tun0 8.8.8.8 + do + ((counter++)) + [[ counter -eq $max_reconnect_retry ]] && echo "Failed!" | tee -a $logfile && exit 1 + echo "Pinging in client container with config $(cat ${env_file} | grep KCP) and $(cat ${env_file} | grep HOP_PT) after reconnect failed. Trying again. Try #$counter" | tee -a $logfile + sleep 10 + done + +fi + docker compose -p "$mode" --env-file $env_file exec client ndt7-client -quiet | tee -a $logfile # Testing bridge control panel -- GitLab