forked from all-of-us/raw-data-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_test.sh
executable file
·74 lines (66 loc) · 1.75 KB
/
load_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
#!/bin/bash -e
# Runs a load test against a deployed RDR. See load_test_locustfile for instructions.
if ! which locust
then
echo "Install Locust with \"sudo pip install locustio\"."
exit 1
fi
function usage {
echo "Usage: load_test.sh --project all-of-us-rdr-test --account [email protected]"
exit 1
}
while true
do
case "$1" in
--project) PROJECT=$2; shift 2;;
--account) ACCOUNT=$2; shift 2;;
*) break;;
esac
done
if [ "$@" ]
then
echo "Unrecognized arguments: $@"
usage
fi
if [ -z "$ACCOUNT" ]
then
usage
fi
if [ -z "$PROJECT" ]
then
usage
fi
if [[ "$PROJECT" =~ "prod" ]]
then
echo "Forbidden to load test against production instance $PROJECT."
exit 1
fi
CREDS_ACCOUNT=$ACCOUNT
. tools/auth_setup.sh
# Some dependency data is loaded via DAOs before load testing via API.
run_cloud_sql_proxy
set_db_connection_string
# Prefer system-wide installs of some packages (specifically "requests"). The
# gcloud libraries added by set_path.sh include an older version.
OLDPATH=$PYTHONPATH
. tools/set_path.sh;
GAE_SDK_ROOT="${sdk_dir}/platform/google_appengine"
# The next line enables Python libraries for Google Cloud SDK
GAEPATH=${GAE_SDK_ROOT}
# * OPTIONAL STEP *
# If you wish to import all Python modules, you may iterate in the directory
# tree and import each module.
#
# * WARNING *
# Some modules have two or more versions available (Ex. django), so the loop
# will import always its latest version.
for module in ${GAE_SDK_ROOT}/lib/*; do
if [ -r ${module} ];
then
GAEPATH=${module}:${GAEPATH}
fi
done
export PYTHONPATH=/usr/local/lib/python2.7/dist-packages:$OLDPATH:$PYTHONPATH:${GAEPATH}
LOCUST_CREDS_FILE="$CREDS_FILE" \
LOCUST_TARGET_INSTANCE="https://$PROJECT.appspot.com" \
locust -f "$BASE_DIR"/tools/load_test_locustfile.py