-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-hub.sh
More file actions
executable file
·95 lines (78 loc) · 2 KB
/
Copy pathtest-hub.sh
File metadata and controls
executable file
·95 lines (78 loc) · 2 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
#!/bin/bash
# Test GraphLens Telemetry Hub
set -e
cd "$(dirname "$0")/../.."
# Source environment
source .env
# Start hub in background
echo "Starting hub..."
node tools/observability-hub/index.js > /tmp/hub-test.log 2>&1 &
HUB_PID=$!
# Wait for hub to start
sleep 2
# Test health endpoint
echo "Testing /health..."
curl -s http://localhost:3000/health | jq .
# Generate HMAC signature for test payload
echo ""
echo "Testing /telemetry with HMAC auth..."
node -e "
const { generateSignature } = require('./backend/services/hmac-auth.cjs');
const payload = {
timestamp: new Date().toISOString(),
machine_id: 'test-machine',
agent_id: 'marketing',
quality_score: 85,
execution_ms: 120,
overall_pass: true,
bottleneck_type: 'structure'
};
const signature = generateSignature(payload, process.env.GRAPHLENS_AUTH_SECRET);
console.log('Payload:', JSON.stringify(payload));
console.log('Signature:', signature);
// Make POST request
const http = require('http');
const postData = JSON.stringify(payload);
const options = {
hostname: 'localhost',
port: 3000,
path: '/telemetry',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData),
'X-GraphLens-Signature': signature
}
};
const req = http.request(options, (res) => {
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => {
console.log('Response:', data);
});
});
req.on('error', (e) => {
console.error('Error:', e.message);
});
req.write(postData);
req.end();
"
sleep 1
# Test query endpoint
echo ""
echo "Testing /telemetry/query..."
curl -s 'http://localhost:3000/telemetry/query?hours=1&limit=10' | jq '.[] | {timestamp, agent_id, quality_score}'
# Test stats endpoint
echo ""
echo "Testing /telemetry/stats..."
curl -s 'http://localhost:3000/telemetry/stats?hours=1' | jq .
# Cleanup
echo ""
echo "Stopping hub..."
kill $HUB_PID
wait $HUB_PID 2>/dev/null || true
echo ""
echo "Hub log:"
cat /tmp/hub-test.log
echo ""
echo "✅ Hub test complete"