86 lines
2.3 KiB
Bash
86 lines
2.3 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
# Simple routing verification test
|
||
|
|
|
||
|
|
echo "=== Routing Verification Test ==="
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Kill any existing proxy
|
||
|
|
pkill -f rproxy 2>/dev/null
|
||
|
|
sleep 1
|
||
|
|
|
||
|
|
# Start proxy
|
||
|
|
echo "Starting proxy..."
|
||
|
|
DEBUG=1 ./rproxy > routing_verify.log 2>&1 &
|
||
|
|
PROXY_PID=$!
|
||
|
|
sleep 2
|
||
|
|
|
||
|
|
if ! ps -p $PROXY_PID > /dev/null; then
|
||
|
|
echo "ERROR: Proxy failed to start"
|
||
|
|
cat routing_verify.log
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "Proxy started (PID: $PROXY_PID)"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Test internal routes
|
||
|
|
echo "Testing internal route handling:"
|
||
|
|
|
||
|
|
# Test dashboard 5 times
|
||
|
|
echo -n " Dashboard: "
|
||
|
|
for i in {1..5}; do
|
||
|
|
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8888/dashboard 2>/dev/null)
|
||
|
|
if [ "$response" = "200" ]; then
|
||
|
|
echo -n "✓"
|
||
|
|
else
|
||
|
|
echo -n "✗($response)"
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Test API stats 5 times
|
||
|
|
echo -n " API Stats: "
|
||
|
|
for i in {1..5}; do
|
||
|
|
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8888/api/stats 2>/dev/null)
|
||
|
|
if [ "$response" = "200" ]; then
|
||
|
|
echo -n "✓"
|
||
|
|
else
|
||
|
|
echo -n "✗($response)"
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
echo ""
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Check routing decisions in log
|
||
|
|
echo "Analyzing routing decisions:"
|
||
|
|
dashboard_internal=$(grep "ROUTING-INTERNAL.*DASHBOARD" routing_verify.log 2>/dev/null | wc -l)
|
||
|
|
api_internal=$(grep "ROUTING-INTERNAL.*API STATS" routing_verify.log 2>/dev/null | wc -l)
|
||
|
|
dashboard_forward=$(grep "ROUTING-FORWARD.*dashboard" routing_verify.log 2>/dev/null | wc -l)
|
||
|
|
api_forward=$(grep "ROUTING-FORWARD.*api/stats" routing_verify.log 2>/dev/null | wc -l)
|
||
|
|
|
||
|
|
echo " ✓ Dashboard handled internally: $dashboard_internal times"
|
||
|
|
echo " ✓ API stats handled internally: $api_internal times"
|
||
|
|
|
||
|
|
if [ "$dashboard_forward" -gt 0 ]; then
|
||
|
|
echo " ✗ Dashboard incorrectly forwarded: $dashboard_forward times"
|
||
|
|
fi
|
||
|
|
if [ "$api_forward" -gt 0 ]; then
|
||
|
|
echo " ✗ API stats incorrectly forwarded: $api_forward times"
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Cleanup
|
||
|
|
kill $PROXY_PID 2>/dev/null
|
||
|
|
wait $PROXY_PID 2>/dev/null
|
||
|
|
|
||
|
|
# Verdict
|
||
|
|
if [ "$dashboard_forward" -eq 0 ] && [ "$api_forward" -eq 0 ] && [ "$dashboard_internal" -gt 0 ] && [ "$api_internal" -gt 0 ]; then
|
||
|
|
echo "✅ SUCCESS: All internal routes are properly handled!"
|
||
|
|
echo " /dashboard and /api/stats are ALWAYS served internally, never forwarded."
|
||
|
|
exit 0
|
||
|
|
else
|
||
|
|
echo "❌ FAILURE: Routing issues detected"
|
||
|
|
exit 1
|
||
|
|
fi
|