Move test scripts inside tests/ folder
This commit is contained in:
123
tests/test_ebpf_integration.sh
Executable file
123
tests/test_ebpf_integration.sh
Executable file
@@ -0,0 +1,123 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Test script to verify eBPF integration with new system prompt format
|
||||
|
||||
echo "🧪 Testing eBPF Integration with TensorZero System Prompt Format"
|
||||
echo "=============================================================="
|
||||
echo ""
|
||||
|
||||
# Test 1: Check if agent can parse eBPF-enhanced responses
|
||||
echo "Test 1: eBPF-Enhanced Response Parsing"
|
||||
echo "--------------------------------------"
|
||||
|
||||
cat > /tmp/test_ebpf_response.json << 'EOF'
|
||||
{
|
||||
"response_type": "diagnostic",
|
||||
"reasoning": "Network timeout issues require monitoring TCP connections and system calls to identify bottlenecks at the kernel level.",
|
||||
"commands": [
|
||||
{"id": "net_status", "command": "ss -tulpn | head -10", "description": "Current network connections"},
|
||||
{"id": "net_config", "command": "ip route show", "description": "Network routing configuration"}
|
||||
],
|
||||
"ebpf_programs": [
|
||||
{
|
||||
"name": "tcp_connect_monitor",
|
||||
"type": "kprobe",
|
||||
"target": "tcp_connect",
|
||||
"duration": 15,
|
||||
"description": "Monitor TCP connection attempts"
|
||||
},
|
||||
{
|
||||
"name": "connect_syscalls",
|
||||
"type": "tracepoint",
|
||||
"target": "syscalls/sys_enter_connect",
|
||||
"duration": 15,
|
||||
"filters": {"comm": "curl"},
|
||||
"description": "Monitor connect() system calls from applications"
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "✓ Created test eBPF-enhanced response format"
|
||||
echo ""
|
||||
|
||||
# Test 2: Check agent capabilities
|
||||
echo "Test 2: Agent eBPF Capabilities"
|
||||
echo "-------------------------------"
|
||||
./nannyagent-ebpf test-ebpf 2>/dev/null | grep -E "(eBPF|Capabilities|Programs)" || echo "No eBPF output found"
|
||||
echo ""
|
||||
|
||||
# Test 3: Validate JSON format
|
||||
echo "Test 3: JSON Format Validation"
|
||||
echo "------------------------------"
|
||||
if python3 -m json.tool /tmp/test_ebpf_response.json > /dev/null 2>&1; then
|
||||
echo "✓ JSON format is valid"
|
||||
else
|
||||
echo "❌ JSON format is invalid"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Test 4: Show eBPF program categories from system prompt
|
||||
echo "Test 4: eBPF Program Categories (from system prompt)"
|
||||
echo "---------------------------------------------------"
|
||||
echo "📡 NETWORK issues:"
|
||||
echo " - tracepoint:syscalls/sys_enter_connect"
|
||||
echo " - kprobe:tcp_connect"
|
||||
echo " - kprobe:tcp_sendmsg"
|
||||
echo ""
|
||||
echo "🔄 PROCESS issues:"
|
||||
echo " - tracepoint:syscalls/sys_enter_execve"
|
||||
echo " - tracepoint:sched/sched_process_exit"
|
||||
echo " - kprobe:do_fork"
|
||||
echo ""
|
||||
echo "📁 FILE I/O issues:"
|
||||
echo " - tracepoint:syscalls/sys_enter_openat"
|
||||
echo " - kprobe:vfs_read"
|
||||
echo " - kprobe:vfs_write"
|
||||
echo ""
|
||||
echo "⚡ PERFORMANCE issues:"
|
||||
echo " - tracepoint:syscalls/sys_enter_*"
|
||||
echo " - kprobe:schedule"
|
||||
echo " - tracepoint:irq/irq_handler_entry"
|
||||
echo ""
|
||||
|
||||
# Test 5: Resolution response format
|
||||
echo "Test 5: Resolution Response Format"
|
||||
echo "---------------------------------"
|
||||
cat > /tmp/test_resolution_response.json << 'EOF'
|
||||
{
|
||||
"response_type": "resolution",
|
||||
"root_cause": "TCP connection timeouts are caused by iptables dropping packets on port 443 due to misconfigured firewall rules.",
|
||||
"resolution_plan": "1. Check iptables rules with 'sudo iptables -L -n'\n2. Remove blocking rule: 'sudo iptables -D INPUT -p tcp --dport 443 -j DROP'\n3. Verify connectivity: 'curl -I https://example.com'\n4. Persist rules: 'sudo iptables-save > /etc/iptables/rules.v4'",
|
||||
"confidence": "High",
|
||||
"ebpf_evidence": "eBPF tcp_connect traces show 127 connection attempts with immediate failures. System call monitoring revealed iptables netfilter hooks rejecting packets before reaching the application layer."
|
||||
}
|
||||
EOF
|
||||
|
||||
if python3 -m json.tool /tmp/test_resolution_response.json > /dev/null 2>&1; then
|
||||
echo "✓ Resolution response format is valid"
|
||||
else
|
||||
echo "❌ Resolution response format is invalid"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "🎯 Integration Test Summary"
|
||||
echo "=========================="
|
||||
echo "✅ eBPF-enhanced diagnostic response format ready"
|
||||
echo "✅ Resolution response format with eBPF evidence ready"
|
||||
echo "✅ System prompt includes comprehensive eBPF instructions"
|
||||
echo "✅ Agent supports both traditional and eBPF-enhanced diagnostics"
|
||||
echo ""
|
||||
echo "📋 Next Steps:"
|
||||
echo "1. Deploy the updated system prompt to TensorZero"
|
||||
echo "2. Test with real network/process/file issues"
|
||||
echo "3. Verify AI model understands eBPF program requests"
|
||||
echo "4. Monitor eBPF trace data quality and completeness"
|
||||
echo ""
|
||||
echo "🔧 TensorZero Configuration:"
|
||||
echo " - Copy content from TENSORZERO_SYSTEM_PROMPT.md"
|
||||
echo " - Ensure model supports structured JSON responses"
|
||||
echo " - Test with sample diagnostic scenarios"
|
||||
|
||||
# Cleanup
|
||||
rm -f /tmp/test_ebpf_response.json /tmp/test_resolution_response.json
|
||||
Reference in New Issue
Block a user