-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-message-flow.sh
More file actions
executable file
·113 lines (95 loc) · 3.36 KB
/
debug-message-flow.sh
File metadata and controls
executable file
·113 lines (95 loc) · 3.36 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
#!/bin/bash
echo "=== Git Friends Message Flow Debug ==="
echo
# Check if all components are running
echo "1. Checking component status..."
# Check server
if curl -s http://localhost:8080/health > /dev/null 2>&1; then
echo " ✓ gf-server is running"
else
echo " ✗ gf-server is not running"
echo " 💡 Start with: ./target/release/gf-server --config test-config.toml"
exit 1
fi
# Check MQTT broker
if command -v mosquitto_pub > /dev/null 2>&1; then
echo " ✓ MQTT tools available"
timeout 2 mosquitto_pub -h localhost -p 1883 -t "test/topic" -m "test" 2>/dev/null
if [ $? -eq 0 ]; then
echo " ✓ MQTT broker is reachable"
else
echo " ✗ MQTT broker is not reachable"
echo " 💡 Install and start mosquitto: sudo apt install mosquitto mosquitto-clients"
echo " 💡 Or start with: mosquitto -v"
fi
else
echo " ? MQTT tools not available (install mosquitto-clients to test)"
fi
echo
echo "2. Testing hook → server flow..."
# Test hook with server
echo " Testing hook with actual server..."
RUST_LOG=info ./target/release/gf-hook --dry-run > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo " ✓ Hook works in dry-run mode"
# Test actual send to server
echo " Sending actual request to server..."
RUST_LOG=info ./target/release/gf-hook 2>&1 | grep -q "Successfully sent"
if [ $? -eq 0 ]; then
echo " ✓ Hook successfully sent to server"
else
echo " ✗ Hook failed to send to server"
echo " 💡 Check server logs for errors"
fi
else
echo " ✗ Hook fails in dry-run mode"
fi
echo
echo "3. Testing MQTT message flow..."
# Check if we can subscribe to MQTT topics
if command -v mosquitto_sub > /dev/null 2>&1; then
echo " Subscribing to MQTT topics for 5 seconds..."
timeout 5 mosquitto_sub -h localhost -p 1883 -t "git-friends/+/+/+" -t "git-friends-test/+/+/+" &
MQTT_PID=$!
sleep 1
echo " Sending hook message..."
./target/release/gf-hook > /dev/null 2>&1
wait $MQTT_PID
echo " (Check above for any MQTT messages)"
else
echo " ? Cannot test MQTT directly (mosquitto-clients not available)"
fi
echo
echo "4. Configuration check..."
echo " Current config files:"
if [ -f "test-config.toml" ]; then
echo " ✓ test-config.toml exists"
echo " MQTT topic prefix: $(grep topic_prefix test-config.toml | cut -d'"' -f2)"
else
echo " ✗ test-config.toml missing"
fi
if [ -f "git-friends.toml" ]; then
echo " ✓ git-friends.toml exists"
else
echo " - git-friends.toml not found (using defaults)"
fi
echo
echo "5. Component integration test..."
echo " Testing full flow with verbose logging..."
echo " (This will show detailed logs from all components)"
echo
echo " You should run in separate terminals:"
echo " Terminal 1: RUST_LOG=info ./target/release/gf-server --config test-config.toml"
echo " Terminal 2: RUST_LOG=info ./target/release/gf-irc --config test-config.toml"
echo " Terminal 3: ./target/release/gf-hook"
echo
echo " Or use the automated test below..."
echo
echo "=== Debug Complete ==="
echo
echo "Common issues:"
echo "1. MQTT broker not running (mosquitto)"
echo "2. Components using different topic prefixes"
echo "3. IRC client not subscribed to correct topics"
echo "4. Server not publishing to MQTT"
echo "5. Network connectivity issues"