Some changes to make the testing script run on mac, too, + a multithreaded server for riot

This commit is contained in:
Tom Lant 2018-09-25 18:45:08 +01:00
parent 4aad156b92
commit 04b64dbae9
7 changed files with 57 additions and 17 deletions

View file

@ -1,12 +1,29 @@
#!/bin/bash #!/bin/bash
RIOT_BRANCH=master set -e
BASE_DIR=$(readlink -f $(dirname $0)) RIOT_BRANCH=master
BASE_DIR=$(cd $(dirname $0) && pwd)
if [ -d $BASE_DIR/riot-web ]; then if [ -d $BASE_DIR/riot-web ]; then
echo "riot is already installed" echo "riot is already installed"
exit exit
fi fi
# Install ComplexHttpServer (a drop in replacement for Python's SimpleHttpServer
# but with support for multiple threads) into a virtualenv.
(
virtualenv $BASE_DIR/env
source $BASE_DIR/env/bin/activate
# Having been bitten by pip SSL fail too many times, I don't trust the existing pip
# to be able to --upgrade itself, so grab a new one fresh from source.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install ComplexHttpServer
deactivate
)
cd $BASE_DIR cd $BASE_DIR
curl -L https://github.com/vector-im/riot-web/archive/${RIOT_BRANCH}.zip --output riot.zip curl -L https://github.com/vector-im/riot-web/archive/${RIOT_BRANCH}.zip --output riot.zip
unzip -q riot.zip unzip -q riot.zip

View file

@ -1,6 +1,8 @@
#!/bin/bash #!/usr/bin/env bash
set -e
PORT=5000 PORT=5000
BASE_DIR=$(readlink -f $(dirname $0)) BASE_DIR=$(cd $(dirname $0) && pwd)
PIDFILE=$BASE_DIR/riot.pid PIDFILE=$BASE_DIR/riot.pid
CONFIG_BACKUP=config.e2etests_backup.json CONFIG_BACKUP=config.e2etests_backup.json
@ -21,7 +23,8 @@ cp $BASE_DIR/config-template/config.json .
LOGFILE=$(mktemp) LOGFILE=$(mktemp)
# run web server in the background, showing output on error # run web server in the background, showing output on error
( (
python -m SimpleHTTPServer $PORT > $LOGFILE 2>&1 & source $BASE_DIR/env/bin/activate
python -m ComplexHTTPServer $PORT > $LOGFILE 2>&1 &
PID=$! PID=$!
echo $PID > $PIDFILE echo $PID > $PIDFILE
# wait so subshell does not exit # wait so subshell does not exit
@ -40,7 +43,7 @@ LOGFILE=$(mktemp)
)& )&
# to be able to return the exit code for immediate errors (like address already in use) # 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 # we wait for a short amount of time in the background and exit when the first
# child process exists # child process exits
sleep 0.5 & sleep 0.5 &
# wait the first child process to exit (python or sleep) # wait the first child process to exit (python or sleep)
wait -n; RESULT=$? wait -n; RESULT=$?

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
BASE_DIR=$(readlink -f $(dirname $0)) set -e
BASE_DIR=$(cd $(dirname $0) && pwd)
PIDFILE=riot.pid PIDFILE=riot.pid
CONFIG_BACKUP=config.e2etests_backup.json CONFIG_BACKUP=config.e2etests_backup.json

1
run.sh
View file

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
set -e
stop_servers() { stop_servers() {
./riot/stop.sh ./riot/stop.sh

View file

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
set -e
# config # config
SYNAPSE_BRANCH=develop SYNAPSE_BRANCH=develop
INSTALLATION_NAME=consent INSTALLATION_NAME=consent
@ -6,7 +8,7 @@ SERVER_DIR=installations/$INSTALLATION_NAME
CONFIG_TEMPLATE=consent CONFIG_TEMPLATE=consent
PORT=5005 PORT=5005
# set current directory to script directory # set current directory to script directory
BASE_DIR=$(readlink -f $(dirname $0)) BASE_DIR=$(cd $(dirname $0) && pwd)
if [ -d $BASE_DIR/$SERVER_DIR ]; then if [ -d $BASE_DIR/$SERVER_DIR ]; then
echo "synapse is already installed" echo "synapse is already installed"
@ -22,9 +24,17 @@ mv synapse-$SYNAPSE_BRANCH $SERVER_DIR
cd $SERVER_DIR cd $SERVER_DIR
virtualenv -p python2.7 env virtualenv -p python2.7 env
source env/bin/activate source env/bin/activate
pip install --upgrade pip
# Having been bitten by pip SSL fail too many times, I don't trust the existing pip
# to be able to --upgrade itself, so grab a new one fresh from source.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install --upgrade setuptools pip install --upgrade setuptools
python synapse/python_dependencies.py | xargs pip install
pip install lxml mock
pip install . pip install .
python -m synapse.app.homeserver \ python -m synapse.app.homeserver \
--server-name localhost \ --server-name localhost \
--config-path homeserver.yaml \ --config-path homeserver.yaml \
@ -32,8 +42,11 @@ python -m synapse.app.homeserver \
--report-stats=no --report-stats=no
# apply configuration # apply configuration
cp -r $BASE_DIR/config-templates/$CONFIG_TEMPLATE/. ./ cp -r $BASE_DIR/config-templates/$CONFIG_TEMPLATE/. ./
sed -i "s#{{SYNAPSE_ROOT}}#$(pwd)/#g" homeserver.yaml
sed -i "s#{{SYNAPSE_PORT}}#${PORT}#g" homeserver.yaml # Hashes used instead of slashes because we'll get a value back from $(pwd) that'll be
sed -i "s#{{FORM_SECRET}}#$(uuidgen)#g" homeserver.yaml # full of un-escapable slashes.
sed -i "s#{{REGISTRATION_SHARED_SECRET}}#$(uuidgen)#g" homeserver.yaml sed -i '' "s#{{SYNAPSE_ROOT}}#$(pwd)/#g" homeserver.yaml
sed -i "s#{{MACAROON_SECRET_KEY}}#$(uuidgen)#g" homeserver.yaml 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

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
BASE_DIR=$(readlink -f $(dirname $0)) set -e
BASE_DIR=$(cd $(dirname $0) && pwd)
cd $BASE_DIR cd $BASE_DIR
cd installations/consent cd installations/consent
source env/bin/activate source env/bin/activate
@ -9,4 +11,4 @@ EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then if [ $EXIT_CODE -ne 0 ]; then
cat $LOGFILE cat $LOGFILE
fi fi
exit $EXIT_CODE exit $EXIT_CODE

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
BASE_DIR=$(readlink -f $(dirname $0)) set -e
BASE_DIR=$(cd $(dirname $0) && pwd)
cd $BASE_DIR cd $BASE_DIR
cd installations/consent cd installations/consent
source env/bin/activate source env/bin/activate