-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery_stress.sh
executable file
·74 lines (59 loc) · 1.62 KB
/
query_stress.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
provided_args="$*"
prefix="$(dirname -- "$(readlink -f "$0")")"
_cleanup () {
[ -n "$spam_analysis_pid" ] && kill "$spam_analysis_pid"
}
trap _cleanup EXIT
while [ "$#" -gt 0 ]; do
case "$1" in
-h|--help)
sed -n '/^while/,/^done/p' "$0" | grep -oP '\S+(?=\)$)'
exit 0
;;
--url)
url="$2"
shift 2
;;
--api-key)
api_key="$2"
shift 2
;;
--concurrency)
concurrency="$2"
shift 2
;;
--query)
query="$2"
shift 2
;;
--time)
time="$2"
shift 2
;;
--workers)
workers="$2"
shift 2
;;
*)
break
;;
esac
done
results="$HOME/audit-trail-perf-results"
mkdir -p "$results"
batch_id="$(uuidgen)"
batch_dir="$results/query-perf/$batch_id"
mkdir -p "$batch_dir"
meta="$batch_dir/description.nldjson"
run="run.$(date +%s)"
echo "run: $batch_id/$run" >&2
echo "$provided_args" > "$batch_dir/$run.stress.trigger"
bash "$prefix/run_series.sh" --duration "$(( $time * 2 ))" "$workers" | tee -a "$batch_dir/$run.stress.trigger" &
sleep "$(( $time / 2 ))"
bash -c 'echo $$>'"$batch_dir/spam_pid && $prefix/spam_analysis.sh" | tee "$batch_dir/$run.stress.measure" &
spam_analysis_pid="$(cat "$batch_dir/spam_pid")"
ab -t "$time" -c "$concurrency" -H"X-Domino-Api-Key: $api_key" "$url/api/audittrail/v1/auditevents?$query" | tee "$batch_dir/$run.log"
_cleanup
echo && echo && echo
echo "run: $batch_id/$run"