Skip to content

test(interop): tcpdump-based wire-equivalence test against upstream (#2075) - #4239

Merged
oferchen merged 1 commit into
masterfrom
test/tcpdump-wire-equivalence-2075
May 17, 2026
Merged

oferchen merged 1 commit into
masterfrom
test/tcpdump-wire-equivalence-2075

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • New tcpdump+tshark harness that captures the wire traffic produced by upstream rsync 3.4.1 and oc-rsync running the same daemon push, then hashes and diffs the normalized application payload.
  • POSIX-sh script under scripts/wire-equivalence-tcpdump.sh, a CI wrapper at tools/ci/run_wire_equivalence.sh, and a Rust integration test at crates/protocol/tests/wire_equivalence_tcpdump.rs that all skip gracefully when prerequisites (Linux, tcpdump, tshark, both binaries) are absent.
  • Scratch state lives entirely under ${TMPDIR:-/tmp}/oc-rsync-wire-equiv.$$ and the cleanup trap refuses to rm -rf anything outside that scope, so the harness is safe to run inside the rsync-profile container with its host bind mount.

What the harness asserts

  • Same input tree (100 deterministic small files by default).
  • Two daemons on loopback - upstream listening on ${WIRE_EQUIV_PORT_BASE} (default 28730), oc-rsync on ${WIRE_EQUIV_PORT_BASE}+1.
  • Upstream rsync client pushes to each in turn while tcpdump captures both ports.
  • tshark -T fields reassembles per-stream payload, ephemeral source ports are normalized to S/C, and SHA-256 over the projection is compared.
  • Exit 0 = match, exit 1 = divergence (pcaps retained, first 40 diff lines logged), exit 77 = skip, exit 2 = setup error.

Known limitations

  • Per-session checksum seeds and MD5 negotiation nonces make the wire stream non-deterministic in the general case. A hash mismatch is a triage signal, not a proof of bug; the retained pcaps are the actual evidence surface.
  • Timestamps, TCP sequence numbers, and ephemeral source ports are stripped before hashing; only application-layer bytes are compared.
  • tcpdump requires CAP_NET_RAW (root in most containers). The CI wrapper and Rust test skip rather than fail when this is missing.

Test plan

  • On the rsync-profile container (or any Linux box with tcpdump+tshark+rsync), run: sh scripts/wire-equivalence-tcpdump.sh and confirm exit 0 with hashes printed.
  • Verify graceful skip on macOS: sh tools/ci/run_wire_equivalence.sh prints "skipped" and exits 0.
  • Confirm Rust test cargo nextest run -p protocol -E 'test(wire_equivalence_tcpdump_harness)' reports a skip on hosts without the prerequisites and passes on hosts with them.

Add a daemon-vs-daemon byte equivalence probe that captures upstream
rsync 3.4.1 and oc-rsync running the same push scenario via tcpdump,
strips IP/TCP framing with tshark, normalizes ephemeral ports, and
compares the resulting application payload hashes.

* scripts/wire-equivalence-tcpdump.sh - self-contained harness that
  spins up both daemons on loopback inside a per-invocation scratch
  directory (never touches the workspace), runs an identical small-tree
  scenario through each, and exits 0 on match, 1 on divergence, 77 on
  skip (missing CAP_NET_RAW, no upstream binary, non-Linux host).
* tools/ci/run_wire_equivalence.sh - CI wrapper that probes the host
  for tcpdump/tshark and the two rsync binaries, skipping gracefully
  on platforms that cannot capture loopback traffic.
* crates/protocol/tests/wire_equivalence_tcpdump.rs - integration test
  that shells out to the harness when prerequisites are present and
  treats a missing toolchain as a non-fatal skip.

Known limitations documented in the test header: per-session random
seeds make a full byte match aspirational, so a divergence is a
triage signal, not a proof of bug. Retained pcaps under the scratch
dir support root-cause analysis.
@github-actions github-actions Bot added the test label May 17, 2026
@oferchen
oferchen merged commit fe894ae into master May 17, 2026
45 checks passed
oferchen added a commit that referenced this pull request May 18, 2026
Add a daemon-vs-daemon byte equivalence probe that captures upstream
rsync 3.4.1 and oc-rsync running the same push scenario via tcpdump,
strips IP/TCP framing with tshark, normalizes ephemeral ports, and
compares the resulting application payload hashes.

* scripts/wire-equivalence-tcpdump.sh - self-contained harness that
  spins up both daemons on loopback inside a per-invocation scratch
  directory (never touches the workspace), runs an identical small-tree
  scenario through each, and exits 0 on match, 1 on divergence, 77 on
  skip (missing CAP_NET_RAW, no upstream binary, non-Linux host).
* tools/ci/run_wire_equivalence.sh - CI wrapper that probes the host
  for tcpdump/tshark and the two rsync binaries, skipping gracefully
  on platforms that cannot capture loopback traffic.
* crates/protocol/tests/wire_equivalence_tcpdump.rs - integration test
  that shells out to the harness when prerequisites are present and
  treats a missing toolchain as a non-fatal skip.

Known limitations documented in the test header: per-session random
seeds make a full byte match aspirational, so a divergence is a
triage signal, not a proof of bug. Retained pcaps under the scratch
dir support root-cause analysis.
oferchen added a commit that referenced this pull request May 18, 2026
Add a daemon-vs-daemon byte equivalence probe that captures upstream
rsync 3.4.1 and oc-rsync running the same push scenario via tcpdump,
strips IP/TCP framing with tshark, normalizes ephemeral ports, and
compares the resulting application payload hashes.

* scripts/wire-equivalence-tcpdump.sh - self-contained harness that
  spins up both daemons on loopback inside a per-invocation scratch
  directory (never touches the workspace), runs an identical small-tree
  scenario through each, and exits 0 on match, 1 on divergence, 77 on
  skip (missing CAP_NET_RAW, no upstream binary, non-Linux host).
* tools/ci/run_wire_equivalence.sh - CI wrapper that probes the host
  for tcpdump/tshark and the two rsync binaries, skipping gracefully
  on platforms that cannot capture loopback traffic.
* crates/protocol/tests/wire_equivalence_tcpdump.rs - integration test
  that shells out to the harness when prerequisites are present and
  treats a missing toolchain as a non-fatal skip.

Known limitations documented in the test header: per-session random
seeds make a full byte match aspirational, so a divergence is a
triage signal, not a proof of bug. Retained pcaps under the scratch
dir support root-cause analysis.
@oferchen
oferchen deleted the test/tcpdump-wire-equivalence-2075 branch May 19, 2026 19:27
oferchen added a commit that referenced this pull request Aug 24, 2026
Add a daemon-vs-daemon byte equivalence probe that captures upstream
rsync 3.4.1 and oc-rsync running the same push scenario via tcpdump,
strips IP/TCP framing with tshark, normalizes ephemeral ports, and
compares the resulting application payload hashes.

* scripts/wire-equivalence-tcpdump.sh - self-contained harness that
  spins up both daemons on loopback inside a per-invocation scratch
  directory (never touches the workspace), runs an identical small-tree
  scenario through each, and exits 0 on match, 1 on divergence, 77 on
  skip (missing CAP_NET_RAW, no upstream binary, non-Linux host).
* tools/ci/run_wire_equivalence.sh - CI wrapper that probes the host
  for tcpdump/tshark and the two rsync binaries, skipping gracefully
  on platforms that cannot capture loopback traffic.
* crates/protocol/tests/wire_equivalence_tcpdump.rs - integration test
  that shells out to the harness when prerequisites are present and
  treats a missing toolchain as a non-fatal skip.

Known limitations documented in the test header: per-session random
seeds make a full byte match aspirational, so a divergence is a
triage signal, not a proof of bug. Retained pcaps under the scratch
dir support root-cause analysis.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant