forked from 4minitz/4minitz
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92e7474
commit dcab8b5
Showing
1 changed file
with
49 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,70 @@ | ||
#!/usr/bin/env bash | ||
|
||
TEST="$1" # We will run these tests | ||
LOGDIR="./tests/end2end/logs" | ||
SERVERLOG="$LOGDIR/server.log" | ||
MONGODB_HOST="localhost:3101" | ||
MONGODB_DB="meteor" | ||
VERSIONS_DIR="./versions" | ||
|
||
# Ensure necessary commands are available | ||
for cmd in npm mongodump google-chrome; do | ||
if ! command -v $cmd &> /dev/null; then | ||
echo "Error: $cmd could not be found" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Function to echo and log | ||
log() { | ||
echo "$1" | ||
echo "$1" >> "$SERVERLOG" | ||
} | ||
echo Remove old log file | ||
LOGDIR=./tests/end2end/logs | ||
mkdir -p "$LOGDIR" | ||
SERVERLOG=$LOGDIR/server.log | ||
rm "$SERVERLOG" | /dev/null | ||
rm "$SERVERLOG" >> /dev/null # Clear the log file | ||
|
||
echo Start end2end server | ||
npm run test:end2end:server >"$SERVERLOG" & | ||
log "Starting end2end server" | ||
npm run test:end2end:server >> "$SERVERLOG" 2>&1 & | ||
SERVER_PID=$! | ||
|
||
COUNTER=0 | ||
MAX_WAIT=900 | ||
wait_for_server_start() { | ||
local counter=0 | ||
local max_wait=900 | ||
until grep "=> App running at" "$SERVERLOG"; do | ||
echo App has not started yet.. Waiting for "$COUNTER" seconds | ||
log "App has not started yet.. Waiting for $counter seconds" | ||
sleep 30 | ||
COUNTER=$((COUNTER + 30)) | ||
|
||
if [ "$COUNTER" -gt "$MAX_WAIT" ]; then | ||
echo Meteor takes too long to start, exiting. Server log: | ||
cat "$SERVERLOG" | ||
exit 1 | ||
fi | ||
if grep "=> Your application has errors." "$SERVERLOG"; then | ||
echo Meteor reports build errors, exiting. Server log: | ||
cat "$SERVERLOG" | ||
exit 1 | ||
fi | ||
counter=$((counter + 30)) | ||
if [ "$counter" -gt "$max_wait" ]; then | ||
log "Meteor takes too long to start, exiting. Server log:" | ||
cat "$SERVERLOG" | ||
exit 1 | ||
fi | ||
if grep "=> Your application has errors." "$SERVERLOG"; then | ||
log "Meteor reports build errors, exiting. Server log:" | ||
cat "$SERVERLOG" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
wait_for_server_start | ||
sleep 10 | ||
|
||
echo Start end2end test runner | ||
log "Starting end2end test runner" | ||
export HEADLESS=1 # evaluated by wdio.conf.js | ||
export CHROME_LOG_FILE="$PWD/$LOGDIR"/chrome_client_console.log | ||
export CHROME_LOG_FILE="$PWD/$LOGDIR/chrome_client_console.log" | ||
npm run wdio -- --spec "$TEST" | ||
WDIO_RESULT=$? | ||
|
||
# Cleanup | ||
unset HEADLESS CHROME_LOG_FILE SPECFILE | ||
mkdir -p tests/mongodump | ||
mongodump -h "$MONGODB_HOST" -d "$MONGODB_DB" -o ./tests/mongodump | ||
|
||
mkdir tests/mongodump | ||
mongodump -h localhost:3101 -d meteor -o ./tests/mongodump | ||
|
||
# archive versions | ||
mkdir versions | ||
npm ls >./versions/npm.txt | ||
google-chrome --version >./versions/chrome.txt | ||
./node_modules/chromedriver/bin/chromedriver --version >./versions/chrome_driver.txt | ||
# Archive versions | ||
mkdir -p "$VERSIONS_DIR" | ||
npm ls > "$VERSIONS_DIR/npm.txt" | ||
google-chrome --version > "$VERSIONS_DIR/chrome.txt" | ||
./node_modules/chromedriver/bin/chromedriver --version > "$VERSIONS_DIR/chrome_driver.txt" | ||
|
||
exit "$WDIO_RESULT" |