-
Notifications
You must be signed in to change notification settings - Fork 145
115 lines (96 loc) · 3.6 KB
/
Copy pathmetrics-integration-tests.yml
File metadata and controls
115 lines (96 loc) · 3.6 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Metrics Exporter Integration Tests
on:
pull_request:
push:
branches: [main]
jobs:
metrics-integration-test:
name: Metrics Exporter Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-metrics-${{ hashFiles('**/Cargo.lock') }}
- name: Build metrics exporter
run: cargo build --manifest-path metrics/Cargo.toml --release
- name: Start metrics exporter
env:
RUST_LOG: debug
run: |
timeout 30 ./metrics/target/release/router-metrics-exporter \
--listen 0.0.0.0:9090 \
--rpc-url http://localhost:8000 &
EXPORTER_PID=$!
sleep 2
echo "EXPORTER_PID=$EXPORTER_PID" >> $GITHUB_ENV
continue-on-error: true
- name: Validate metrics endpoint
run: |
# Check if metrics endpoint is accessible
RESPONSE=$(curl -s -w "\n%{http_code}" http://localhost:9090/metrics || echo "000")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | head -n-1)
if [ "$HTTP_CODE" != "200" ]; then
echo "❌ Metrics endpoint returned HTTP $HTTP_CODE"
exit 1
fi
echo "✅ Metrics endpoint is accessible (HTTP 200)"
# Validate Prometheus format
if echo "$BODY" | grep -q "^# HELP"; then
echo "✅ Prometheus format detected (HELP lines present)"
else
echo "⚠️ No HELP lines found in metrics output"
fi
if echo "$BODY" | grep -q "^# TYPE"; then
echo "✅ Prometheus TYPE lines present"
else
echo "⚠️ No TYPE lines found in metrics output"
fi
- name: Validate expected metrics
run: |
METRICS_OUTPUT=$(curl -s http://localhost:9090/metrics)
EXPECTED_METRICS=(
"router_core_routes_total"
"router_core_resolutions_total"
"router_middleware_rate_limit_hits_total"
"router_registry_entries_total"
)
MISSING_METRICS=0
for metric in "${EXPECTED_METRICS[@]}"; do
if echo "$METRICS_OUTPUT" | grep -q "$metric"; then
echo "✅ Found metric: $metric"
else
echo "⚠️ Missing metric: $metric (expected but not found)"
MISSING_METRICS=$((MISSING_METRICS + 1))
fi
done
if [ $MISSING_METRICS -gt 0 ]; then
echo ""
echo "Note: Some expected metrics were not found. This may be expected if contracts are not initialized."
fi
- name: Test metrics scrape performance
run: |
START_TIME=$(date +%s%N)
curl -s http://localhost:9090/metrics > /dev/null
END_TIME=$(date +%s%N)
DURATION_MS=$(( (END_TIME - START_TIME) / 1000000 ))
echo "Metrics scrape took ${DURATION_MS}ms"
if [ $DURATION_MS -gt 5000 ]; then
echo "⚠️ Metrics scrape took longer than 5 seconds"
else
echo "✅ Metrics scrape performance is acceptable"
fi
- name: Cleanup
if: always()
run: |
if [ -n "$EXPORTER_PID" ]; then
kill $EXPORTER_PID 2>/dev/null || true
fi