docs/e2e-tests.md
This document describes the comprehensive end-to-end test suite for eCapture modules.
The e2e test suite validates that eCapture can successfully capture various types of system activity:
bash): Tests bash command capturezsh): Tests zsh command capturemysqld): Tests MySQL query capturepostgres): Tests PostgreSQL query capturetls): Tests OpenSSL/BoringSSL traffic capturegnutls): Tests GnuTLS library traffic capturegotls): Tests Go's native TLS implementation captureCAP_SYS_ADMIN and CAP_BPF (on newer kernels)All modules:
openssl - For certificate generationnc (netcat) - For port checkinggo - Go compiler (1.24 or newer)clang - Clang compiler (version 12 or newer)Module-specific:
python3, curlwget (optional, for GnuTLS-based client)libgnutls30 or libgnutls28 - GnuTLS library (for GnuTLS test)libssl1.1 or libssl3 - OpenSSL library (for TLS test)Run all e2e tests:
sudo make e2e
Run specific module tests:
# Simple probe tests
sudo make e2e-bash # Test Bash command capture
sudo make e2e-zsh # Test Zsh command capture (requires zsh)
sudo make e2e-mysql # Test MySQL query capture (requires MySQL/MariaDB)
sudo make e2e-postgres # Test PostgreSQL query capture (requires PostgreSQL)
# TLS/SSL probe tests
sudo make e2e-tls # Test TLS/OpenSSL capture
sudo make e2e-gnutls # Test GnuTLS capture
sudo make e2e-gotls # Test GoTLS capture
You can also run test scripts directly:
# Make sure scripts are executable
chmod +x test/e2e/*.sh
# Run individual tests
sudo bash test/e2e/bash_e2e_test.sh
sudo bash test/e2e/zsh_e2e_test.sh
sudo bash test/e2e/mysql_e2e_test.sh
sudo bash test/e2e/postgres_e2e_test.sh
sudo bash test/e2e/tls_e2e_test.sh
sudo bash test/e2e/gnutls_e2e_test.sh
sudo bash test/e2e/gotls_e2e_test.sh
Each e2e test follows this general flow:
Prerequisites Check
Build Phase
Execution Phase
Verification Phase
Cleanup Phase
test/e2e/common.sh)Shared functions for all tests:
Bash Test (test/e2e/bash_e2e_test.sh)
Zsh Test (test/e2e/zsh_e2e_test.sh)
MySQL Test (test/e2e/mysql_e2e_test.sh)
PostgreSQL Test (test/e2e/postgres_e2e_test.sh)
TLS Test (test/e2e/tls_e2e_test.sh)
GnuTLS Test (test/e2e/gnutls_e2e_test.sh)
GoTLS Test (test/e2e/gotls_e2e_test.sh)
test/e2e/go_https_client.go)When tests pass, you'll see:
[INFO] === TLS E2E Test ===
[INFO] === Step 1: Prerequisites Check ===
[INFO] Kernel version: 5.15.0 (OK)
[INFO] All required tools are present
...
[SUCCESS] ✓ TLS E2E test PASSED
[SUCCESS] eCapture successfully captured TLS plaintext traffic
On failure, tests display:
Example:
[ERROR] Test failed. Showing logs:
=== Server Log ===
...
=== eCapture Log ===
...
=== Client Log ===
...
External Dependency: Tests connect to https://github.com
GnuTLS Test: wget/curl may use OpenSSL instead of GnuTLS
Timing Sensitivity: Tests use sleep delays for process startup
Output Formats: eCapture output format may vary by:
[ERROR] This test requires root privileges
Solution: Run with sudo:
sudo make e2e-tls
[ERROR] Kernel version 4.15.0 is too old. Required: >= 4.18
Solution: Upgrade kernel or use a newer system
[ERROR] Missing required tools: curl python3
Solution: Install required packages:
# Ubuntu/Debian
sudo apt-get install curl python3 openssl netcat-openbsd
# RHEL/CentOS
sudo yum install curl python3 openssl nc
[ERROR] Port 8443 did not open within 10s
Solution: Check if port is in use:
sudo netstat -tlnp | grep 8443
# Kill the process using the port
sudo kill <pid>
[ERROR] Failed to build ecapture
Solution: Check build requirements:
# Install build dependencies
sudo apt-get install clang llvm libelf-dev pkg-config golang-go
# Try manual build
make clean
make all
[ERROR] eCapture process died
Solution: Check logs and system support:
sudo dmesg | grep -i bpfls /sys/kernel/btf/vmlinuxFor more verbose output, you can:
# Logs are in /tmp/ecapture_*_e2e_*/output/
ls -la /tmp/ecapture_*_e2e_*/output/
# Run in foreground to see output
sudo ./bin/ecapture tls -m text
./bin/ecapture tls -h
./bin/ecapture gnutls -h
./bin/ecapture gotls -h
name: E2E Tests
on: [push, pull_request]
jobs:
e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang llvm libelf-dev pkg-config \
golang-go curl python3 openssl netcat-openbsd
- name: Run E2E tests
run: |
sudo make e2e
Run tests in Docker with privileged mode:
docker run --rm -it --privileged \
-v "$(pwd)":/src -w /src \
ubuntu:22.04 /bin/bash -c "
apt-get update && \
apt-get install -y build-essential clang llvm libelf-dev \
pkg-config golang-go git libpcap-dev \
bpftool ca-certificates curl python3 openssl netcat-openbsd && \
make all && \
make e2e
"
To add a new e2e test:
test/e2e/mymodule_e2e_test.shsource "$SCRIPT_DIR/common.sh".PHONY: e2e-mymodule
e2e-mymodule:
bash ./test/e2e/mymodule_e2e_test.sh
e2e target to include new test/tmp for artifactsWhen modifying e2e tests:
sudo make e2eFor issues or questions:
/tmp/ecapture_*_e2e_*/output/uname -r)cat /etc/os-release)