forked from all-of-us/raw-data-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_server.sh
executable file
·85 lines (77 loc) · 1.83 KB
/
test_server.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
#!/bin/bash -e
# Runs all client tests against a server instance. Fails if any test fails.
function usage() {
echo "Usage: test_server.sh [-r <name match glob>]"
echo " [-i <instance URL> (-c <creds file> | -a <ACCOUNT> -p <PROJECT>) ]" >& 2
exit 1
}
while getopts "a:p:i:r:c:" opt; do
case $opt in
a)
ACCOUNT=$OPTARG
;;
p)
PROJECT=$OPTARG
;;
r)
substring=$OPTARG
;;
i)
instance=$OPTARG
;;
c)
CREDS_FILE=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
h|*)
usage
;;
esac
done
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
if [ "${instance}" ]
then
if [[ -n "${ACCOUNT}" && -n "${PROJECT}" ]]
then
echo "Getting credentials for ${PROJECT}..."
CREDS_ACCOUNT="${ACCOUNT}"
source ${BASE_DIR}/tools/auth_setup.sh
elif [[ -z "${CREDS_FILE}" ]]
then
echo "If providing -i, must also provide -c or both -a, -p" >& 2
echo ""
usage
fi
else
instance=http://localhost:8080
fi
echo "Testing ${instance}"
if [[ $substring ]];
then
echo Excuting tests that match glob $substring
fi
. ${BASE_DIR}/tools/set_path.sh
function run_client_test {
# Use | instead of / for sed delimiter since we're editing file paths.
test=`echo $1 | sed -e "s|^$BASE_DIR/test/||"`
if [[ $test == *"$substring"* ]]
then
echo Running $test as it matches substring \"${substring}\".
(cd $BASE_DIR/test && \
PMI_DRC_RDR_INSTANCE=${instance} TESTING_CREDS_FILE=${CREDS_FILE} python $test)
else
echo Skipping $test as it doesn\'t match substring \"${substring}\".
fi
}
for test in $BASE_DIR/test/client_test/*_test.py
do
run_client_test "${test}"
done
echo "All client tests passed!"