From c9461dd2967f869af469575853566a3ec9d9d105 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 13:29:59 +0200 Subject: [PATCH 01/27] hide riot static server output --- riot/start.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/riot/start.sh b/riot/start.sh index 2eb3221511..3e5077717e 100644 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,8 +1,8 @@ BASE_DIR=$(realpath $(dirname $0)) -pushd $BASE_DIR -pushd riot-web/webapp/ -python -m SimpleHTTPServer 8080 & +pushd $BASE_DIR > /dev/null +pushd riot-web/webapp/ > /dev/null +python -m SimpleHTTPServer 8080 > /dev/null 2>&1 & PID=$! -popd +popd > /dev/null echo $PID > riot.pid -popd \ No newline at end of file +popd > /dev/null \ No newline at end of file From 0be2e023812f06013a8f0c086ecea7301a44eb3d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 13:42:36 +0200 Subject: [PATCH 02/27] hide synapse schema update logs by redirecting stderr --- synapse/start.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/synapse/start.sh b/synapse/start.sh index 6d758630a4..f59a3641cc 100644 --- a/synapse/start.sh +++ b/synapse/start.sh @@ -1,7 +1,7 @@ BASE_DIR=$(realpath $(dirname $0)) -pushd $BASE_DIR -pushd installations/consent +pushd $BASE_DIR > /dev/null +pushd installations/consent > /dev/null source env/bin/activate -./synctl start -popd -popd \ No newline at end of file +./synctl start 2> /dev/null +popd > /dev/null +popd > /dev/null \ No newline at end of file From a6304ce83ebe21e0f5ae0d9c84a41bac159abf78 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 13:43:12 +0200 Subject: [PATCH 03/27] now the output isn't overwhelming anymore, output what's happening at every step --- riot/start.sh | 4 +++- start.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/riot/start.sh b/riot/start.sh index 3e5077717e..5feb40eb2b 100644 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,7 +1,9 @@ +PORT=8080 +echo "running riot on http://localhost:$PORT..." BASE_DIR=$(realpath $(dirname $0)) pushd $BASE_DIR > /dev/null pushd riot-web/webapp/ > /dev/null -python -m SimpleHTTPServer 8080 > /dev/null 2>&1 & +python -m SimpleHTTPServer $PORT > /dev/null 2>&1 & PID=$! popd > /dev/null echo $PID > riot.pid diff --git a/start.js b/start.js index d4b8dab076..a37aa4538a 100644 --- a/start.js +++ b/start.js @@ -29,6 +29,7 @@ global.riotserver = 'http://localhost:8080'; global.browser = null; async function runTests() { + console.log("running tests ..."); global.browser = await puppeteer.launch(); const page = await helpers.newPage(); From b3473a7220236f9af0ac0fcf4fc74b281ed89b5c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 13:43:38 +0200 Subject: [PATCH 04/27] with no logs polluting the output, we dont need tmux anymore to split the terminal --- run.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/run.sh b/run.sh index b64fa1dbdd..d4d4261430 100644 --- a/run.sh +++ b/run.sh @@ -1,4 +1,5 @@ -tmux \ - new-session "sh riot/stop.sh; sh synapse/stop.sh; sh synapse/start.sh; sh riot/start.sh; read"\; \ - split-window "sleep 5; node start.js; sh riot/stop.sh; sh synapse/stop.sh; read"\; \ - select-layout even-vertical +sh synapse/start.sh +sh riot/start.sh +node start.js +sh riot/stop.sh +sh synapse/stop.sh From a4e7b14728c834f0d992e2b12866ce17c163f7d4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 13:50:58 +0200 Subject: [PATCH 05/27] update README --- README.md | 12 +++++------- install.sh | 3 +++ 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 install.sh diff --git a/README.md b/README.md index 90a3e869d3..5bd4c1dadc 100644 --- a/README.md +++ b/README.md @@ -34,18 +34,16 @@ puppeteer.launch({headless: false}); ## How to run ### Setup - - install synapse with `sh synapse/install.sh`, this fetches the master branch at the moment. If anything fails here, please refer to the synapse README to see if you're missing one of the prerequisites. - - install riot with `sh riot/install.sh`, this fetches the master branch at the moment. - - install dependencies with `npm install` (will download copy of chrome) - - have riot-web running on `localhost:8080` - - have a local synapse running at `localhost:8008` + +Run `sh install.sh`. This will: + - install synapse, fetches the master branch at the moment. If anything fails here, please refer to the synapse README to see if you're missing one of the prerequisites. + - install riot, this fetches the master branch at the moment. + - install dependencies (will download copy of chrome) ### Run tests Run tests with `sh run.sh`. -You should see the terminal split with on top the server output (both riot static server, and synapse), and on the bottom the tests running. - Developer Guide =============== diff --git a/install.sh b/install.sh new file mode 100644 index 0000000000..c4e6d6253e --- /dev/null +++ b/install.sh @@ -0,0 +1,3 @@ +sh synapse/install.sh +sh riot/install.sh +npm install From 96374f4e5400d1132703927b32db22981fa27886 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 14:00:01 +0200 Subject: [PATCH 06/27] only install synapse and riot if directory is not already there --- riot/install.sh | 13 ++++++++++--- synapse/install.sh | 9 ++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/riot/install.sh b/riot/install.sh index 22bb87f03e..43b39611d7 100644 --- a/riot/install.sh +++ b/riot/install.sh @@ -1,13 +1,20 @@ RIOT_BRANCH=master BASE_DIR=$(realpath $(dirname $0)) -pushd $BASE_DIR +if [[ -d $BASE_DIR/riot-web ]]; then + echo "riot is already installed" + exit +fi + + +pushd $BASE_DIR > /dev/null curl -L https://github.com/vector-im/riot-web/archive/${RIOT_BRANCH}.zip --output riot.zip unzip riot.zip rm riot.zip mv riot-web-${RIOT_BRANCH} riot-web cp config-template/config.json riot-web/ -pushd riot-web +pushd riot-web > /dev/null npm install npm run build -popd \ No newline at end of file +popd > /dev/null +popd > /dev/null diff --git a/synapse/install.sh b/synapse/install.sh index 47f1f746fc..959e529e6b 100644 --- a/synapse/install.sh +++ b/synapse/install.sh @@ -6,7 +6,14 @@ CONFIG_TEMPLATE=consent PORT=8008 # set current directory to script directory BASE_DIR=$(realpath $(dirname $0)) -pushd $BASE_DIR + +if [[ -d $BASE_DIR/$SERVER_DIR ]]; then + echo "synapse is already installed" + exit +fi + +pushd $BASE_DIR > /dev/null + mkdir -p installations/ curl https://codeload.github.com/matrix-org/synapse/zip/$SYNAPSE_BRANCH --output synapse.zip unzip synapse.zip From 5e1517eb4d93351a8497eb7401b648d348dedc07 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 14:10:19 +0200 Subject: [PATCH 07/27] no need for push/popd in sub-shell --- riot/install.sh | 7 ++----- riot/start.sh | 3 +-- riot/stop.sh | 3 +-- synapse/install.sh | 6 ++---- synapse/start.sh | 6 ++---- synapse/stop.sh | 6 ++---- 6 files changed, 10 insertions(+), 21 deletions(-) diff --git a/riot/install.sh b/riot/install.sh index 43b39611d7..9e7e5bb2da 100644 --- a/riot/install.sh +++ b/riot/install.sh @@ -6,15 +6,12 @@ if [[ -d $BASE_DIR/riot-web ]]; then exit fi - -pushd $BASE_DIR > /dev/null +cd $BASE_DIR curl -L https://github.com/vector-im/riot-web/archive/${RIOT_BRANCH}.zip --output riot.zip unzip riot.zip rm riot.zip mv riot-web-${RIOT_BRANCH} riot-web cp config-template/config.json riot-web/ -pushd riot-web > /dev/null +cd riot-web npm install npm run build -popd > /dev/null -popd > /dev/null diff --git a/riot/start.sh b/riot/start.sh index 5feb40eb2b..141d3176e7 100644 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,10 +1,9 @@ PORT=8080 echo "running riot on http://localhost:$PORT..." BASE_DIR=$(realpath $(dirname $0)) -pushd $BASE_DIR > /dev/null +cd $BASE_DIR/ pushd riot-web/webapp/ > /dev/null python -m SimpleHTTPServer $PORT > /dev/null 2>&1 & PID=$! popd > /dev/null echo $PID > riot.pid -popd > /dev/null \ No newline at end of file diff --git a/riot/stop.sh b/riot/stop.sh index 59fef1dfd0..148116cfe6 100644 --- a/riot/stop.sh +++ b/riot/stop.sh @@ -1,6 +1,5 @@ BASE_DIR=$(realpath $(dirname $0)) -pushd $BASE_DIR > /dev/null +cd $BASE_DIR PIDFILE=riot.pid kill $(cat $PIDFILE) rm $PIDFILE -popd > /dev/null \ No newline at end of file diff --git a/synapse/install.sh b/synapse/install.sh index 959e529e6b..7170ce6d30 100644 --- a/synapse/install.sh +++ b/synapse/install.sh @@ -12,13 +12,13 @@ if [[ -d $BASE_DIR/$SERVER_DIR ]]; then exit fi -pushd $BASE_DIR > /dev/null +cd $BASE_DIR mkdir -p installations/ curl https://codeload.github.com/matrix-org/synapse/zip/$SYNAPSE_BRANCH --output synapse.zip unzip synapse.zip mv synapse-$SYNAPSE_BRANCH $SERVER_DIR -pushd $SERVER_DIR +cd $SERVER_DIR virtualenv -p python2.7 env source env/bin/activate pip install --upgrade pip @@ -36,5 +36,3 @@ sed -i "s#{{SYNAPSE_PORT}}#${PORT}/#g" homeserver.yaml sed -i "s#{{FORM_SECRET}}#$(uuidgen)#g" homeserver.yaml sed -i "s#{{REGISTRATION_SHARED_SECRET}}#$(uuidgen)#g" homeserver.yaml sed -i "s#{{MACAROON_SECRET_KEY}}#$(uuidgen)#g" homeserver.yaml -popd #back to synapse root dir -popd #back to wherever we were \ No newline at end of file diff --git a/synapse/start.sh b/synapse/start.sh index f59a3641cc..e809fb906c 100644 --- a/synapse/start.sh +++ b/synapse/start.sh @@ -1,7 +1,5 @@ BASE_DIR=$(realpath $(dirname $0)) -pushd $BASE_DIR > /dev/null -pushd installations/consent > /dev/null +cd $BASE_DIR +cd installations/consent source env/bin/activate ./synctl start 2> /dev/null -popd > /dev/null -popd > /dev/null \ No newline at end of file diff --git a/synapse/stop.sh b/synapse/stop.sh index f55d8b50db..1c5ab2fed7 100644 --- a/synapse/stop.sh +++ b/synapse/stop.sh @@ -1,7 +1,5 @@ BASE_DIR=$(realpath $(dirname $0)) -pushd $BASE_DIR > /dev/null -pushd installations/consent > /dev/null +cd $BASE_DIR +cd installations/consent source env/bin/activate ./synctl stop -popd > /dev/null -popd > /dev/null \ No newline at end of file From 5389a42bc18d6150770abbe1350ad73e2938d7f1 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 15:04:04 +0200 Subject: [PATCH 08/27] use readlink instead of realpath as it seems to be more portable --- riot/install.sh | 2 +- riot/start.sh | 2 +- riot/stop.sh | 2 +- synapse/install.sh | 2 +- synapse/start.sh | 2 +- synapse/stop.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/riot/install.sh b/riot/install.sh index 9e7e5bb2da..8a8761b705 100644 --- a/riot/install.sh +++ b/riot/install.sh @@ -1,6 +1,6 @@ RIOT_BRANCH=master -BASE_DIR=$(realpath $(dirname $0)) +BASE_DIR=$(readlink -f $(dirname $0)) if [[ -d $BASE_DIR/riot-web ]]; then echo "riot is already installed" exit diff --git a/riot/start.sh b/riot/start.sh index 141d3176e7..ec3e5b32bc 100644 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,6 +1,6 @@ PORT=8080 echo "running riot on http://localhost:$PORT..." -BASE_DIR=$(realpath $(dirname $0)) +BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR/ pushd riot-web/webapp/ > /dev/null python -m SimpleHTTPServer $PORT > /dev/null 2>&1 & diff --git a/riot/stop.sh b/riot/stop.sh index 148116cfe6..40695c749c 100644 --- a/riot/stop.sh +++ b/riot/stop.sh @@ -1,4 +1,4 @@ -BASE_DIR=$(realpath $(dirname $0)) +BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR PIDFILE=riot.pid kill $(cat $PIDFILE) diff --git a/synapse/install.sh b/synapse/install.sh index 7170ce6d30..661c98ecd5 100644 --- a/synapse/install.sh +++ b/synapse/install.sh @@ -5,7 +5,7 @@ SERVER_DIR=installations/$INSTALLATION_NAME CONFIG_TEMPLATE=consent PORT=8008 # set current directory to script directory -BASE_DIR=$(realpath $(dirname $0)) +BASE_DIR=$(readlink -f $(dirname $0)) if [[ -d $BASE_DIR/$SERVER_DIR ]]; then echo "synapse is already installed" diff --git a/synapse/start.sh b/synapse/start.sh index e809fb906c..f7af6ac0f7 100644 --- a/synapse/start.sh +++ b/synapse/start.sh @@ -1,4 +1,4 @@ -BASE_DIR=$(realpath $(dirname $0)) +BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR cd installations/consent source env/bin/activate diff --git a/synapse/stop.sh b/synapse/stop.sh index 1c5ab2fed7..ff9b004533 100644 --- a/synapse/stop.sh +++ b/synapse/stop.sh @@ -1,4 +1,4 @@ -BASE_DIR=$(realpath $(dirname $0)) +BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR cd installations/consent source env/bin/activate From ebc9859cce39efd965ea5f9b91b9bf9a725ebbf3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 15:07:43 +0200 Subject: [PATCH 09/27] add instruction to install without chrome download --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index c4e6d6253e..9004176e9a 100644 --- a/install.sh +++ b/install.sh @@ -1,3 +1,4 @@ +# run with PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true sh install.sh if chrome is already installed sh synapse/install.sh sh riot/install.sh npm install From 20becf87354725a7aff9cb402fcae3e76a25cc49 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 15:08:14 +0200 Subject: [PATCH 10/27] force running scripts in bash, as it's not the default shell on Ubuntu (which is what Travis runs) --- install.sh | 1 + riot/install.sh | 3 ++- riot/start.sh | 1 + riot/stop.sh | 1 + run.sh | 1 + synapse/install.sh | 3 ++- synapse/start.sh | 1 + synapse/stop.sh | 1 + 8 files changed, 10 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 9004176e9a..ca8a51bd69 100644 --- a/install.sh +++ b/install.sh @@ -1,3 +1,4 @@ +#!/bin/bash # run with PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true sh install.sh if chrome is already installed sh synapse/install.sh sh riot/install.sh diff --git a/riot/install.sh b/riot/install.sh index 8a8761b705..d9cc7292f0 100644 --- a/riot/install.sh +++ b/riot/install.sh @@ -1,7 +1,8 @@ +#!/bin/bash RIOT_BRANCH=master BASE_DIR=$(readlink -f $(dirname $0)) -if [[ -d $BASE_DIR/riot-web ]]; then +if [ -d $BASE_DIR/riot-web ]; then echo "riot is already installed" exit fi diff --git a/riot/start.sh b/riot/start.sh index ec3e5b32bc..3892a80a48 100644 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,3 +1,4 @@ +#!/bin/bash PORT=8080 echo "running riot on http://localhost:$PORT..." BASE_DIR=$(readlink -f $(dirname $0)) diff --git a/riot/stop.sh b/riot/stop.sh index 40695c749c..a3dc722e58 100644 --- a/riot/stop.sh +++ b/riot/stop.sh @@ -1,3 +1,4 @@ +#!/bin/bash BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR PIDFILE=riot.pid diff --git a/run.sh b/run.sh index d4d4261430..ae073d2ba9 100644 --- a/run.sh +++ b/run.sh @@ -1,3 +1,4 @@ +#!/bin/bash sh synapse/start.sh sh riot/start.sh node start.js diff --git a/synapse/install.sh b/synapse/install.sh index 661c98ecd5..8260f208c2 100644 --- a/synapse/install.sh +++ b/synapse/install.sh @@ -1,3 +1,4 @@ +#!/bin/bash # config SYNAPSE_BRANCH=master INSTALLATION_NAME=consent @@ -7,7 +8,7 @@ PORT=8008 # set current directory to script directory BASE_DIR=$(readlink -f $(dirname $0)) -if [[ -d $BASE_DIR/$SERVER_DIR ]]; then +if [ -d $BASE_DIR/$SERVER_DIR ]; then echo "synapse is already installed" exit fi diff --git a/synapse/start.sh b/synapse/start.sh index f7af6ac0f7..785909a0b1 100644 --- a/synapse/start.sh +++ b/synapse/start.sh @@ -1,3 +1,4 @@ +#!/bin/bash BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR cd installations/consent diff --git a/synapse/stop.sh b/synapse/stop.sh index ff9b004533..d83ddd0e4a 100644 --- a/synapse/stop.sh +++ b/synapse/stop.sh @@ -1,3 +1,4 @@ +#!/bin/bash BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR cd installations/consent From edf37e3592a85a7d92026a71dbbfc64ccffefa59 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 15:15:10 +0200 Subject: [PATCH 11/27] add support for passing chrome path as env var --- start.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/start.js b/start.js index a37aa4538a..427fa319d0 100644 --- a/start.js +++ b/start.js @@ -30,7 +30,11 @@ global.browser = null; async function runTests() { console.log("running tests ..."); - global.browser = await puppeteer.launch(); + const options = {}; + if (process.env.CHROME_PATH) { + options.executablePath = process.env.CHROME_PATH; + } + global.browser = await puppeteer.launch(options); const page = await helpers.newPage(); const username = 'user-' + helpers.randomInt(10000); From c3b7e6c7cb6d7a7d983f2d7e6e393fff577439c6 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 16:01:54 +0200 Subject: [PATCH 12/27] make scripts executable, running them with sh does something weird on travis --- README.md | 4 ++-- install.sh | 4 ++-- riot/install.sh | 0 riot/start.sh | 0 riot/stop.sh | 0 run.sh | 8 ++++---- synapse/install.sh | 0 synapse/start.sh | 0 synapse/stop.sh | 0 9 files changed, 8 insertions(+), 8 deletions(-) mode change 100644 => 100755 install.sh mode change 100644 => 100755 riot/install.sh mode change 100644 => 100755 riot/start.sh mode change 100644 => 100755 riot/stop.sh mode change 100644 => 100755 run.sh mode change 100644 => 100755 synapse/install.sh mode change 100644 => 100755 synapse/start.sh mode change 100644 => 100755 synapse/stop.sh diff --git a/README.md b/README.md index 5bd4c1dadc..b1a4e40aac 100644 --- a/README.md +++ b/README.md @@ -35,14 +35,14 @@ puppeteer.launch({headless: false}); ### Setup -Run `sh install.sh`. This will: +Run `./install.sh`. This will: - install synapse, fetches the master branch at the moment. If anything fails here, please refer to the synapse README to see if you're missing one of the prerequisites. - install riot, this fetches the master branch at the moment. - install dependencies (will download copy of chrome) ### Run tests -Run tests with `sh run.sh`. +Run tests with `./run.sh`. Developer Guide =============== diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index ca8a51bd69..98ce104ba0 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/bin/bash # run with PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true sh install.sh if chrome is already installed -sh synapse/install.sh -sh riot/install.sh +./synapse/install.sh +./riot/install.sh npm install diff --git a/riot/install.sh b/riot/install.sh old mode 100644 new mode 100755 diff --git a/riot/start.sh b/riot/start.sh old mode 100644 new mode 100755 diff --git a/riot/stop.sh b/riot/stop.sh old mode 100644 new mode 100755 diff --git a/run.sh b/run.sh old mode 100644 new mode 100755 index ae073d2ba9..90e1528d48 --- a/run.sh +++ b/run.sh @@ -1,6 +1,6 @@ #!/bin/bash -sh synapse/start.sh -sh riot/start.sh +./synapse/start.sh +./riot/start.sh node start.js -sh riot/stop.sh -sh synapse/stop.sh +./riot/stop.sh +./synapse/stop.sh diff --git a/synapse/install.sh b/synapse/install.sh old mode 100644 new mode 100755 diff --git a/synapse/start.sh b/synapse/start.sh old mode 100644 new mode 100755 diff --git a/synapse/stop.sh b/synapse/stop.sh old mode 100644 new mode 100755 From e8f626ba183831becbdf65e6c864e411b79a93a0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 16:04:41 +0200 Subject: [PATCH 13/27] exit on error --- install.sh | 1 + run.sh | 1 + start.js | 1 + 3 files changed, 3 insertions(+) diff --git a/install.sh b/install.sh index 98ce104ba0..4008099a3d 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,6 @@ #!/bin/bash # run with PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true sh install.sh if chrome is already installed +set -e ./synapse/install.sh ./riot/install.sh npm install diff --git a/run.sh b/run.sh index 90e1528d48..c59627e3a6 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e ./synapse/start.sh ./riot/start.sh node start.js diff --git a/start.js b/start.js index 427fa319d0..5e14539bfc 100644 --- a/start.js +++ b/start.js @@ -29,6 +29,7 @@ global.riotserver = 'http://localhost:8080'; global.browser = null; async function runTests() { + process.exit(-1); console.log("running tests ..."); const options = {}; if (process.env.CHROME_PATH) { From 976f041bbadbd43b434c336055f8a670a04c358a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 16:22:17 +0200 Subject: [PATCH 14/27] remove test exit, and use port we are semi-sure is free --- riot/start.sh | 2 +- start.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/riot/start.sh b/riot/start.sh index 3892a80a48..8e7e742f98 100755 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,5 +1,5 @@ #!/bin/bash -PORT=8080 +PORT=5000 echo "running riot on http://localhost:$PORT..." BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR/ diff --git a/start.js b/start.js index 5e14539bfc..05f4df9d0c 100644 --- a/start.js +++ b/start.js @@ -25,11 +25,10 @@ const acceptServerNoticesInviteAndConsent = require('./tests/server-notices-cons const homeserver = 'http://localhost:8008'; -global.riotserver = 'http://localhost:8080'; +global.riotserver = 'http://localhost:5000'; global.browser = null; async function runTests() { - process.exit(-1); console.log("running tests ..."); const options = {}; if (process.env.CHROME_PATH) { From 5cd52e2ebd17fed24f33c91e7b2bcad151788272 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 18:43:11 +0200 Subject: [PATCH 15/27] show browser logs on error --- helpers.js | 6 +++--- start.js | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/helpers.js b/helpers.js index fae5c8e859..a1f7434a29 100644 --- a/helpers.js +++ b/helpers.js @@ -58,9 +58,9 @@ function logXHRRequests(page) { const type = req.resourceType(); if (type === 'xhr' || type === 'fetch') { buffer += `${req.method()} ${req.url()} \n`; - if (req.method() === "POST") { - buffer += " Post data: " + req.postData(); - } + // if (req.method() === "POST") { + // buffer += " Post data: " + req.postData(); + // } } }); return { diff --git a/start.js b/start.js index 05f4df9d0c..aa459537c2 100644 --- a/start.js +++ b/start.js @@ -28,6 +28,9 @@ const homeserver = 'http://localhost:8008'; global.riotserver = 'http://localhost:5000'; global.browser = null; +let consoleLogs = null; +let xhrLogs = null; + async function runTests() { console.log("running tests ..."); const options = {}; @@ -36,6 +39,9 @@ async function runTests() { } global.browser = await puppeteer.launch(options); const page = await helpers.newPage(); + + consoleLogs = helpers.logConsole(page); + xhrLogs = helpers.logXHRRequests(page); const username = 'user-' + helpers.randomInt(10000); const password = 'testtest'; @@ -44,10 +50,12 @@ async function runTests() { process.stdout.write('done\n'); const noticesName = "Server Notices"; - process.stdout.write(`* accepting "${noticesName}" and accepting terms & conditions ...`); + process.stdout.write(`* accepting "${noticesName}" and accepting terms & conditions ... `); await acceptServerNoticesInviteAndConsent(page, noticesName); process.stdout.write('done\n'); + throw new Error('blubby'); + const room = 'test'; process.stdout.write(`* creating room ${room} ... `); await createRoom(page, room); @@ -62,6 +70,10 @@ function onSuccess() { function onFailure(err) { console.log('failure: ', err); + console.log('console.log output:'); + console.log(consoleLogs.logs()); + console.log('XHR requests:'); + console.log(xhrLogs.logs()); process.exit(-1); } From 758da7865941d4243ceacaa44f055cb7678c28bc Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 18:43:40 +0200 Subject: [PATCH 16/27] dont fail when trying to stop riot and its not running --- riot/stop.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/riot/stop.sh b/riot/stop.sh index a3dc722e58..7ed18887f9 100755 --- a/riot/stop.sh +++ b/riot/stop.sh @@ -2,5 +2,8 @@ BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR PIDFILE=riot.pid -kill $(cat $PIDFILE) -rm $PIDFILE +if [ -f $PIDFILE ]; then + echo "stopping riot server ..." + kill $(cat $PIDFILE) + rm $PIDFILE +fi From 29d688543d34554c5b56c8ce78eb7491f8f51429 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 18:44:01 +0200 Subject: [PATCH 17/27] stop servers on error in run script --- riot/start.sh | 2 +- run.sh | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/riot/start.sh b/riot/start.sh index 8e7e742f98..143e5d9f8f 100755 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,6 +1,6 @@ #!/bin/bash PORT=5000 -echo "running riot on http://localhost:$PORT..." +echo "running riot on http://localhost:$PORT ..." BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR/ pushd riot-web/webapp/ > /dev/null diff --git a/run.sh b/run.sh index c59627e3a6..02b2e4cbdf 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,19 @@ #!/bin/bash -set -e + +stop_servers() { + ./riot/stop.sh + ./synapse/stop.sh +} + +handle_error() { + EXIT_CODE=$? + stop_servers + exit $EXIT_CODE +} + +trap 'handle_error' ERR + ./synapse/start.sh ./riot/start.sh node start.js -./riot/stop.sh -./synapse/stop.sh +stop_servers From 5129bb57b608cb68a404d35f1d26f47bd4809a12 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 18:58:37 +0200 Subject: [PATCH 18/27] log all requests with their response code --- helpers.js | 9 +++++---- start.js | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/helpers.js b/helpers.js index a1f7434a29..e830824e7c 100644 --- a/helpers.js +++ b/helpers.js @@ -54,14 +54,15 @@ function logConsole(page) { function logXHRRequests(page) { let buffer = ""; - page.on('request', req => { + page.on('requestfinished', async (req) => { const type = req.resourceType(); - if (type === 'xhr' || type === 'fetch') { - buffer += `${req.method()} ${req.url()} \n`; + const response = await req.response(); + //if (type === 'xhr' || type === 'fetch') { + buffer += `${type} ${response.status()} ${req.method()} ${req.url()} \n`; // if (req.method() === "POST") { // buffer += " Post data: " + req.postData(); // } - } + //} }); return { logs() { diff --git a/start.js b/start.js index aa459537c2..c4eba26b58 100644 --- a/start.js +++ b/start.js @@ -54,8 +54,6 @@ async function runTests() { await acceptServerNoticesInviteAndConsent(page, noticesName); process.stdout.write('done\n'); - throw new Error('blubby'); - const room = 'test'; process.stdout.write(`* creating room ${room} ... `); await createRoom(page, room); From 31fcf08fece786f7fc7c3fd96770037c0926dc2e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 31 Jul 2018 11:41:01 +0200 Subject: [PATCH 19/27] only allow one riot server instance simultaneously --- riot/start.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/riot/start.sh b/riot/start.sh index 143e5d9f8f..2c76747e46 100755 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,10 +1,18 @@ #!/bin/bash PORT=5000 -echo "running riot on http://localhost:$PORT ..." BASE_DIR=$(readlink -f $(dirname $0)) +PIDFILE=riot.pid +CONFIG_BACKUP=config.e2etests_backup.json + cd $BASE_DIR/ + +if [ -f $PIDFILE ]; then + exit +fi + +echo "running riot on http://localhost:$PORT ..." pushd riot-web/webapp/ > /dev/null python -m SimpleHTTPServer $PORT > /dev/null 2>&1 & PID=$! popd > /dev/null -echo $PID > riot.pid +echo $PID > $PIDFILE From e50420dd1baa991f9229f4dec10e82442684b7ac Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 19:27:53 +0200 Subject: [PATCH 20/27] apply config file when starting riot, not installing, so we can support riots that were built by another process --- riot/install.sh | 1 - riot/start.sh | 7 +++++++ riot/stop.sh | 12 +++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/riot/install.sh b/riot/install.sh index d9cc7292f0..a215b46cea 100755 --- a/riot/install.sh +++ b/riot/install.sh @@ -12,7 +12,6 @@ curl -L https://github.com/vector-im/riot-web/archive/${RIOT_BRANCH}.zip --outpu unzip riot.zip rm riot.zip mv riot-web-${RIOT_BRANCH} riot-web -cp config-template/config.json riot-web/ cd riot-web npm install npm run build diff --git a/riot/start.sh b/riot/start.sh index 2c76747e46..35f66f68e3 100755 --- a/riot/start.sh +++ b/riot/start.sh @@ -12,6 +12,13 @@ fi echo "running riot on http://localhost:$PORT ..." pushd riot-web/webapp/ > /dev/null + +# backup config file before we copy template +if [ -f config.json ]; then + mv config.json $CONFIG_BACKUP +fi +cp $BASE_DIR/config-template/config.json . + python -m SimpleHTTPServer $PORT > /dev/null 2>&1 & PID=$! popd > /dev/null diff --git a/riot/stop.sh b/riot/stop.sh index 7ed18887f9..0773174fd1 100755 --- a/riot/stop.sh +++ b/riot/stop.sh @@ -1,9 +1,19 @@ #!/bin/bash BASE_DIR=$(readlink -f $(dirname $0)) -cd $BASE_DIR PIDFILE=riot.pid +CONFIG_BACKUP=config.e2etests_backup.json + +cd $BASE_DIR + if [ -f $PIDFILE ]; then echo "stopping riot server ..." kill $(cat $PIDFILE) rm $PIDFILE + + # revert config file + cd riot-web/webapp + rm config.json + if [ -f $CONFIG_BACKUP ]; then + mv $CONFIG_BACKUP config.json + fi fi From a5c891144567442f5a3fee2a142af4842de7f6e2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 27 Jul 2018 20:01:13 +0200 Subject: [PATCH 21/27] output document html on error and dont make a screenshot on submit --- start.js | 13 ++++++++++++- tests/signup.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/start.js b/start.js index c4eba26b58..c109430fb8 100644 --- a/start.js +++ b/start.js @@ -30,6 +30,7 @@ global.browser = null; let consoleLogs = null; let xhrLogs = null; +let globalPage = null; async function runTests() { console.log("running tests ..."); @@ -39,6 +40,7 @@ async function runTests() { } global.browser = await puppeteer.launch(options); const page = await helpers.newPage(); + globalPage = page; consoleLogs = helpers.logConsole(page); xhrLogs = helpers.logXHRRequests(page); @@ -66,12 +68,21 @@ function onSuccess() { console.log('all tests finished successfully'); } -function onFailure(err) { +async function onFailure(err) { + + let documentHtml = "no page"; + if (globalPage) { + documentHtml = await globalPage.content(); + } + console.log('failure: ', err); console.log('console.log output:'); console.log(consoleLogs.logs()); console.log('XHR requests:'); console.log(xhrLogs.logs()); + console.log('document html:'); + console.log(documentHtml); + process.exit(-1); } diff --git a/tests/signup.js b/tests/signup.js index 65044f900c..06035b61e3 100644 --- a/tests/signup.js +++ b/tests/signup.js @@ -55,7 +55,7 @@ module.exports = async function signup(page, username, password, homeserver) { const error_text = await helpers.tryGetInnertext(page, '.mx_Login_error'); assert.strictEqual(!!error_text, false); //submit form - await page.screenshot({path: "beforesubmit.png", fullPage: true}); + //await page.screenshot({path: "beforesubmit.png", fullPage: true}); await registerButton.click(); //confirm dialog saying you cant log back in without e-mail From d738b404ca207337ea8295280781c55e3c11439f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 30 Jul 2018 11:11:06 +0200 Subject: [PATCH 22/27] try upgrading puppeteer --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 48644df401..1cbdf5bd26 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,6 @@ "author": "", "license": "ISC", "dependencies": { - "puppeteer": "^1.5.0" + "puppeteer": "^1.6.0" } } From c357a0158dac92af4c30fc22258b56e2f4c7cc5f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 30 Jul 2018 13:40:23 +0200 Subject: [PATCH 23/27] no need to log contents of zip files --- riot/install.sh | 2 +- synapse/install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/riot/install.sh b/riot/install.sh index a215b46cea..7f37fa9457 100755 --- a/riot/install.sh +++ b/riot/install.sh @@ -9,7 +9,7 @@ fi cd $BASE_DIR curl -L https://github.com/vector-im/riot-web/archive/${RIOT_BRANCH}.zip --output riot.zip -unzip riot.zip +unzip -q riot.zip rm riot.zip mv riot-web-${RIOT_BRANCH} riot-web cd riot-web diff --git a/synapse/install.sh b/synapse/install.sh index 8260f208c2..dc4a08cb41 100755 --- a/synapse/install.sh +++ b/synapse/install.sh @@ -17,7 +17,7 @@ cd $BASE_DIR mkdir -p installations/ curl https://codeload.github.com/matrix-org/synapse/zip/$SYNAPSE_BRANCH --output synapse.zip -unzip synapse.zip +unzip -q synapse.zip mv synapse-$SYNAPSE_BRANCH $SERVER_DIR cd $SERVER_DIR virtualenv -p python2.7 env From 9a2f3094866d56281a6de930ee2c170eeb12325b Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 31 Jul 2018 10:08:01 +0200 Subject: [PATCH 24/27] xhr and console logs are done for all tests now, no need to do it in signup anymore --- tests/signup.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/signup.js b/tests/signup.js index 06035b61e3..70c478aed1 100644 --- a/tests/signup.js +++ b/tests/signup.js @@ -19,8 +19,6 @@ const acceptTerms = require('./consent'); const assert = require('assert'); module.exports = async function signup(page, username, password, homeserver) { - const consoleLogs = helpers.logConsole(page); - const xhrLogs = helpers.logXHRRequests(page); await page.goto(helpers.riotUrl('/#/register')); //click 'Custom server' radio button if (homeserver) { From 387657721898c3d1618ab2ae29bbc2a759548288 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 31 Jul 2018 10:25:26 +0200 Subject: [PATCH 25/27] log when using external chrome! --- start.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/start.js b/start.js index c109430fb8..4912f901c1 100644 --- a/start.js +++ b/start.js @@ -36,7 +36,9 @@ async function runTests() { console.log("running tests ..."); const options = {}; if (process.env.CHROME_PATH) { - options.executablePath = process.env.CHROME_PATH; + const path = process.env.CHROME_PATH; + console.log(`(using external chrome/chromium at ${path}, make sure it's compatible with puppeteer)`); + options.executablePath = path; } global.browser = await puppeteer.launch(options); const page = await helpers.newPage(); From f57628e3d0a0b6b53484df6d95249da4cde6935c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 31 Jul 2018 12:54:39 +0200 Subject: [PATCH 26/27] dont swallow riot server errors --- riot/start.sh | 42 ++++++++++++++++++++++++++++++++++-------- riot/stop.sh | 3 ++- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/riot/start.sh b/riot/start.sh index 35f66f68e3..1127535d2b 100755 --- a/riot/start.sh +++ b/riot/start.sh @@ -1,16 +1,15 @@ #!/bin/bash PORT=5000 BASE_DIR=$(readlink -f $(dirname $0)) -PIDFILE=riot.pid +PIDFILE=$BASE_DIR/riot.pid CONFIG_BACKUP=config.e2etests_backup.json -cd $BASE_DIR/ - if [ -f $PIDFILE ]; then exit fi -echo "running riot on http://localhost:$PORT ..." +cd $BASE_DIR/ +echo -n "starting riot on http://localhost:$PORT ... " pushd riot-web/webapp/ > /dev/null # backup config file before we copy template @@ -19,7 +18,34 @@ if [ -f config.json ]; then fi cp $BASE_DIR/config-template/config.json . -python -m SimpleHTTPServer $PORT > /dev/null 2>&1 & -PID=$! -popd > /dev/null -echo $PID > $PIDFILE +LOGFILE=$(mktemp) +# run web server in the background, showing output on error +( + python -m SimpleHTTPServer $PORT > $LOGFILE 2>&1 & + PID=$! + echo $PID > $PIDFILE + # wait so subshell does not exit + # otherwise sleep below would not work + wait $PID; RESULT=$? + + # NOT expected SIGTERM (128 + 15) + # from stop.sh? + if [ $RESULT -ne 143 ]; then + echo "failed" + cat $LOGFILE + rm $PIDFILE 2> /dev/null + fi + rm $LOGFILE + exit $RESULT +)& +# to be able to return the exit code for immediate errors (like address already in use) +# we wait for a short amount of time in the background and exit when the first +# child process exists +sleep 0.5 & +# wait the first child process to exit (python or sleep) +wait -n; RESULT=$? +# return exit code of first child to exit +if [ $RESULT -eq 0 ]; then + echo "running" +fi +exit $RESULT diff --git a/riot/stop.sh b/riot/stop.sh index 0773174fd1..8d3c925c80 100755 --- a/riot/stop.sh +++ b/riot/stop.sh @@ -7,8 +7,9 @@ cd $BASE_DIR if [ -f $PIDFILE ]; then echo "stopping riot server ..." - kill $(cat $PIDFILE) + PID=$(cat $PIDFILE) rm $PIDFILE + kill $PID # revert config file cd riot-web/webapp From 97fa7e03d13bd73726bcbd0e6c556a8e336163a4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 31 Jul 2018 14:45:14 +0200 Subject: [PATCH 27/27] dont swallow synapse startup errors --- synapse/start.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/synapse/start.sh b/synapse/start.sh index 785909a0b1..12b89b31ed 100755 --- a/synapse/start.sh +++ b/synapse/start.sh @@ -3,4 +3,10 @@ BASE_DIR=$(readlink -f $(dirname $0)) cd $BASE_DIR cd installations/consent source env/bin/activate -./synctl start 2> /dev/null +LOGFILE=$(mktemp) +./synctl start 2> $LOGFILE +EXIT_CODE=$? +if [ $EXIT_CODE -ne 0 ]; then + cat $LOGFILE +fi +exit $EXIT_CODE \ No newline at end of file