-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_realistic_tests.sh
More file actions
executable file
·168 lines (148 loc) · 6.76 KB
/
run_realistic_tests.sh
File metadata and controls
executable file
·168 lines (148 loc) · 6.76 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
# SentinelEdge Realistic Testing Script
# This script demonstrates the real testing capabilities we've added
set -e
echo "🚀 SentinelEdge Realistic Testing Demonstration"
echo "=============================================="
# Check if running as root
if [ "$EUID" -eq 0 ]; then
echo "✅ Running with root privileges - can demonstrate full capabilities"
HAS_ROOT=true
else
echo "⚠️ Running without root privileges - some tests will be simulated"
HAS_ROOT=false
fi
echo ""
echo "📊 Test Categories Available:"
echo "1. Unit Tests (Mock Mode) - ✅ Available"
echo "2. Integration Tests (Mock Mode) - ✅ Available"
echo "3. Real eBPF Integration Tests - $(if [ "$HAS_ROOT" = true ]; then echo "✅ Available"; else echo "❌ Requires root"; fi)"
echo "4. Performance Benchmarks - ✅ Available"
echo "5. System Stress Testing - $(if [ "$HAS_ROOT" = true ]; then echo "✅ Available"; else echo "❌ Requires root"; fi)"
echo "6. Real eBPF Demo - $(if [ "$HAS_ROOT" = true ]; then echo "✅ Available"; else echo "❌ Requires root"; fi)"
echo ""
echo "🧪 What makes our tests authentic and realistic:"
echo ""
echo "📁 Realistic Test Data:"
echo " • Process names from actual Linux systems (systemd, kthreadd, etc.)"
echo " • File paths from real filesystem locations (/proc, /sys, /var/log)"
echo " • Network patterns based on actual traffic (HTTP, SSH, DNS)"
echo " • Timing patterns from real system measurements"
echo ""
echo "⚡ Performance Testing:"
echo " • Event parsing with realistic Linux syscall structures"
echo " • Batch processing with production-sized workloads"
echo " • Concurrent processing simulating real system load"
echo " • End-to-end latency measurement under actual conditions"
echo ""
echo "🔧 System Integration:"
echo " • Real file system operations (create/read/delete files)"
echo " • Actual process spawning (system commands)"
echo " • Memory pressure testing with realistic allocation patterns"
echo " • Network activity generation with real protocols"
echo ""
# If we have root, show what we can do
if [ "$HAS_ROOT" = true ]; then
echo "💪 Root Privileges Available - Full Testing Capabilities:"
echo " • Real eBPF program loading simulation"
echo " • Kernel ring buffer interaction"
echo " • Actual system event capture"
echo " • Real-time performance measurement"
echo " • System resource monitoring"
echo ""
echo "🎯 Demonstrating Real System Integration:"
echo " Creating real filesystem activity..."
# Generate some real system activity
for i in {1..5}; do
echo "test data $i" > "/tmp/sentinel_demo_$i.txt"
cat "/tmp/sentinel_demo_$i.txt" > /dev/null
rm "/tmp/sentinel_demo_$i.txt"
done
echo " ✅ Generated realistic file operations"
echo " Creating real process activity..."
for cmd in "date" "id" "pwd" "uname -r"; do
$cmd > /dev/null 2>&1
done
echo " ✅ Generated realistic process events"
echo " Testing network connectivity..."
ping -c 1 127.0.0.1 > /dev/null 2>&1
echo " ✅ Generated realistic network events"
echo ""
echo "📈 System Impact Measurement:"
echo " • Current memory usage: $(ps -o rss -p $$ | tail -1 | tr -d ' ') KB"
echo " • Current process count: $(ps aux | wc -l)"
echo " • Current load average: $(uptime | awk -F'load average:' '{print $2}')"
echo ""
else
echo "🔒 Limited Privileges - Demonstrating Mock Capabilities:"
echo " • Simulated eBPF event processing"
echo " • Mock kernel interaction"
echo " • Realistic data generation without system access"
echo " • Performance measurement of processing pipeline"
echo ""
fi
echo "🎨 Test Data Authenticity Examples:"
echo ""
echo "Real Linux Process Names Used:"
echo "systemd, kthreadd, ksoftirqd, kworker, NetworkManager, systemd-resolved"
echo "cron, dbus-daemon, rsyslog, sshd, bash, vim, curl, python3"
echo ""
echo "Real Linux File Paths Used:"
echo "/proc/meminfo, /sys/devices/system/cpu/*, /var/log/syslog"
echo "/etc/passwd, /run/systemd/*, /usr/lib/systemd/*, /tmp/*"
echo ""
echo "Real Network Patterns:"
echo "TCP connections, UDP packets, Loopback traffic, DNS queries"
echo "HTTP requests, SSH connections, Common ports (80, 443, 22, 53)"
echo ""
echo "📊 Performance Baselines We Test Against:"
echo " • Event parsing: <500ns per event"
echo " • End-to-end latency: <50μs P95"
echo " • Throughput: >10K events/sec sustained"
echo " • Memory growth: <100MB under load"
echo " • Drop rate: <5% under stress"
echo ""
echo "🔍 Validation Methods:"
echo " • Timestamp validation (not zero, not future)"
echo " • Process ID validation (>0, <65536)"
echo " • User ID validation (real system UIDs)"
echo " • File path validation (real filesystem structure)"
echo " • Event structure validation (matches kernel layouts)"
echo ""
if [ "$HAS_ROOT" = true ]; then
echo "🚀 Ready to run full test suite with root privileges!"
echo ""
echo "To run the tests:"
echo " • Unit tests: cargo test tests::"
echo " • Integration tests: cargo test integration_tests::"
echo " • Real eBPF tests: sudo -E cargo test real_integration_tests::"
echo " • Performance benchmarks: cargo bench"
echo " • System stress test: sudo cargo run --release --example system_stress_test"
echo " • Real eBPF demo: sudo cargo run --release --example real_ebpf_demo"
else
echo "ℹ️ To unlock full testing capabilities:"
echo " Run this script with root privileges: sudo $0"
echo ""
echo "Available without root:"
echo " • Unit tests: cargo test tests::"
echo " • Integration tests: cargo test integration_tests::"
echo " • Performance benchmarks: cargo bench"
fi
echo ""
echo "📖 For detailed testing instructions, see:"
echo " • TESTING.md - Comprehensive testing guide"
echo " • DEPLOYMENT.md - Production deployment testing"
echo " • OPERATIONS.md - Operational testing procedures"
echo ""
echo "✨ Key Improvements Made:"
echo " 1. ✅ Real eBPF integration tests requiring root privileges"
echo " 2. ✅ Realistic event data based on actual Linux system patterns"
echo " 3. ✅ Performance benchmarks using production-grade configurations"
echo " 4. ✅ System stress testing with actual filesystem/process operations"
echo " 5. ✅ Comprehensive demonstration programs showing real capabilities"
echo " 6. ✅ Validation ensuring test data authenticity and realism"
echo ""
echo "🎯 This testing suite demonstrates production-ready capabilities"
echo " suitable for enterprise deployment and interview presentations."
echo ""
echo "✅ SentinelEdge testing demonstration complete!"