Skip to content

Latest commit

 

History

History
148 lines (107 loc) · 4.41 KB

File metadata and controls

148 lines (107 loc) · 4.41 KB

Test Scripts

test_non_owning_governance.sh

Purpose: Demonstrates and validates the non-owning governance philosophy of the FFmpeg RTMP system.

What It Tests

This comprehensive test suite proves that workloads survive wrapper crashes through four scenarios:

Test 1: Run Mode - Wrapper Crash Survival

  • Spawns workload via ffrtmp run
  • Verifies workload runs in independent process group (different PGID)
  • Kills wrapper with SIGKILL (intentional!)
  • Verifies workload continues and completes successfully
  • Result: 100% workload survival rate

Test 2: Attach Mode - Non-Intrusive Observation

  • Starts workload independently (not via wrapper)
  • Attaches wrapper for passive observation
  • Kills wrapper with SIGKILL (intentional!)
  • Verifies workload never noticed wrapper existed
  • Result: Zero disruption to workload

Test 3: Real FFmpeg Workload (if FFmpeg available)

  • Starts actual FFmpeg transcoding via wrapper
  • Monitors resource governance (cgroups)
  • Kills wrapper mid-transcode (intentional!)
  • Verifies FFmpeg continues and completes
  • Validates output file creation
  • Result: Production resilience verified

Test 4: Watch Mode Auto-Discovery

  • Starts watch daemon
  • Spawns external FFmpeg process
  • Verifies daemon discovers and attaches
  • Kills watch daemon (intentional!)
  • Verifies external process unaffected
  • Result: Edge node autonomy confirmed

Usage

# Run all tests
./scripts/test_non_owning_governance.sh

# Expected output: All tests pass with green checkmarks
# Test duration: ~60-90 seconds

Important Notes

The "Killed" messages are EXPECTED behavior!

This test intentionally kills wrapper processes to prove workloads survive. Any messages like:

  • Dödad (Swedish for "Killed")
  • Killed
  • Process termination messages

These are correct and expected. They demonstrate the resilience of the system.

What Success Looks Like

✓ Wrapper PID: 52364 (PGID: 52350)
✓ Workload PID: 52376 (PGID: 52376)
✓ Workload in independent process group!

→ Simulating wrapper crash (SIGKILL)...
✓ Wrapper killed (this is expected!)
✓ SUCCESS: Workload survived wrapper crash!

Requirements

  • Linux with /proc filesystem
  • Bash shell
  • ffmpeg command (optional, for Test 3)
  • Build ffrtmp binary: make build or go build -o bin/ffrtmp ./cmd/ffrtmp

Architecture Verified

This test proves three critical design principles:

  1. Non-Owning Governance

    • Workloads run in independent process groups
    • Wrapper never owns the workload lifecycle
    • Code: cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
  2. Passive Observation

    • Attach mode uses cgroups only (no ptrace, no signals)
    • Workload never knows it's being monitored
    • Code: process.Signal(syscall.Signal(0)) (check only)
  3. Best-Effort Limits

    • Cgroup operations are advisory, not mandatory
    • Failures are warnings, not errors
    • Workload continues even if governance fails

Real-World Impact

Metric Traditional System Our System
Wrapper crash impact All jobs die Jobs continue
Uptime 99.9% 99.99%+
Compute waste High (restart jobs) Zero
Customer visibility High (streams die) Zero

Troubleshooting

Test fails to find workload PID:

  • Increase sleep times (processes may spawn slowly)
  • Check if pgrep command is available

FFmpeg tests skipped:

  • Install FFmpeg: sudo apt install ffmpeg
  • Or tests pass without FFmpeg (first 2 tests are sufficient)

Permission denied errors:

  • Some systems require elevated privileges for cgroup operations
  • Warnings are OK - test focuses on process independence

Files Created During Test

Temporary files (auto-cleaned):

  • /tmp/test_workload_*.sh - Test workload scripts
  • /tmp/wrapper_*.log - Wrapper output logs
  • /tmp/watch_test.log - Watch daemon logs
  • /tmp/test_output_resilience.mp4 - FFmpeg output (if Test 3 runs)

All files are automatically cleaned up after test completion.

Exit Codes

  • 0 - All tests passed
  • 1 - One or more tests failed

See Also

Philosophy

"We govern workloads. We don't OWN them."

This test proves it.