Skip to content

Testing

~11,000 lines of tests across 25 test files. Zero mocks for VM tests — all Firecracker integration tests run on real microVMs.

Test at the real boundary. The server tests use real Docker/Firecracker engines, not mocks. Mocks silently accept any input and hide broken behavior.

Test the protocol without VMs. Lohar has a test mode that listens on Unix sockets instead of vsock/TCP. The entire protocol handler test suite (40+ tests) runs on macOS in under 2 seconds without root or KVM.

Test performance with percentiles. Tests report p50/p95/p99, not averages. Assertions are on p99 to catch regressions.

Protocol and agent tests (macOS/Linux, no root)

Section titled “Protocol and agent tests (macOS/Linux, no root)”
Terminal window
go test ./pkg/agent/proto/ # frame encoding, round-trips
go test ./cmd/lohar/ # agent handlers via Unix socket
go test ./pkg/agent/ # host-side client
Terminal window
go test ./pkg/server/ # API, proxy, streaming, thermal

Firecracker integration tests (Linux, KVM, root)

Section titled “Firecracker integration tests (Linux, KVM, root)”
Terminal window
sudo go test ./pkg/engine/firecracker/ -count=1
Terminal window
sudo go test ./pkg/engine/firecracker/ -run TestPerf -count=1
CategoryLocationRequiresCount
Protocolpkg/agent/proto/Nothing~15
Agentcmd/lohar/Nothing~40
Clientpkg/agent/Nothing~10
Serverpkg/server/Docker~30
Enginepkg/engine/firecracker/KVM, root~25
Performancepkg/engine/firecracker/KVM, root~8
CLIcmd/bhatti/Firecracker~11
Recoverycmd/bhatti/Nothing~8
  • Protocol tests — binary framing: round-trips, EOF handling, max frame size, concurrent writes
  • Agent tests — exec (exit codes, env vars, kill, process groups), TTY sessions (detach/reattach, scrollback, resize), files (read/write/stat/ls, truncation, atomicity)
  • Server tests — API endpoints, auth, streaming exec (NDJSON), proxy, thermal cycle, volume management
  • Engine tests — full VM lifecycle, snapshot/restore, diff snapshots, networking (bridge, cross-VM), TAP cleanup
  • Performance tests — exec latency, file I/O, concurrent operations, warm→exec, snapshot timings
  • CLI tests — end-to-end: create → exec → file → shell → destroy
  • Recovery tests — daemon restart scenarios: crashed VMs, missing snapshots, orphaned state