-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_api.sh
More file actions
executable file
·65 lines (58 loc) · 1.55 KB
/
test_api.sh
File metadata and controls
executable file
·65 lines (58 loc) · 1.55 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
#!/bin/bash
echo "🧪 Testing SLOGuard API"
echo "======================="
# Test 1: POST a valid config
echo "📤 Test 1: Posting config for payments-api..."
curl -X POST http://localhost:8080/configs \
-H "Content-Type: application/json" \
-d '{
"service_name": "payments-api",
"endpoints": {
"base_url": "http://payments-api:8080",
"metrics": "/metrics",
"health": "/health"
},
"slo": {
"target": 99.9,
"time_window": "30d"
},
"slis": [
{
"name": "availability",
"query": "up{service=\"payments-api\"}",
"threshold": 1.0,
"comparator": "=="
}
],
"alerting": [
{
"type": "webhook",
"webhook_url": "https://hooks.slack.com/services/example"
}
]
}'
echo -e "\n"
# Test 2: GET the config back
echo "📥 Test 2: Getting config for payments-api..."
curl http://localhost:8080/configs/payments-api
echo -e "\n"
# Test 3: Test case insensitivity
echo "📥 Test 3: Getting config with uppercase name..."
curl http://localhost:8080/configs/PAYMENTS-API
echo -e "\n"
# Test 4: Test non-existent service
echo "❌ Test 4: Getting non-existent service..."
curl http://localhost:8080/configs/nonexistent-service
echo -e "\n"
# Test 5: POST invalid config
echo "❌ Test 5: Posting invalid config..."
curl -X POST http://localhost:8080/configs \
-H "Content-Type: application/json" \
-d '{
"service_name": "",
"endpoints": {"base_url": ""},
"slo": {"target": 0},
"slis": []
}'
echo -e "\n"
echo "✅ All tests completed!"