|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -set -e |
| 3 | +set -euo pipefail |
4 | 4 |
|
5 | | -if [ -z $(which wget) ]; then |
6 | | - # use curl |
7 | | - GET='curl' |
8 | | -else |
9 | | - GET='wget -O -' |
| 5 | +if [ "$#" != "2" ]; then |
| 6 | + echo "Usage: $0 <workspace_dir> <testmodel_url>" |
| 7 | + exit 2 |
10 | 8 | fi |
11 | 9 |
|
| 10 | +WORKSPACE_DIR=$1 |
| 11 | +TESTMODEL_URL=$2 |
| 12 | + |
| 13 | +INTERMINE_DIR=${WORKSPACE_DIR}/server |
| 14 | +TESTMINE_DIR=${INTERMINE_DIR}/testmine |
| 15 | + |
| 16 | +cd "${WORKSPACE_DIR}" |
| 17 | + |
12 | 18 | # Pull in the server code. |
13 | | -git clone --single-branch --depth 1 https://github.com/intermine/intermine.git server |
| 19 | + |
| 20 | +if [ ! -d "${INTERMINE_DIR}" ]; then |
| 21 | + git clone --single-branch --depth 1 -b dev https://github.com/ucam-department-of-psychiatry/intermine.git "${INTERMINE_DIR}" |
| 22 | +fi |
14 | 23 |
|
15 | 24 | export PSQL_USER=test |
16 | 25 | export PSQL_PWD=test |
| 26 | +export PSQL_HOST=localhost |
| 27 | +export PGPASSWORD=${PGPASSWORD:-postgres} |
17 | 28 | export KEYSTORE=${PWD}/keystore.jks |
18 | 29 |
|
19 | 30 | echo "#---> Running unit tests" |
20 | 31 |
|
21 | | -sudo -u postgres createuser test |
22 | | -sudo -u postgres psql -c "alter user test with encrypted password 'test';" |
| 32 | +sudo -E -u postgres dropdb -h "$PSQL_HOST" --if-exists intermine-demo |
| 33 | +sudo -E -u postgres dropdb -h "$PSQL_HOST" --if-exists userprofile-demo |
| 34 | + |
| 35 | +sudo -E -u postgres dropuser -h "${PSQL_HOST}" --if-exists test |
| 36 | +sudo -E -u postgres createuser -h "${PSQL_HOST}" test |
| 37 | +sudo -E -u postgres psql -h "${PSQL_HOST}" -c "alter user test with encrypted password 'test';" |
23 | 38 |
|
24 | 39 | # Set up properties |
25 | | -PROPDIR=$HOME/.intermine |
26 | | -TESTMODEL_PROPS=$PROPDIR/testmodel.properties |
27 | | -SED_SCRIPT='s/PSQL_USER/test/' |
| 40 | +PROPDIR=${HOME}/.intermine |
| 41 | +TESTMODEL_PROPS=${PROPDIR}/testmodel.properties |
| 42 | + |
| 43 | +mkdir -p "${PROPDIR}" |
28 | 44 |
|
29 | | -mkdir -p $PROPDIR |
| 45 | +echo "#--- creating ${TESTMODEL_PROPS}" |
| 46 | +cp "${INTERMINE_DIR}"/config/testmodel.properties "${TESTMODEL_PROPS}" |
| 47 | +sed -i -e "s/PSQL_HOST/${PSQL_HOST}/" "$TESTMODEL_PROPS" |
| 48 | +sed -i -e "s/PSQL_USER/${PSQL_USER}/" "$TESTMODEL_PROPS" |
| 49 | +sed -i -e "s/PSQL_PWD/${PSQL_PWD}/" "$TESTMODEL_PROPS" |
30 | 50 |
|
31 | | -echo "#--- creating $TESTMODEL_PROPS" |
32 | | -cp server/config/testmodel.properties $TESTMODEL_PROPS |
33 | | -sed -i -e $SED_SCRIPT $TESTMODEL_PROPS |
34 | 51 |
|
35 | 52 | # We will need a fully operational web-application |
36 | 53 | echo '#---> Building and releasing web application to test against' |
37 | | -(cd server/testmine && ./setup.sh) |
| 54 | +(cd "${TESTMINE_DIR}" && ./setup.sh "${INTERMINE_DIR}") |
38 | 55 | # Travis is so slow |
39 | 56 | sleep 90 # let webapp startup |
40 | 57 |
|
41 | 58 | # Warm up the keyword search by requesting results, but ignoring the results |
42 | | -$GET "$TESTMODEL_URL/service/search" > /dev/null |
| 59 | +wget -O - "${TESTMODEL_URL}/service/search" > /dev/null |
43 | 60 | # Start any list upgrades |
44 | | -$GET "$TESTMODEL_URL/service/lists?token=test-user-token" > /dev/null |
| 61 | +wget -O - "${TESTMODEL_URL}/service/lists?token=test-user-token" > /dev/null |
0 commit comments