-
Notifications
You must be signed in to change notification settings - Fork 360
/
Copy pathtest_cromwell.sh
executable file
·194 lines (165 loc) · 6.63 KB
/
test_cromwell.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/env bash
shutdown() {
cd "${INITIAL_DIR}"
exit "${EXIT_CODE}"
}
trap "shutdown" EXIT
set -e
EXIT_CODE=1
PROGNAME="$(basename $0)"
usage="
$PROGNAME [-h] [-b branch] [-j jar path] [-g] [-r rundir] [-l logdir] [-c cromwell config file] [-n centaur config file] [-t refresh token file] [-s service account json] [-i includeTag] [-e excludeTag] [-d testDirPath]
Builds and runs specified branch of Cromwell and runs Centaur against it.
Arguments:
-h Displays this help message and exits
-b Branch of Cromwell to test. Mutually exclusive with -j
-j Path of a Cromwell jar to use. Mutually exclusive with -b
-r Directory where script is run (defaults to current directory)
-l Directory where logs are written (defaults to logs under the current directory)
-g Generate code coverage output for the Centaur main classes
-c If supplied, the config file to pass to Cromwell
-n If supplied, the config file to pass to Centaur
-t If supplied, the timeout for request-plus-response from Centaur to Cromwell
-i If supplied, will include tests with this tag
-e If supplied, will exclude tests with this tag
-s If supplied, will run only the specified suite
-p If supplied, number of tests to be run in parallel. 16 is the default
-d If supplied, will run the tests in this directory instead of the standard tests
"
INITIAL_DIR=$(pwd)
RUN_DIR=$(pwd)
LOG_DIR="${RUN_DIR}"/logs
TEST_THREAD_COUNT=16 # Note that most users of this script override this value
CENTAUR_SBT_COVERAGE=false
CROMWELL_TIMEOUT=10s
SUITE=""
while getopts ":hb:r:l:c:n:p:j:gt:i:e:s:d:" option; do
case "$option" in
h) echo "$usage"
exit
;;
r) RUN_DIR=$OPTARG
;;
l) LOG_DIR=$OPTARG
;;
n) CENTAUR_CONFIG_STRING="${OPTARG}"
;;
g) CENTAUR_SBT_COVERAGE=true
;;
b) CROMWELL_BRANCH="${OPTARG}"
;;
j) CROMWELL_JAR="${OPTARG}"
;;
c) CROMWELL_CONFIG_STRING="${OPTARG}"
;;
t) CROMWELL_TIMEOUT="${OPTARG}"
;;
p) TEST_THREAD_COUNT="${OPTARG}"
;;
d) TEST_CASE_DIR="${OPTARG}"
;;
i) INCLUDE_TAG+=("${OPTARG}")
;;
e) EXCLUDE_TAG+=("${OPTARG}")
;;
s) SUITE="${OPTARG}"
;;
:) printf "Missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?) printf "Illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
ASSEMBLY_LOG=${LOG_DIR}/cromwell_assembly.log
CROMWELL_LOG=${LOG_DIR}/cromwell.log
CENTAUR_LOG=${LOG_DIR}/centaur.log
mkdir -p "${RUN_DIR}"
cd "${RUN_DIR}"
mkdir -p "${LOG_DIR}"
if [[ -n ${CROMWELL_BRANCH} ]]; then
if [[ -n ${CROMWELL_JAR} ]]; then
echo "Do not specify both a branch and a jar" >&2
exit 1
fi
if [ ! -d "cromwell" ]; then
echo "Cloning Cromwell"
git clone https://github.com/broadinstitute/cromwell.git
else
echo "Using existing Cromwell directory"
fi
cd cromwell
echo "Checking out CROMWELL_BRANCH $CROMWELL_BRANCH"
git checkout "${CROMWELL_BRANCH}"
git pull
echo "Building Cromwell"
sbt -Dsbt.supershell=false --warn assembly >> "${ASSEMBLY_LOG}" 2>&1
cd ..
# This is the "branch" logic but sets the CROMWELL_JAR to be used in either the "branch" or "jar" use cases.
# Note that this may not be necessary in the docker-compose use case.
CROMWELL_JAR=$(find "${RUN_DIR}"/cromwell/target/scala-2.* -name "cromwell-*.jar")
fi
# Build and run centaur
cd "${RUN_DIR}"
TEST_STATUS="failed"
if [[ "${CENTAUR_SBT_COVERAGE}" == "true" ]]; then
sbt -Dsbt.supershell=false --warn coverage centaur/IntegrationTest/compile
CP=$(sbt -no-colors --error coverage "export centaur/IntegrationTest/dependencyClasspath")
else
sbt -Dsbt.supershell=false --warn centaur/IntegrationTest/compile
CP=$(sbt -no-colors --error "export centaur/IntegrationTest/dependencyClasspath")
fi
# Add the it-classes folder to the classpath to ensure logback configuration files are picked up.
CP="${CP}:${RUN_DIR}/centaur/target/scala-2.13/it-classes"
# This is set in cromwell::private::create_centaur_variables
if [ -n "${CENTAUR_CONFIG_STRING}" ]; then
CENTAUR_CONF="-Dconfig.file=${CENTAUR_CONFIG_STRING}"
else
if [ -n "${TEST_CASE_DIR}" ]; then
RUN_SPECIFIED_TEST_DIR_CMD="-Dcentaur.standardTestCasePath=${TEST_CASE_DIR}"
fi
# Regardless of whether this script was invoked with the "branch" or "jar" option, Centaur is always run in "jar" mode.
# "branch" or "jar" only controls whether this script was handed a jar or had to build one above.
CENTAUR_CROMWELL_MODE="-Dcentaur.cromwell.mode=jar"
CENTAUR_CROMWELL_JAR="-Dcentaur.cromwell.jar.path=${CROMWELL_JAR}"
CENTAUR_CROMWELL_CONF="-Dcentaur.cromwell.jar.conf=${CROMWELL_CONFIG_STRING}"
CENTAUR_CROMWELL_LOG="-Dcentaur.cromwell.jar.log=${CROMWELL_LOG}"
CENTAUR_CROMWELL_RESTART="-Dcentaur.cromwell.jar.withRestart=true"
CENTAUR_SEND_RECEIVE_TIMEOUT="-Dcentaur.sendReceiveTimeout='${CROMWELL_TIMEOUT}'"
CENTAUR_LOG_REQUEST_FAILURES="-Dcentaur.log-request-failures=true"
CENTAUR_CONF="${RUN_SPECIFIED_TEST_DIR_CMD} ${CENTAUR_LOG_REQUEST_FAILURES} ${CENTAUR_CROMWELL_MODE} ${CENTAUR_CROMWELL_JAR} ${CENTAUR_CROMWELL_CONF} ${CENTAUR_CROMWELL_LOG} ${CENTAUR_CROMWELL_RESTART} ${CENTAUR_SEND_RECEIVE_TIMEOUT}"
fi
TEST_DESCRIPTION="Running Centaur with sbt test"
TEST_COMMAND="java ${CENTAUR_CONF} -cp $CP org.scalatest.tools.Runner -R centaur/target/scala-2.13/it-classes -oD -u target/test-reports -PS${TEST_THREAD_COUNT}"
if [[ -n ${EXCLUDE_TAG[*]} ]]; then
TEST_DESCRIPTION=${TEST_DESCRIPTION}" excluding ${EXCLUDE_TAG[*]} tests"
EXCLUDE=""
for val in "${EXCLUDE_TAG[@]}"; do
EXCLUDE=" -l $val"${EXCLUDE}
done
TEST_COMMAND="${TEST_COMMAND}${EXCLUDE}"
fi
if [[ -n ${INCLUDE_TAG[*]} ]]; then
TEST_DESCRIPTION=${TEST_DESCRIPTION}" including ${INCLUDE_TAG[*]} tests"
INCLUDE=""
for val in "${INCLUDE_TAG[@]}"; do
INCLUDE=" -n $val"${INCLUDE}
done
TEST_COMMAND="${TEST_COMMAND}${INCLUDE}"
fi
if [[ -n "${SUITE}" ]]; then
TEST_DESCRIPTION=${TEST_DESCRIPTION}" with suite ${SUITE}"
TEST_COMMAND="${TEST_COMMAND} -s ${SUITE}"
fi
echo "${TEST_DESCRIPTION}"
echo "TEST_COMMAND is ${TEST_COMMAND}"
eval "${TEST_COMMAND} >> ${CENTAUR_LOG} 2>&1"
if [ $? -eq 0 ]; then
EXIT_CODE=0
TEST_STATUS="succeeded"
fi
echo "SBT test $TEST_STATUS, please see logs for more information"