76 lines
2.6 KiB
Bash
Executable File
76 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
profile=${1:-full}
|
|
case "$profile" in
|
|
smoke|full) ;;
|
|
*)
|
|
echo "usage: $0 [smoke|full]" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
env_file=${ENV_FILE:-lab7.env.example}
|
|
base_url=${BASE_URL:-https://localhost:8443}
|
|
ca_file=${CA_FILE:-.runtime/security/public-ca/ca.crt}
|
|
prometheus_url=${PROMETHEUS_URL:-http://127.0.0.1:9090}
|
|
tempo_url=${TEMPO_URL:-http://127.0.0.1:3200}
|
|
loki_url=${LOKI_URL:-http://127.0.0.1:3100}
|
|
run_id=$(date -u +%Y%m%dT%H%M%SZ)
|
|
output_dir=${EVIDENCE_DIR:-evidence/runtime/lab6-$run_id}
|
|
mkdir -p "$output_dir"
|
|
|
|
compose() {
|
|
docker compose --env-file "$env_file" "$@"
|
|
}
|
|
|
|
restore() {
|
|
compose up -d postgres redis-broker s3 valkey api nginx dispatcher worker otel-collector prometheus loki tempo grafana >/dev/null 2>&1 || true
|
|
}
|
|
|
|
trap restore EXIT INT TERM
|
|
|
|
test -f "$env_file"
|
|
compose config --quiet
|
|
compose up -d --build --wait --wait-timeout 180
|
|
python3 scripts/lab6-traffic.py \
|
|
--base-url "$base_url" \
|
|
--ca-file "$ca_file" \
|
|
--mode mixed \
|
|
--duration "${BASELINE_LOAD_SECONDS:-15}" \
|
|
--requests "${BASELINE_REQUESTS:-120}" \
|
|
--concurrency 4 \
|
|
--rate "${BASELINE_LOAD_RATE:-10}" \
|
|
--wait-ready \
|
|
--ready-timeout 120 \
|
|
--output "$output_dir/baseline-traffic.json" >/dev/null
|
|
python3 scripts/lab6-observe.py \
|
|
--prometheus-url "$prometheus_url" \
|
|
--phase baseline \
|
|
--output "$output_dir/baseline-observability.json" >/dev/null
|
|
python3 scripts/lab6-correlation.py \
|
|
--tempo-url "$tempo_url" \
|
|
--loki-url "$loki_url" \
|
|
--output "$output_dir/baseline-correlation.json" \
|
|
--require >/dev/null
|
|
|
|
if [ "$profile" = "full" ]; then
|
|
ENV_FILE="$env_file" BASE_URL="$base_url" CA_FILE="$ca_file" PROMETHEUS_URL="$prometheus_url" TEMPO_URL="$tempo_url" LOKI_URL="$loki_url" EVIDENCE_DIR="$output_dir/incidents" scripts/incident-database.sh
|
|
ENV_FILE="$env_file" BASE_URL="$base_url" CA_FILE="$ca_file" PROMETHEUS_URL="$prometheus_url" EVIDENCE_DIR="$output_dir/incidents" scripts/incident-worker.sh long
|
|
ENV_FILE="$env_file" BASE_URL="$base_url" CA_FILE="$ca_file" PROMETHEUS_URL="$prometheus_url" EVIDENCE_DIR="$output_dir/incidents" scripts/incident-worker.sh short
|
|
ENV_FILE="$env_file" BASE_URL="$base_url" CA_FILE="$ca_file" PROMETHEUS_URL="$prometheus_url" EVIDENCE_DIR="$output_dir/incidents" scripts/incident-telemetry.sh
|
|
fi
|
|
|
|
arguments=
|
|
if [ "$profile" = "full" ]; then
|
|
arguments="--require-incidents"
|
|
if [ "${REQUIRE_ALERT_TRANSITIONS:-1}" = "1" ]; then
|
|
arguments="$arguments --require-alerts"
|
|
fi
|
|
fi
|
|
# shellcheck disable=SC2086
|
|
python3 scripts/validate-lab6-evidence.py "$output_dir" $arguments
|
|
trap - EXIT INT TERM
|
|
printf '%s\n' "$output_dir"
|