78 lines
2.3 KiB
Bash
Executable File
78 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
env_file="${1:-${repo_root}/compose/.env}"
|
|
run_id="${2:-$(date +%Y%m%d-%H%M%S)}"
|
|
request_count="${BENCHMARK_REQUESTS_PER_LEVEL:-200}"
|
|
output_root="${repo_root}/results/raw/${run_id}"
|
|
|
|
if [[ ! -f "$env_file" ]]; then
|
|
echo "Environment file not found: $env_file" >&2
|
|
exit 1
|
|
fi
|
|
|
|
read_value() {
|
|
local key="$1"
|
|
sed -n "s/^${key}=//p" "$env_file" | head -n 1
|
|
}
|
|
|
|
backend_bind_address="$(read_value BACKEND_BIND_ADDRESS)"
|
|
backend_host_port="$(read_value BACKEND_HOST_PORT)"
|
|
admin_backend_bind_address="$(read_value ADMIN_BACKEND_BIND_ADDRESS)"
|
|
admin_backend_host_port="$(read_value ADMIN_BACKEND_HOST_PORT)"
|
|
|
|
if [[ -z "$backend_bind_address" || -z "$backend_host_port" || -z "$admin_backend_bind_address" || -z "$admin_backend_host_port" ]]; then
|
|
echo "Backend benchmark endpoints are missing from the environment file." >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$output_root"
|
|
sampler_stop="${output_root}/.resource-sampler-stop"
|
|
rm -f "$sampler_stop"
|
|
bash "${repo_root}/scripts/sample-benchmark-resources.sh" "$sampler_stop" \
|
|
> "${output_root}/resources-during-load.csv" &
|
|
sampler_pid=$!
|
|
|
|
stop_sampler() {
|
|
touch "$sampler_stop"
|
|
wait "$sampler_pid" 2>/dev/null || true
|
|
rm -f "$sampler_stop"
|
|
}
|
|
trap stop_sampler EXIT
|
|
|
|
declare -a names=(user-health admin-health)
|
|
declare -a urls=(
|
|
"http://${backend_bind_address}:${backend_host_port}/api/health"
|
|
"http://${admin_backend_bind_address}:${admin_backend_host_port}/actuator/health"
|
|
)
|
|
declare -a concurrencies=(1 5 10 20 40)
|
|
|
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
|
> "${output_root}/snapshot-before.txt"
|
|
|
|
for index in "${!names[@]}"; do
|
|
name="${names[$index]}"
|
|
url="${urls[$index]}"
|
|
for concurrency in "${concurrencies[@]}"; do
|
|
python3 "${repo_root}/benchmark/run-http-benchmark.py" \
|
|
--url "$url" \
|
|
--requests "$request_count" \
|
|
--concurrency "$concurrency" \
|
|
--warmup 5 \
|
|
--timeout 10 \
|
|
--expected-status 200 \
|
|
--output "${output_root}/${name}-c${concurrency}.json" \
|
|
> /dev/null
|
|
echo "Completed ${name} at concurrency ${concurrency}."
|
|
done
|
|
done
|
|
|
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
|
> "${output_root}/snapshot-after.txt"
|
|
|
|
stop_sampler
|
|
trap - EXIT
|
|
|
|
echo "HTTP benchmark suite completed: $output_root"
|