Skip to main content

Test Suite Overview

ML Defender employs a multi-layered testing strategy validated with real-world datasets and stress testing.

Unit Tests

25+ tests covering core algorithms

Integration Tests

End-to-end pipeline validation

Stress Tests

36K+ events, 17-hour stability

Test Structure

Unit Tests

Located in */tests/ directories:

Integration Tests


Running Tests

Quick Unit Tests

All Components

With Valgrind (Leak Detection)


Stress Testing

8-Hour Stability Test

Validated with 36,000 events across 4 progressive tests (source/stress_test_8h.sh).
Test Phases (from source/stress_test_8h.sh:575-613):
  1. Warm-up (30 min): Low load, gradual increase
  2. Normal Load (2 hours): Mixed protocols (HTTP/HTTPS/DNS)
  3. Stress Testing (1.5 hours): High bursts (50/s)
  4. Ransomware Simulation (1 hour): Suspicious patterns
  5. Sustained Load (3 hours): Continuous moderate traffic
  6. Cool Down (30 min): Gradual reduction

Stress Test Results (Day 52)

From source/README.md:179-203: Totals (36K events):

Synthetic Traffic Generation

Tools Available

From source/tools/:

Traffic Profiles

Hospital Benchmark (source/scripts/day11_hospital_benchmark/):

Validation Scripts

Crypto Pipeline Validation

Verifies:
  • ✅ ChaCha20-Poly1305 encryption/decryption
  • ✅ LZ4 compression/decompression
  • ✅ Protobuf serialization
  • ✅ Zero errors at 36K events

Firewall Integration

Validates:
  • ✅ IPSet creation and rules
  • ✅ Event reception from ml-detector
  • ✅ Decryption and decompression
  • ✅ IP blocking via iptables

Full Ecosystem

End-to-end test:
  1. Start etcd-server
  2. Start sniffer (eBPF capture)
  3. Start ml-detector (inference)
  4. Start firewall-acl-agent (blocking)
  5. Generate synthetic traffic
  6. Verify all components healthy

Test Datasets

CTU-13 Neris Botnet

Used for ransomware detection validation (source/README.md:289-292).
Expected Results:
  • 492K events processed
  • 97.6% ransomware detection accuracy
  • 0 crashes, 0 memory leaks

Dataset Structure


Performance Benchmarks

17-Hour Stability Test Results

From source/TESTING.md:164-182:

Component Latency

From source/TESTING.md:282-296: End-to-end latency:
  • Normal path: ~64 μs
  • Suspicious path: ~212 μs

Coverage and CI/CD

Test Coverage Goals

  • Unit tests: >80% code coverage
  • Integration tests: All critical paths
  • Stress tests: 24h+ continuous operation

Current Coverage

From source/TESTING.md:353-361:

CI/CD Pipeline (Planned)

.github/workflows/test.yml

Test-Driven Development

Writing New Tests

Example: Adding a new feature to PayloadAnalyzer
sniffer/tests/test_payload_analyzer.cpp

Test Naming Convention


Debugging Failed Tests

Common Issues

Test fails intermittently:
Memory errors:
Performance regression:

Next Steps

Build System

Understand CMake and Makefile configuration

Stress Testing

Deep dive into stress test methodology

eBPF/XDP

Learn eBPF packet capture internals

Performance

Optimize and benchmark components