build: properly wait for external browser tunnels to terminate

We currently wait for browser tunnels of Saucelabs and Browserstack
to terminate by repeatedly checking with `ps -p`. This is not reliable and
can break if the host system is not removing forcibly killed child processes
from the process table. This is valid since the tunnels are launched as child
processes and we ideally wait for those to terminate using the `wait` command.
This commit is contained in:
Paul Gschwendtner
2019-06-20 10:21:29 +02:00
committed by Jeremy Elbourn
parent 10cd71a0ed
commit 21594d33e8
6 changed files with 19 additions and 16 deletions
+4
View File
@@ -68,3 +68,7 @@ browserstack-tunnel/BrowserStackLocal -k ${BROWSER_STACK_ACCESS_KEY} ${ARGS} 2>&
# Wait for the tunnel to be ready and create the readyfile with the Browserstack PID
create_ready_file ${!} &
# Wait for all sub processes to finish. This ensures that no zombie
# processes are left over.
wait
+1 -6
View File
@@ -19,10 +19,5 @@ tunnelProcessId=$(cat ${tunnelReadyFile})
# we cannot use killall because CircleCI base container images don't have it installed.
kill ${tunnelProcessId}
while (ps -p ${tunnelProcessId} &> /dev/null); do
printf "."
sleep .5
done
echo ""
echo "Browserstack tunnel has been shut down"
echo "Browserstack tunnel interrupt signal has been sent."
+8 -2
View File
@@ -4,14 +4,17 @@
# proper exit code.
set -e
# Path to the project directory.
projectDir="$(dirname ${0})/../.."
# Go to project directory.
cd $(dirname ${0})/../..
cd ${projectDir}
# Decode access token and make it accessible for child processes.
export BROWSER_STACK_ACCESS_KEY=`echo ${BROWSER_STACK_ACCESS_KEY} | rev`
# Start tunnel and wait for it being ready.
./scripts/browserstack/start-tunnel.sh
./scripts/browserstack/start-tunnel.sh &
./scripts/browserstack/wait-tunnel.sh
# Setup the test platform environment variable that will be read
@@ -24,3 +27,6 @@ yarn gulp ci:test
# Kill the Browserstack tunnel. This is necessary in order to avoid rate-limit
# errors that cause the unit tests to be flaky.
./scripts/browserstack/stop-tunnel.sh
# Wait for all sub processes to terminate properly.
wait
+4 -1
View File
@@ -11,7 +11,7 @@ cd $(dirname ${0})/../..
export SAUCE_ACCESS_KEY=`echo ${SAUCE_ACCESS_KEY} | rev`
# Start tunnel and wait for it being ready.
./scripts/saucelabs/start-tunnel.sh
./scripts/saucelabs/start-tunnel.sh &
./scripts/saucelabs/wait-tunnel.sh
# Setup the test platform environment variable that will be read
@@ -24,3 +24,6 @@ yarn gulp ci:test
# Kill the Saucelabs tunnel. This is necessary in order to avoid rate-limit
# errors that cause the unit tests to be flaky.
./scripts/saucelabs/stop-tunnel.sh
# Wait for all sub processes to terminate properly.
wait
+1 -1
View File
@@ -35,4 +35,4 @@ fi
echo "Starting Sauce Connect in the background. Passed arguments: ${sauceArgs}"
sauce-connect/bin/sc -u ${SAUCE_USERNAME} -k ${SAUCE_ACCESS_KEY} ${sauceArgs} &
sauce-connect/bin/sc -u ${SAUCE_USERNAME} -k ${SAUCE_ACCESS_KEY} ${sauceArgs}
+1 -6
View File
@@ -19,10 +19,5 @@ tunnelProcessId=$(cat ${tunnelPidFile})
# we cannot use killall because CircleCI base container images don't have it installed.
kill ${tunnelProcessId}
while (ps -p ${tunnelProcessId} &> /dev/null); do
printf "."
sleep .5
done
echo ""
echo "Sauce Connect tunnel has been shut down"
echo "Sauce Connect tunnel interrupt signal has been sent."