-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.sh
More file actions
executable file
·82 lines (73 loc) · 1.95 KB
/
Copy pathtest_api.sh
File metadata and controls
executable file
·82 lines (73 loc) · 1.95 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
#!/bin/bash
# Test script for Baskerville Solo API
API_URL="http://localhost:8000"
echo "=== Testing Baskerville Solo API ==="
echo ""
# 1. Health check
echo "1. Health Check"
curl -s "$API_URL/health" | python3 -m json.tool
echo -e "\n"
# 2. Send single log
echo "2. Sending single log..."
curl -s -X POST "$API_URL/api/v1/logs" \
-H "Content-Type: application/json" \
-d '{
"timestamp": "2025-10-29 12:00:00",
"ip": "192.168.1.100",
"host": "example.com",
"path": "/test.html",
"method": "GET",
"status": 200,
"user_agent": "Mozilla/5.0 (Test Bot)",
"country": "US",
"session_id": "test_session_001"
}' | python3 -m json.tool
echo -e "\n"
# 3. Send batch of logs
echo "3. Sending batch of logs..."
curl -s -X POST "$API_URL/api/v1/logs/batch" \
-H "Content-Type: application/json" \
-d '{
"logs": [
{
"timestamp": "2025-10-29 12:01:00",
"ip": "192.168.1.101",
"host": "example.com",
"path": "/page1.html",
"method": "GET",
"status": 200,
"user_agent": "Chrome/90.0",
"country": "CA"
},
{
"timestamp": "2025-10-29 12:01:01",
"ip": "192.168.1.101",
"host": "example.com",
"path": "/page2.html",
"method": "GET",
"status": 200,
"user_agent": "Chrome/90.0",
"country": "CA"
},
{
"timestamp": "2025-10-29 12:01:02",
"ip": "10.0.0.50",
"host": "testsite.org",
"path": "/api/data",
"method": "POST",
"status": 201,
"user_agent": "Python-requests/2.28",
"country": "GB"
}
]
}' | python3 -m json.tool
echo -e "\n"
# 4. Get predictions
echo "4. Getting recent predictions..."
curl -s "$API_URL/api/v1/predictions?limit=5" | python3 -m json.tool
echo -e "\n"
# 5. Get statistics
echo "5. Getting statistics..."
curl -s "$API_URL/api/v1/stats" | python3 -m json.tool
echo -e "\n"
echo "=== Test completed ==="