UIExplorer test: wait for packager by polling its status

Reviewed By: ericvicenti

Differential Revision: D4674436

fbshipit-source-id: c9673f85a764207f108c6e2282503e8c3201c97e
This commit is contained in:
David Aurelio
2017-03-08 11:33:35 -08:00
committed by Facebook Github Bot
parent 0ff379bb76
commit c5e2cf7678

View File

@@ -1,10 +1,12 @@
#!/bin/bash
set -ex
SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT=$(dirname $SCRIPTS)
trap 'kill $(jobs -p)' INT TERM EXIT
cd $ROOT
SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT=$(dirname "$SCRIPTS")
cd "$ROOT"
# Create cleanup handler
function cleanup {
@@ -14,7 +16,7 @@ function cleanup {
if [ $EXIT_CODE -ne 0 ];
then
WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log
[ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS
[ -f "$WATCHMAN_LOGS" ] && cat "$WATCHMAN_LOGS"
fi
# kill whatever is occupying port 8081 (packager)
lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill
@@ -23,12 +25,31 @@ function cleanup {
}
trap cleanup EXIT
# Start the packager
open "./packager/launchPackager.command" || echo "Can't start packager automatically"
open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"
# Start the packager
(exec "./packager/launchPackager.command" || echo "Can't start packager automatically") &
(exec "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically") &
# wait until packager is ready
PACKAGER_IS_RUNNING="packager-status:running"
SECONDS=0
STATUS=
sleep 2
test "$SECONDS" -ne 0 # Make sure the magic $SECONDS variable works
set +ex
while [ "$STATUS" != "$PACKAGER_IS_RUNNING" ] && [ "$SECONDS" -lt 60 ]; do
STATUS=$(curl --silent 'http://localhost:8081/status')
sleep 1
done
set -ex
if [ "$STATUS" != "$PACKAGER_IS_RUNNING" ]; then
echo "Could not startup packager within $SECONDS seconds"
false
fi
# Preload the UIExplorerApp bundle for better performance in integration tests
sleep 20
curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true' -o temp.bundle
rm temp.bundle
curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true&minify=false' -o temp.bundle
@@ -47,4 +68,4 @@ xcodebuild \
-sdk "iphonesimulator" \
-destination "platform=iOS Simulator,name=iPhone 5s,OS=10.1" \
build test