Skip to content

faults/network: add packet loss fault - #7

Merged
alexmchughdev merged 1 commit into
mainfrom
phase2/packet-loss
May 17, 2026
Merged

alexmchughdev merged 1 commit into
mainfrom
phase2/packet-loss

Conversation

@alexmchughdev

Copy link
Copy Markdown
Owner

Summary

Stage 1 of Phase 2 (v0.2.0). Adds network_packet_loss as the second
network fault, parallel to network_latency. Same safety contract:
refuse to overwrite a user-installed qdisc, watchdog registration with
heartbeat loop, idempotent revert, post-revert verification.

Structure deliberately mirrors latency.go rather than extracting a
shared base. The dedup pass across the three netem-based faults
(latency, packet loss, partition) is the stabilisation stage, after
partition and DNS failure are in.

  • New fault: internal/faults/network/packet_loss.go. Parameters
    loss_percent (required, 0 < x <= 100) and correlation_percent
    (optional, 0 <= x <= 100).
  • Unit tests in packet_loss_test.go mirror the latency suite
    (validation, qdisc-busy guard, watchdog registration, idempotent
    revert, verify, dry run). Integration tests gated on
    //go:build integration exercise a real dummy interface.
  • New CLI subcommand: scorpius inject network-packet-loss with
    --loss and --correlation flags, plus the existing shared
    duration/audit/watchdog flags.

Test plan

  • go vet ./...
  • go build -tags integration ./...
  • go test -race -count=1 ./... (unit suite, all green)
  • sudo go test -race -count=1 -tags integration ./internal/faults/network/ on a host with tc/ip (runs against a dummy interface; expected post-merge before tagging v0.2.0)
  • End-to-end CLI dry-run smoke test against the built binary

Second network fault for Phase 2. Mirrors the latency fault's structure
deliberately: the dedup pass across the three netem-based faults comes
after partition and dns failure exist, in the Fault interface
stabilisation stage. Same safety contract: refuse to overwrite a
user-installed qdisc, watchdog registration with heartbeat loop,
idempotent revert, post-revert verification.

Parameters: loss_percent (required, 0 < x <= 100) and
correlation_percent (optional, 0 <= x <= 100). CLI: scorpius inject
network-packet-loss with --loss, --correlation, and the same shared
duration/audit/watchdog flags as network-latency.
@alexmchughdev

Copy link
Copy Markdown
Owner Author

/lgtm

@alexmchughdev alexmchughdev reopened this May 17, 2026
@alexmchughdev
alexmchughdev merged commit 1ff0035 into main May 17, 2026
11 checks passed
@alexmchughdev
alexmchughdev deleted the phase2/packet-loss branch May 17, 2026 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant