Skip to content

test(daemon): run the daemon server integration tests un-detached - #7592

Merged
oferchen merged 1 commit into
test/daemon-filter-directives-inertfrom
test/daemon-server-inert
Sep 1, 2026
Merged

oferchen merged 1 commit into
test/daemon-filter-directives-inertfrom
test/daemon-server-inert

Conversation

@oferchen

@oferchen oferchen commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Stacked on #7588 — base is test/daemon-filter-directives-inert, which GitHub will retarget to master once that merges. See Ceiling below.

The defect

All 25 tests in tests/integration_daemon_server.rs started their daemon without --no-detach. RuntimeOptions::detach defaults to cfg!(unix), so run_daemon reached become_daemon() and the parent of that fork — the test binary — exited 0 before any assertion ran.

The window is worth stating precisely, because the obvious probe misleads. thread::spawn returns before the daemon thread reaches the fork, so an unconditional panic! placed straight after the spawn still fires. It is the first blocking socket call that hands the daemon its opportunity. With 14 unconditional panics placed after connect_with_retries:

Starting 25 tests across 1 binary (88 binaries skipped)
     Summary [   0.151s] 25 tests run: 25 passed (1 leaky), 0 skipped

Baseline before the fix: 0.082s for 25 tests, each of which opens a TCP connection and drives a protocol exchange.

Four defect classes

Grouped by root cause rather than by symptom.

1 — The client greeting. Nine sites sent a bare @RSYNCD: 32.0. The digest name list is mandatory above protocol 31 (clientserver.c:229-241), so every probe was answered @ERROR: your client omitted the digest name list and never reached the feature under test. Five more sites jumped straight to #list under a comment claiming "no version handshake needed" — but handle_daemon_connection() runs exchange_protocols() at clientserver.c:1534 and only reads the command line at :1538. A shared send_client_greeting() now attaches the list above protocol 31 and omits it at or below, which is the legacy path the protocol-29/30 cases exercise.

2 — The listing shape. Six tests expected a CAP line and an OK line before the module rows. send_listing() (clientserver.c:1374-1386) writes one "%-15s\t%s\n" row per module and then @RSYNCD: EXIT — no capability line, no OK. Those reads consumed the real rows. In two tests the follow-on loop then spun on end-of-file instead of terminating, so a wrong expectation presented as a hang rather than a failure; read_line returning 0 is now treated as EOF.

3 — Assertions that could not fire even once executing. These are the ones that would have gone on proving nothing after a bare --no-detach fix:

Test Guard Why it never held
server_lists_modules_with_comments if line.contains('\t') reached with an empty line after the phantom CAP/OK reads — asserted nothing at all
server_enforces_max_connections if line.contains("OK") the entire cap probe was optional; any non-admission skipped to the join
server_handles_invalid_greeting_response if result.is_ok() && !line.is_empty() a dropped connection skipped it, and the surviving @ERROR: or @RSYNCD: disjunction accepts every line the daemon can write

All three are now unconditional and pinned to the exact upstream payload.

4 — Expectations upstream does not have. @RSYNCD: EXIT has exactly one producer upstream — send_listing() at clientserver.c:1385. The unknown-module arm at :1567-1572 writes the error and returns -1, dropping the connection. server_sends_exit_after_error is therefore renamed server_closes_connection_after_error and asserts a zero-length read, which is the discriminating check: a daemon that kept the session open would block there.

auth_flow_protocol_29_md4_succeeds computed plain MD4. A client advertising no list lands on the md4 fallback with md4_is_old = 1, and negotiate_daemon_auth() rewrites the negotiated item to CSUM_MD4_OLD (compat.c:888-891), which sum_init() seeds with four zero bytes. oc implements this correctly; the test encoded the wrong digest.

The auth cases never negotiated anything

Worth separating out. perform_auth_handshake took a digest argument, used it for the client's own response arithmetic, and advertised no list — so the daemon stayed on the protocol_version >= 30 ? "md5" : "md4" fallback (compat.c:868-871). The digest parameter never reached the daemon's choice. auth_flow_protocol_32_sha512_succeeds passed while negotiating md5. The handshake now advertises the digest under test above protocol 31.

Mutation proofs — three classes, three distinct reddenings

Dropping the listing comment in module_access/listing.rs — reddens only the test that previously asserted nothing:

assertion `left == right` failed: listing row must carry the module comment
  left: ""
 right: "Documentation files"
 Summary [0.695s] 25 tests run: 24 passed, 1 failed

Altering the max-connections payload:

assertion `left == right` failed: second client must be refused with the upstream cap payload
  left: "@ERROR: max connections (1) reached, try again later"
 right: "@ERROR: max connections (1) reached -- try again later"
 Summary [0.574s] 25 tests run: 24 passed, 1 failed

Ignoring the client's advertised digest list in negotiate_server_daemon_digest:

protocol 32 with SHA-512 should succeed: @ERROR: auth failed on module authmod
protocol 32 with SHA-256 should succeed: @ERROR: auth failed on module authmod
 Summary [0.627s] 25 tests run: 23 passed, 2 failed

The md5 case stays green under that mutation — because md5 is the fallback. That is precisely why the old fixture, advertising nothing, could never have detected it.

Unmutated: 25 tests run: 25 passed, 0 skipped in 0.624s.

Ceiling

ROOT_DETACHING_CEILING goes 2 → 1. The value 1 assumes #7588 has landed (it is this PR's base). The single remaining file is tests/integration_daemon_max_connections_cap.rs, which #7578 fixes; whoever merges that should take the ceiling to 0 and can then delete the check's ceiling entirely.

Residuals — captured, not fixed

  • tests/integration_daemon_filter_directives.rs (in test(daemon): run the module filter-directive tests un-detached #7588) has a module header claiming include from coverage that no test exercises.
  • Two production comments cite become_daemon() at 3.4.4 line numbers: server_runtime/accept_loop.rs says clientserver.c:1568-1571 and sections/daemonize.rs says clientserver.c:1513. In the 3.5.0 pin the call site is clientserver.c:1758-1761 and the definition is :1691. module_access/listing.rs likewise cites clientserver.c:1246-1272 for send_listing(), which is :1374-1386. Out of scope here; the citation gate passes because those lines exist, and only the drift audit would notice.

Gates

  • cargo fmt --all -- --check clean
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings clean
  • bash tools/ci/check_daemon_no_detach.sh — no violations, 1 root test remaining against a ceiling of 1
  • cargo xtask citations — exit 0, 8663 citations resolve against the rsync 3.5.0 pin
  • cargo nextest run -p bin --all-features over both daemon binaries: 28 tests, 28 passed

All 25 tests in tests/integration_daemon_server.rs started their daemon
without --no-detach, so run_daemon reached become_daemon() and the fork's
parent - the test binary - exited 0 before any assertion ran.

The window is not the spawn: thread::spawn returns before the daemon thread
reaches the fork, so a panic! placed straight after it still fires. It is
the first blocking socket call. With 14 unconditional panics placed after
connect_with_retries, all 25 tests still reported PASSED.

Making them execute surfaced four defect classes, none of which could have
been seen before:

1. Greeting. Nine sites sent a bare `@RSYNCD: 32.0`. The digest name list
   is mandatory above protocol 31 (clientserver.c:229-241), so every probe
   was refused before reaching the feature under test. Five more sites
   jumped straight to `#list`, but exchange_protocols() runs at
   clientserver.c:1534 and the command line is only read at :1538.

2. Listing shape. Six tests expected a CAP line and an OK line before the
   module rows. send_listing() (clientserver.c:1374-1386) writes rows then
   `@RSYNCD: EXIT` and nothing else, so those reads consumed the real rows.
   In two tests the follow-on loop then spun on end-of-file rather than
   ending, turning a wrong expectation into a hang.

3. Assertions that could not fire. server_lists_modules_with_comments
   guarded its only assertions behind `if line.contains('\t')`, reached
   with an empty line, and so asserted nothing even once executing;
   server_enforces_max_connections hid the entire cap probe behind
   `if line.contains("OK")`; server_handles_invalid_greeting_response
   guarded on `result.is_ok() && !line.is_empty()`. Each is now
   unconditional and pinned to the upstream payload.

4. Expectations upstream does not have. `@RSYNCD: EXIT` has exactly one
   producer upstream (send_listing, clientserver.c:1385); the unknown-module
   arm at :1567-1572 writes the error and drops the connection, so
   server_sends_exit_after_error is renamed to
   server_closes_connection_after_error and asserts EOF.
   auth_flow_protocol_29_md4_succeeds computed plain MD4 where a client that
   advertises no list lands on CSUM_MD4_OLD (compat.c:888-891); oc is
   correct and the test encoded the wrong digest.

The auth cases also never negotiated anything: perform_auth_handshake took
a digest argument, used it for the client's own arithmetic, and advertised
no list, so the daemon stayed on the md5 fallback. It now advertises the
digest under test above protocol 31.

Mutation-proved across three classes: dropping the listing comment reddens
only server_lists_modules_with_comments (which previously asserted nothing);
altering the max-connections payload reddens only
server_enforces_max_connections; ignoring the client's advertised digest
list reddens the sha512 and sha256 cases while md5 stays green, because md5
is the fallback the old fixture silently relied on.

The no-detach guard ceiling drops to 1, leaving
tests/integration_daemon_max_connections_cap.rs.
@github-actions github-actions Bot added the test label Sep 1, 2026
@oferchen
oferchen merged commit 3dcca3f into test/daemon-filter-directives-inert Sep 1, 2026
69 checks passed
@oferchen
oferchen deleted the test/daemon-server-inert branch September 1, 2026 14:35
oferchen added a commit that referenced this pull request Sep 2, 2026
* test(daemon): run the module filter-directive tests un-detached

All three tests in tests/integration_daemon_filter_directives.rs started
the daemon without --no-detach. RuntimeOptions::detach defaults to
cfg!(unix), so run_daemon reached become_daemon() in the accept loop and
the fork's parent - the test binary - exited 0 before any assertion ran.
An unconditional panic! placed immediately after the daemon spawn still
reported "3 tests run: 3 passed"; the tell was a 0.029s runtime for three
full TCP transfers.

Making them execute surfaced a second defect the vacuity had masked. The
tests checked only that run_client returned Ok. A daemon-refused push does
not return Err: generator.c:1669-1671 reports the refusal as FERROR_XFER,
log.c:337-338 sets got_xfer_error on receipt, and cleanup.c:217-218 lifts
the exit status to RERR_PARTIAL, which arrives on
ClientSummary::io_error_exit_code rather than as an error. The push's
actual status was therefore never asserted, and an absent .log file on its
own is equally consistent with a transfer that achieved nothing - so each
test now asserts exit 23 as the positive signal that the module directive
fired.

collect_files carries file contents alongside the names so a kept file has
to arrive intact rather than merely exist, and the module header's upstream
citations are moved onto the 3.5.0 pin (clientserver.c:934-951,
receiver.c:889, generator.c:1663).

Mutation-proved on both assertions: silencing the FERROR_XFER frame in
receiver/transfer/candidates.rs leaves the on-disk state correct and reddens
only the new exit-code assertion, while disabling the daemon filter check
reddens the exclusion assertions with all four files landing.

The no-detach guard grows a fourth check for root-level integration tests,
which live outside the daemon crate and cannot reach its test-support
helpers, with a shrink-only ceiling at the 2 files still to be migrated.

* test(daemon): run the daemon server integration tests un-detached (#7592)

All 25 tests in tests/integration_daemon_server.rs started their daemon
without --no-detach, so run_daemon reached become_daemon() and the fork's
parent - the test binary - exited 0 before any assertion ran.

The window is not the spawn: thread::spawn returns before the daemon thread
reaches the fork, so a panic! placed straight after it still fires. It is
the first blocking socket call. With 14 unconditional panics placed after
connect_with_retries, all 25 tests still reported PASSED.

Making them execute surfaced four defect classes, none of which could have
been seen before:

1. Greeting. Nine sites sent a bare `@RSYNCD: 32.0`. The digest name list
   is mandatory above protocol 31 (clientserver.c:229-241), so every probe
   was refused before reaching the feature under test. Five more sites
   jumped straight to `#list`, but exchange_protocols() runs at
   clientserver.c:1534 and the command line is only read at :1538.

2. Listing shape. Six tests expected a CAP line and an OK line before the
   module rows. send_listing() (clientserver.c:1374-1386) writes rows then
   `@RSYNCD: EXIT` and nothing else, so those reads consumed the real rows.
   In two tests the follow-on loop then spun on end-of-file rather than
   ending, turning a wrong expectation into a hang.

3. Assertions that could not fire. server_lists_modules_with_comments
   guarded its only assertions behind `if line.contains('\t')`, reached
   with an empty line, and so asserted nothing even once executing;
   server_enforces_max_connections hid the entire cap probe behind
   `if line.contains("OK")`; server_handles_invalid_greeting_response
   guarded on `result.is_ok() && !line.is_empty()`. Each is now
   unconditional and pinned to the upstream payload.

4. Expectations upstream does not have. `@RSYNCD: EXIT` has exactly one
   producer upstream (send_listing, clientserver.c:1385); the unknown-module
   arm at :1567-1572 writes the error and drops the connection, so
   server_sends_exit_after_error is renamed to
   server_closes_connection_after_error and asserts EOF.
   auth_flow_protocol_29_md4_succeeds computed plain MD4 where a client that
   advertises no list lands on CSUM_MD4_OLD (compat.c:888-891); oc is
   correct and the test encoded the wrong digest.

The auth cases also never negotiated anything: perform_auth_handshake took
a digest argument, used it for the client's own arithmetic, and advertised
no list, so the daemon stayed on the md5 fallback. It now advertises the
digest under test above protocol 31.

Mutation-proved across three classes: dropping the listing comment reddens
only server_lists_modules_with_comments (which previously asserted nothing);
altering the max-connections payload reddens only
server_enforces_max_connections; ignoring the client's advertised digest
list reddens the sha512 and sha256 cases while md5 stays green, because md5
is the fallback the old fixture silently relied on.

The no-detach guard ceiling drops to 1, leaving
tests/integration_daemon_max_connections_cap.rs.
oferchen added a commit that referenced this pull request Sep 2, 2026
`## [Unreleased]` last covered the #7304-#7522 era. Measured against the 60
most recently merged pull requests, 44 were absent; of the most recent 45,
43 were absent. Nothing from #7574 onward was recorded at all.

Each entry is derived from what the pull request actually landed - the merge
commit and the body - not from its title. Three cases where those differ:

  * #7616 ships far more than the doc-alias correction its body describes:
    the `upstream_version` pin moves to 3.5.0 and `--version` starts naming
    `quic`, `sd-notify`, `vmsplice` and `send_zc`.
  * #7618 also adds the pull-request rustdoc-link job its body says was
    filed separately, which is what closes the master-only-gate recurrence.
  * #7602's squash carries the closed #7597 as its first commit, so the
    directory-obstacle half is recorded under #7602.

#7587 is deliberately not recorded. Its merge commit is empty: the change
had already landed as #7563, which the section already names.

Entries extend the existing Keep a Changelog groups and the bold
sub-groupings. Clusters that are one story carry one entry with several
references: the FERROR_XFER routing and its two-phase drain (#7576, #7581),
the connection-FSM close edge and the accept loop that outlives a session
error (#7579, #7590), the three detaching daemon suites (#7578, #7588,
#7592), the io_uring and SEND_ZC work (#7593, #7600, #7610), the citation
retargets (#7601, #7603, #7604), and the accept-loop pin flake (#7615,
#7620).

Only `## [Unreleased]` is touched; every released section, including the
3.4.4 statements that were correct when written, is byte-identical.
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