-
Notifications
You must be signed in to change notification settings - Fork 318
/
Copy pathe2e.sh
executable file
·83 lines (68 loc) · 2.96 KB
/
e2e.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
set -e
set -o allexport
TEST_REPO_URL="https://github.com/cBioPortal/cbioportal-test.git"
DOCKER_COMPOSE_REPO_URL="https://github.com/cBioPortal/cbioportal-docker-compose.git"
STUDIES='ascn_test_study study_hg38 teststudy_genepanels study_es_0 lgg_ucsf_2014_test_generic_assay'
APPLICATION_PROPERTIES_PATH=$(cd -- "$(dirname -- "$0")" && cd .. && pwd)/end-to-end-test/local/runtime-config/portal.properties
KEYCLOAK="true"
RUN_FRONTEND="false" # Set to "true" if you want to build and run frontend at localhost:3000
RUN_TESTS="false" # Set to "true" if you want to run all e2e:local tests
# Use database image with preloaded studies
export DOCKER_IMAGE_MYSQL=cbioportal/mysql:8.0-database-test
# Use custom application properties
export APPLICATION_PROPERTIES_PATH=$APPLICATION_PROPERTIES_PATH
# Backend image
export DOCKER_IMAGE_CBIOPORTAL=cbioportal/cbioportal:master
# Create a temp dir and clone test repo
ROOT_DIR=$(pwd)
TEMP_DIR=$(mktemp -d)
git clone "$TEST_REPO_URL" "$TEMP_DIR/cbioportal-test" || exit 1
git clone "$DOCKER_COMPOSE_REPO_URL" "$TEMP_DIR/cbioportal-docker-compose" || exit 1
cd "$TEMP_DIR/cbioportal-test" || exit 1
# Generate keycloak config
if [ "$KEYCLOAK" = "true" ]; then
./utils/gen-keycloak-config.sh --studies="$STUDIES" --template='$TEMP_DIR/cbioportal-docker-compose/dev/keycloak/keycloak-config.json' --out='keycloak-config-generated.json'
export KEYCLOAK_CONFIG_PATH="$TEMP_DIR/cbioportal-test/keycloak-config-generated.json"
fi
# Start backend
if [ "$KEYCLOAK" = "true" ]; then
./scripts/docker-compose.sh --portal_type='keycloak' --docker_args='-d'
# Check keycloak connection at localhost:8081
./utils/check-connection.sh --url=localhost:8081 --max_retries=50
else
./scripts/docker-compose.sh --portal_type='web-and-data' --docker_args='-d'
fi
# Check backend connection at localhost:8080
./utils/check-connection.sh --url=localhost:8080/api/health --max_retries=50
if [ "$RUN_FRONTEND" = "true" ]; then
# Build frontend
printf "\nBuilding frontend ...\n\n"
cd "$ROOT_DIR" || exit 1
export BRANCH_ENV=master
yarn install --frozen-lockfile
yarn run buildAll
# Start frontend http server, delete if previous server exists
if [ -e "/var/tmp/cbioportal-pid" ]; then
pkill -F /var/tmp/cbioportal-pid
fi
openssl \
req -newkey rsa:2048 -new -nodes -x509 -days 1 -keyout key.pem -out cert.pem -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" && \
nohup ./node_modules/http-server/bin/http-server --cors dist/ -p 3000 > /dev/null 2>&1 &
echo $! > /var/tmp/cbioportal-pid
# Wait for frontend at localhost:3000
printf "\nVerifying frontend connection ...\n\n"
cd "$TEMP_DIR/cbioportal-test" || exit 1
./utils/check-connection.sh --url=localhost:3000
fi
if [ "$RUN_TESTS" = "true" ]; then
# Build e2e localdb tests
cd "$ROOT_DIR/end-to-end-test" || exit 1
yarn --ignore-engines
# Run e2e localdb tests
cd "$ROOT_DIR" || exit 1
yarn run e2e:local
fi
# Cleanup
cd "$ROOT_DIR" || exit 1
rm -rf "$TEMP_DIR"