Files
m3db-vke-setup/test-metrics.sh
biondizzle d35cd2d7d4 Update test scripts to accept full URL instead of LB_IP
- test-metrics.sh and test-metrics.py now take a full URL with port
- Supports both HTTP and HTTPS endpoints
- Updated README with new usage examples
2026-04-01 02:38:47 +00:00

78 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
#
# Simple M3DB connectivity test
# Usage: ./test-metrics.sh <BASE_URL>
#
set -e
BASE_URL="${1:-}"
if [ -z "$BASE_URL" ]; then
echo "Usage: $0 <BASE_URL>"
echo "Example: $0 https://m3db.vultrlabs.dev:7201"
echo " $0 http://192.168.1.100:7201"
exit 1
fi
# Remove trailing slash if present
BASE_URL="${BASE_URL%/}"
echo "=== M3DB Connectivity Test ==="
echo "Target: ${BASE_URL}"
echo ""
# Health check
echo "1. Coordinator Health"
if curl -sf "${BASE_URL}/health" > /dev/null 2>&1; then
echo " ✓ Healthy"
else
echo " ✗ Unhealthy or unreachable"
exit 1
fi
# Placement
echo ""
echo "2. Placement (cluster topology)"
PLACEMENT=$(curl -sf "${BASE_URL}/api/v1/services/m3db/placement" 2>/dev/null || echo '{}')
INSTANCE_COUNT=$(echo "$PLACEMENT" | python3 -c "import sys,json; d=json.load(sys.stdin).get('placement',{}).get('instances',{}); print(len(d))" 2>/dev/null || echo "0")
if [ "$INSTANCE_COUNT" -gt 0 ]; then
echo "$INSTANCE_COUNT instances in placement"
echo "$PLACEMENT" | python3 -c "import sys,json; d=json.load(sys.stdin).get('placement',{}).get('instances',{}); [print(f' - {k}') for k in d.keys()]" 2>/dev/null || true
else
echo " ✗ No placement configured (run init job)"
fi
# Namespaces
echo ""
echo "3. Namespaces (retention policies)"
NAMESPACES=$(curl -sf "${BASE_URL}/api/v1/services/m3db/namespace" 2>/dev/null || echo '{}')
NS_COUNT=$(echo "$NAMESPACES" | python3 -c "import sys,json; d=json.load(sys.stdin).get('registry',{}).get('namespaces',{}); print(len(d))" 2>/dev/null || echo "0")
if [ "$NS_COUNT" -gt 0 ]; then
echo "$NS_COUNT namespaces configured"
echo "$NAMESPACES" | python3 -c "import sys,json; d=json.load(sys.stdin).get('registry',{}).get('namespaces',{}); [print(f' - {k}') for k in d.keys()]" 2>/dev/null || true
else
echo " ✗ No namespaces configured (run init job)"
fi
# Query test
echo ""
echo "4. Query Test (PromQL)"
QUERY_RESULT=$(curl -sf "${BASE_URL}/api/v1/query?query=up" 2>/dev/null || echo '{"status":"error"}')
STATUS=$(echo "$QUERY_RESULT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('status','error'))" 2>/dev/null || echo "error")
if [ "$STATUS" = "success" ]; then
RESULT_COUNT=$(echo "$QUERY_RESULT" | python3 -c "import sys,json; print(len(json.load(sys.stdin).get('data',{}).get('result',[])))" 2>/dev/null || echo "0")
echo " ✓ Query returned: $RESULT_COUNT series"
else
echo " ✗ Query failed"
fi
# Write test (requires protobuf + snappy, so just note it)
echo ""
echo "5. Write Test"
echo " Note: Prometheus remote_write requires protobuf + snappy encoding."
echo " Use test-metrics.py for full write/read verification."
echo " Install: pip install python-snappy requests"
echo ""
echo "=== Test Complete ==="