generated from grafana/k6-template-es6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
52 lines (44 loc) · 1.06 KB
/
run.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
#!/bin/bash
vus=30
duration=30
endpoint="${ENDPOINT:-"https://api-loadtest.fieldseating.com"}"
use_docker=0
while getopts 'v:d:c:k' OPTION; do
case "$OPTION" in
v)
vus="$OPTARG"
;;
d)
duration="$OPTARG"
;;
c)
DIR_PATH=$(cd $(dirname "$OPTARG") && pwd)
path=$DIR_PATH/$(basename "$OPTARG")
entry_file=$path
;;
k)
echo "in k"
use_docker=1
;;
?)
echo "script usage: $(basename \$0) [-k] [-v 10] [-d 10s] [-c case]" >&2
exit 1
;;
esac
done
[[ -z ${entry_file+z} ]] && echo "please provide entry file by -c testcase.js" && exit 1
echo "options arg: vus: ${vus} | duration: ${duration}s"
echo "entry_file: $entry_file"
echo "endpoint: $endpoint"
if npm run webpack --entry ${entry_file} ; then
echo "build succeeds"
else
echo "build fails"
exit 1
fi
if [ $use_docker -eq 1 ]
then
ENDPOINT=$endpoint docker run -v $(pwd)/build:/build loadimpact/k6 run /build/main.bundle.js
exit 0
fi
ENDPOINT=$endpoint k6 run --vus ${vus} --duration "${duration}s" build/main.bundle.js