-
Notifications
You must be signed in to change notification settings - Fork 1
/
execute-single-test.sh
executable file
·74 lines (65 loc) · 2.22 KB
/
execute-single-test.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
#!/usr/bin/env bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/docker/dev.env
function print_usage() {
printf '\n%b\n\n' "Usage: ${0} [ -p SUBPROJECT_NAME ] -n TEST_NAME"
printf '%b\n' "Execute a unit/integration test in a module with the given schema version"
printf '\n%b\n' "-n\tName of the unit/integration test to execute;\n\tfor example: CellPlotDaoIT"
printf '\n%b\n' "-p\tName of the sub-project the test can be found;\n\tfor example: app or atlas-web-core (default is app)"
printf '%b\n\n' "-h\tShow usage instructions"
}
PROJECT_NAME=app
mandatory_name=false
while getopts "n:p:h" opt
do
case ${opt} in
n )
mandatory_name=true; TEST_CASE_NAME=${OPTARG}
;;
p )
PROJECT_NAME=${OPTARG}
if ! [[ "$PROJECT_NAME" =~ ^(app|atlas-web-core)$ ]]; then
echo "Project name is not valid -$OPTARG" >&2
exit 1
fi
;;
h )
print_usage
exit 0
;;
\?)
printf '%b\n' "Invalid option: -${OPTARG}" >&2
print_usage
exit 2
;;
: ) echo "Missing option argument for: $OPTARG" >&2; exit 1;;
esac
done
if ! $mandatory_name
then
echo "-n must be provided with the name of the test to execute" >&2
exit 1
fi
echo "Testing ${TEST_CASE_NAME}"
docker-compose \
--env-file ${SCRIPT_DIR}/docker/dev.env \
-f docker/docker-compose-postgres-test.yml \
-f docker/docker-compose-solrcloud.yml \
-f docker/docker-compose-gradle-test.yml \
run --rm --service-ports \
gxa-gradle bash -c "
set -e
gradle clean
gradle \
-PdataFilesLocation=/atlas-data \
-PexperimentFilesLocation=/atlas-data/exp \
-PexperimentDesignLocation=/atlas-data/expdesign \
-PjdbcUrl=jdbc:postgresql://${POSTGRES_HOST}:5432/${POSTGRES_DB} \
-PjdbcUsername=${POSTGRES_USER} \
-PjdbcPassword=${POSTGRES_PASSWORD} \
-PzkHosts=${PROJECT_NAME}-${SOLR_CLOUD_ZK_CONTAINER_1_NAME}:2181,${PROJECT_NAME}-${SOLR_CLOUD_ZK_CONTAINER_2_NAME}:2181,${PROJECT_NAME}-${SOLR_CLOUD_ZK_CONTAINER_3_NAME}:2181 \
-PsolrHosts=http://${PROJECT_NAME}-${SOLR_CLOUD_CONTAINER_1_NAME}:8983/solr,http://${PROJECT_NAME}-${SOLR_CLOUD_CONTAINER_2_NAME}:8983/solr \
${PROJECT_NAME}:testClasses
gradle --continuous :${PROJECT_NAME}:test --tests $TEST_CASE_NAME
"