tests: future proof travis/runner.sh and make it more robust
This change only slightly modifies the bahaviour of travis/runner.sh, but:
1. speeds up the tests, because it does not install dependencies before running
them. Dependencies are already installed by .travis.yml in its "install"
section;
2. if for some reason Etherpad does not start, there is a sudden failure,
instead of launching the front end tests anyway, and then having to wait 10
minutes for them to time out;
3. it is compatible with a different way of installing etherpad dependencies
("npm ci" instead of "npm install"), whereas the previous one broke. This
will probably be introduced in a while, so this change future-proofs for it
(see #3778).
4. it is more robust, because it detects more reliably the paths, and changes
between them correctly;
Please note that the script now requires bash instead of a generic posix shell.
This may break on platforms which default to a different shell (FreeBSD, MacOS?)
2020-03-29 20:32:54 +00:00
|
|
|
#!/bin/bash
|
2020-04-03 01:27:05 +00:00
|
|
|
if [ -z "${SAUCE_USERNAME}" ]; then echo "SAUCE_USERNAME is unset - exiting"; exit 1; fi
|
|
|
|
if [ -z "${SAUCE_ACCESS_KEY}" ]; then echo "SAUCE_ACCESS_KEY is unset - exiting"; exit 1; fi
|
2012-11-01 22:17:31 +00:00
|
|
|
|
tests: future proof travis/runner.sh and make it more robust
This change only slightly modifies the bahaviour of travis/runner.sh, but:
1. speeds up the tests, because it does not install dependencies before running
them. Dependencies are already installed by .travis.yml in its "install"
section;
2. if for some reason Etherpad does not start, there is a sudden failure,
instead of launching the front end tests anyway, and then having to wait 10
minutes for them to time out;
3. it is compatible with a different way of installing etherpad dependencies
("npm ci" instead of "npm install"), whereas the previous one broke. This
will probably be introduced in a while, so this change future-proofs for it
(see #3778).
4. it is more robust, because it detects more reliably the paths, and changes
between them correctly;
Please note that the script now requires bash instead of a generic posix shell.
This may break on platforms which default to a different shell (FreeBSD, MacOS?)
2020-03-29 20:32:54 +00:00
|
|
|
# do not continue if there is an error
|
|
|
|
set -eu
|
2012-11-01 22:17:31 +00:00
|
|
|
|
tests: future proof travis/runner.sh and make it more robust
This change only slightly modifies the bahaviour of travis/runner.sh, but:
1. speeds up the tests, because it does not install dependencies before running
them. Dependencies are already installed by .travis.yml in its "install"
section;
2. if for some reason Etherpad does not start, there is a sudden failure,
instead of launching the front end tests anyway, and then having to wait 10
minutes for them to time out;
3. it is compatible with a different way of installing etherpad dependencies
("npm ci" instead of "npm install"), whereas the previous one broke. This
will probably be introduced in a while, so this change future-proofs for it
(see #3778).
4. it is more robust, because it detects more reliably the paths, and changes
between them correctly;
Please note that the script now requires bash instead of a generic posix shell.
This may break on platforms which default to a different shell (FreeBSD, MacOS?)
2020-03-29 20:32:54 +00:00
|
|
|
# source: https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself#246128
|
|
|
|
MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
2012-11-01 22:17:31 +00:00
|
|
|
|
tests: future proof travis/runner.sh and make it more robust
This change only slightly modifies the bahaviour of travis/runner.sh, but:
1. speeds up the tests, because it does not install dependencies before running
them. Dependencies are already installed by .travis.yml in its "install"
section;
2. if for some reason Etherpad does not start, there is a sudden failure,
instead of launching the front end tests anyway, and then having to wait 10
minutes for them to time out;
3. it is compatible with a different way of installing etherpad dependencies
("npm ci" instead of "npm install"), whereas the previous one broke. This
will probably be introduced in a while, so this change future-proofs for it
(see #3778).
4. it is more robust, because it detects more reliably the paths, and changes
between them correctly;
Please note that the script now requires bash instead of a generic posix shell.
This may break on platforms which default to a different shell (FreeBSD, MacOS?)
2020-03-29 20:32:54 +00:00
|
|
|
# reliably move to the etherpad base folder before running it
|
|
|
|
cd "${MY_DIR}/../../../"
|
|
|
|
|
|
|
|
# start Etherpad, assuming all dependencies are already installed.
|
|
|
|
#
|
|
|
|
# This is possible because the "install" section of .travis.yml already contains
|
|
|
|
# a call to bin/installDeps.sh
|
|
|
|
echo "Running Etherpad directly, assuming bin/installDeps.sh has already been run"
|
2020-07-28 18:57:33 +00:00
|
|
|
node node_modules/ep_etherpad-lite/node/server.js "${@}" &
|
tests: future proof travis/runner.sh and make it more robust
This change only slightly modifies the bahaviour of travis/runner.sh, but:
1. speeds up the tests, because it does not install dependencies before running
them. Dependencies are already installed by .travis.yml in its "install"
section;
2. if for some reason Etherpad does not start, there is a sudden failure,
instead of launching the front end tests anyway, and then having to wait 10
minutes for them to time out;
3. it is compatible with a different way of installing etherpad dependencies
("npm ci" instead of "npm install"), whereas the previous one broke. This
will probably be introduced in a while, so this change future-proofs for it
(see #3778).
4. it is more robust, because it detects more reliably the paths, and changes
between them correctly;
Please note that the script now requires bash instead of a generic posix shell.
This may break on platforms which default to a different shell (FreeBSD, MacOS?)
2020-03-29 20:32:54 +00:00
|
|
|
|
|
|
|
echo "Now I will try for 15 seconds to connect to Etherpad on http://localhost:9001"
|
|
|
|
|
|
|
|
# wait for at most 15 seconds until Etherpad starts accepting connections
|
|
|
|
#
|
|
|
|
# modified from:
|
|
|
|
# https://unix.stackexchange.com/questions/5277/how-do-i-tell-a-script-to-wait-for-a-process-to-start-accepting-requests-on-a-po#349138
|
|
|
|
#
|
|
|
|
(timeout 15 bash -c 'until echo > /dev/tcp/localhost/9001; do sleep 0.5; done') || \
|
|
|
|
(echo "Could not connect to Etherpad on http://localhost:9001" ; exit 1)
|
|
|
|
|
|
|
|
echo "Successfully connected to Etherpad on http://localhost:9001"
|
|
|
|
|
|
|
|
# On the Travis VM, remote_runner.js is found at
|
|
|
|
# /home/travis/build/ether/[secure]/tests/frontend/travis/remote_runner.js
|
|
|
|
# which is the same directory that contains this script.
|
|
|
|
# Let's move back there.
|
|
|
|
#
|
|
|
|
# Probably remote_runner.js is injected by Saucelabs.
|
|
|
|
cd "${MY_DIR}"
|
|
|
|
|
|
|
|
# start the remote runner
|
|
|
|
echo "Now starting the remote runner"
|
2012-11-01 22:17:31 +00:00
|
|
|
node remote_runner.js
|
2012-11-01 23:21:10 +00:00
|
|
|
exit_code=$?
|
2012-11-01 22:17:31 +00:00
|
|
|
|
2012-11-01 23:21:10 +00:00
|
|
|
kill $(cat /tmp/sauce.pid)
|
|
|
|
|
tests: future proof travis/runner.sh and make it more robust
This change only slightly modifies the bahaviour of travis/runner.sh, but:
1. speeds up the tests, because it does not install dependencies before running
them. Dependencies are already installed by .travis.yml in its "install"
section;
2. if for some reason Etherpad does not start, there is a sudden failure,
instead of launching the front end tests anyway, and then having to wait 10
minutes for them to time out;
3. it is compatible with a different way of installing etherpad dependencies
("npm ci" instead of "npm install"), whereas the previous one broke. This
will probably be introduced in a while, so this change future-proofs for it
(see #3778).
4. it is more robust, because it detects more reliably the paths, and changes
between them correctly;
Please note that the script now requires bash instead of a generic posix shell.
This may break on platforms which default to a different shell (FreeBSD, MacOS?)
2020-03-29 20:32:54 +00:00
|
|
|
exit $exit_code
|