-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-benchmarking-test.sh
More file actions
executable file
·84 lines (76 loc) · 2.32 KB
/
Copy pathstart-benchmarking-test.sh
File metadata and controls
executable file
·84 lines (76 loc) · 2.32 KB
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
#!/bin/bash
# Lists available benchmarking tests and prompts the user to select one to run.
#
# Usage:
# ./start-benchmarking-test.sh # fully interactive
# ./start-benchmarking-test.sh <test> # prompts for broker only
# ./start-benchmarking-test.sh <test> <broker> # fully non-interactive
#
# <test> can be a test name (e.g. ent-1k-quick) or menu number (e.g. 14)
script_dir="${BASH_SOURCE%/*}"
test_dir="${script_dir}/benchmarking-tests"
# Collect test scripts
mapfile -t scripts < <(find "${test_dir}" -maxdepth 1 -name '*.sh' | sort)
if [ ${#scripts[@]} -eq 0 ]; then
echo "No benchmarking tests found in ${test_dir}."
exit 1
fi
# Resolve test selection
if [ -n "$1" ]; then
arg="$1"
if [[ "${arg}" =~ ^[0-9]+$ ]]; then
if [ "${arg}" -ge 1 ] && [ "${arg}" -le "${#scripts[@]}" ]; then
sel="${arg}"
else
echo "Error: test number ${arg} is out of range (1-${#scripts[@]})."
exit 1
fi
else
name="${arg%.sh}"
sel=""
for i in "${!scripts[@]}"; do
if [ "$(basename "${scripts[$i]}" .sh)" = "${name}" ]; then
sel=$(( i + 1 ))
break
fi
done
if [ -z "${sel}" ]; then
echo "Error: no test named '${name}' found."
echo "Available tests:"
for i in "${!scripts[@]}"; do
printf " %2d) %s\n" $(( i + 1 )) "$(basename "${scripts[$i]}" .sh)"
done
exit 1
fi
fi
else
echo "============================================================"
echo " Available benchmarking tests"
echo "============================================================"
for i in "${!scripts[@]}"; do
printf " %2d) %s\n" $(( i + 1 )) "$(basename "${scripts[$i]}" .sh)"
done
echo ""
while true; do
read -r -p "Select a test [1-${#scripts[@]}]: " sel
if [[ "${sel}" =~ ^[0-9]+$ ]] && [ "${sel}" -ge 1 ] && [ "${sel}" -le "${#scripts[@]}" ]; then
break
fi
echo " Please enter a number between 1 and ${#scripts[@]}."
done
fi
selected="${scripts[$(( sel - 1 ))]}"
# Resolve broker
if [ -n "$2" ]; then
broker="$2"
else
read -r -p "Broker IP or hostname: " broker
while [ -z "${broker}" ]; do
echo " This field is required."
read -r -p "Broker IP or hostname: " broker
done
fi
echo ""
echo "Running: $(basename "${selected}") against ${broker}"
echo ""
bash "${selected}" "${broker}"