forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-synthetic-tests.sh
More file actions
executable file
·63 lines (52 loc) · 2.1 KB
/
Copy pathrun-synthetic-tests.sh
File metadata and controls
executable file
·63 lines (52 loc) · 2.1 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
#!/usr/bin/env bash
# Run GistPin synthetic monitoring tests
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_FILE="${SCRIPT_DIR}/../monitoring/synthetic-config.yml"
TESTS_DIR="${SCRIPT_DIR}/../monitoring/synthetic-tests"
BASE_URL="${BASE_URL:-https://api.gistpin.io}"
FRONTEND_URL="${FRONTEND_URL:-https://gistpin.io}"
TIMEOUT="${TIMEOUT:-10}"
PASS=0
FAIL=0
log() { echo "[$(date -u +%H:%M:%S)] $*"; }
pass() { log "✓ $*"; ((PASS++)); }
fail() { log "✗ $*"; ((FAIL++)); }
run_http_step() {
local name="$1" method="$2" url="$3" expected_status="$4"
url="${url//\{\{ base_url \}\}/$BASE_URL}"
url="${url//\{\{ frontend_url \}\}/$FRONTEND_URL}"
local status
status=$(curl -s -o /dev/null -w "%{http_code}" \
--max-time "$TIMEOUT" -X "$method" "$url" 2>/dev/null || echo "000")
if [[ "$status" == "$expected_status" ]]; then
pass "$name → HTTP $status"
else
fail "$name → expected $expected_status, got $status (url: $url)"
fi
}
log "Starting synthetic tests against $BASE_URL"
log "================================================"
# api-health suite
log "Suite: api-health"
run_http_step "health-check" GET "$BASE_URL/health" 200
run_http_step "readiness-check" GET "$BASE_URL/health/ready" 200
run_http_step "api-version" GET "$BASE_URL/api/v1" 200
run_http_step "frontend-home" GET "$FRONTEND_URL" 200
# geo-query-flow suite
log "Suite: geo-query-flow"
run_http_step "geo-query-sf" \
GET "$BASE_URL/api/v1/gists/nearby?lat=37.7749&lon=-122.4194&radius_km=5&limit=20" 200
run_http_step "geo-query-london" \
GET "$BASE_URL/api/v1/gists/nearby?lat=51.5074&lon=-0.1278&radius_km=5&limit=20" 200
run_http_step "geo-query-singapore" \
GET "$BASE_URL/api/v1/gists/nearby?lat=1.3521&lon=103.8198&radius_km=5&limit=20" 200
run_http_step "geo-query-invalid-coords" \
GET "$BASE_URL/api/v1/gists/nearby?lat=999&lon=999&radius_km=5" 400
log "================================================"
log "Results: $PASS passed, $FAIL failed"
if [[ $FAIL -gt 0 ]]; then
log "SYNTHETIC TESTS FAILED"
exit 1
fi
log "All synthetic tests passed"