Skip to content

test(daemon): stop the max-connections cap test passing without running - #7578

Merged
oferchen merged 1 commit into
masterfrom
test/daemon-max-connections-cap-inert
Sep 1, 2026
Merged

oferchen merged 1 commit into
masterfrom
test/daemon-max-connections-cap-inert

Conversation

@oferchen

@oferchen oferchen commented Sep 1, 2026 •

Copy link
Copy Markdown
Owner

daemon_caps_concurrent_module_connections_at_max_connections never ran
a single assertion. It spawns run_daemon on a thread without
--no-detach, and RuntimeOptions::detach defaults to cfg!(unix), so
the accept loop reaches become_daemon() (accept_loop.rs:287). That
forks, and the parent of the fork is the test binary itself, which exits
0 (platform::daemonize::become_daemon). libtest and nextest record the
process's clean exit as a pass.

Proven by mutation, not by reading:

  • Removing the cap from production entirely - MaxConnections::Limited
    returning an unlimited guard in try_acquire_connection - left the
    test at 1 test run: 1 passed in 0.033s.
  • An unconditional panic! in the test body also reported
    1 test run: 1 passed, in 0.018s.

0.02s is itself the tell: the body contains a 250ms sleep it never
reached. Each run also leaked a real background daemon that outlived the
test process.

Turning the test on exposed three further defects, all masked by the
detach:

  • The client fixture sent a bare @RSYNCD: 32.0. The digest name list
    is mandatory for protocol > 31 (clientserver.c:228-238), so all three
    probes were refused at the greeting and the module request was never
    reached. Now sends @RSYNCD: 32.0 md5 md4.
  • cap_line.starts_with("oc-rsync warning:") could never hold: every
    daemon log line carries upstream's YYYY/MM/DD HH:MM:SS [pid]
    prefix (log.c:135). The level check now runs against the message with
    that prefix stripped, and the prefix shape itself is asserted rather
    than assumed.
  • The "skip when the daemon never bound" guard fired on any outcome
    where every client failed, including clients that connected and then
    hit a broken daemon - it swallowed exactly the failures the test
    exists to catch. ClientError now separates a connect-phase failure
    from an exchange failure, and only the former can skip.

The fixed test reddens on the same mutation:

assertion `left == right` failed: exactly 2 clients should be
admitted, got 3; refused=[]
  left: 3
 right: 2

and on a level mutation of the DMC-5 warning:

cap line must be warning-level (DMC-5): ... oc-rsync error:
max-connections cap reached: which=capped peer=localhost
(127.0.0.1) cap=2 current=2 ...

The 250ms sleep is replaced by a Barrier: no client returns - and so
no socket closes and no slot is handed back - until all three have been
classified. The contended probe is now deterministic instead of merely
likely. The daemon join is a plain join() for the same reason.

tools/ci/check_daemon_no_detach.sh already guards this defect class,
but its scan is scoped to crates/daemon/src/tests/chunks, so the
root-level integration tests were invisible to it. It now also counts
files under tests/ that call run_daemon() without ever naming
--no-detach, against a shrink-only ceiling. Two remain -
integration_daemon_server.rs and integration_daemon_filter_directives.rs

  • and they are vacuous on Unix for the same reason; they are left for
    separate slices because their assertions need triaging once they start
    executing.

No production code is changed: the cap, its wire payload and its log line
were all correct once the test could see them.

`daemon_caps_concurrent_module_connections_at_max_connections` never ran
a single assertion. It spawns `run_daemon` on a thread without
`--no-detach`, and `RuntimeOptions::detach` defaults to `cfg!(unix)`, so
the accept loop reaches `become_daemon()` (accept_loop.rs:287). That
forks, and the parent of the fork is the test binary itself, which exits
0 (`platform::daemonize::become_daemon`). libtest and nextest record the
process's clean exit as a pass.

Proven by mutation, not by reading:

  * Removing the cap from production entirely - `MaxConnections::Limited`
    returning an unlimited guard in `try_acquire_connection` - left the
    test at `1 test run: 1 passed` in 0.033s.
  * An unconditional `panic!` in the test body also reported
    `1 test run: 1 passed`, in 0.018s.

0.02s is itself the tell: the body contains a 250ms sleep it never
reached. Each run also leaked a real background daemon that outlived the
test process.

Turning the test on exposed three further defects, all masked by the
detach:

  * The client fixture sent a bare `@RSYNCD: 32.0`. The digest name list
    is mandatory for protocol > 31 (clientserver.c:228-238), so all three
    probes were refused at the greeting and the module request was never
    reached. Now sends `@RSYNCD: 32.0 md5 md4`.
  * `cap_line.starts_with("oc-rsync warning:")` could never hold: every
    daemon log line carries upstream's `YYYY/MM/DD HH:MM:SS [pid] `
    prefix (log.c:135). The level check now runs against the message with
    that prefix stripped, and the prefix shape itself is asserted rather
    than assumed.
  * The "skip when the daemon never bound" guard fired on any outcome
    where every client failed, including clients that connected and then
    hit a broken daemon - it swallowed exactly the failures the test
    exists to catch. `ClientError` now separates a connect-phase failure
    from an exchange failure, and only the former can skip.

The fixed test reddens on the same mutation:

    assertion `left == right` failed: exactly 2 clients should be
    admitted, got 3; refused=[]
      left: 3
     right: 2

and on a level mutation of the DMC-5 warning:

    cap line must be warning-level (DMC-5): ... oc-rsync error:
    max-connections cap reached: which=capped peer=localhost
    (127.0.0.1) cap=2 current=2 ...

The 250ms sleep is replaced by a `Barrier`: no client returns - and so
no socket closes and no slot is handed back - until all three have been
classified. The contended probe is now deterministic instead of merely
likely. The daemon join is a plain `join()` for the same reason.

`tools/ci/check_daemon_no_detach.sh` already guards this defect class,
but its scan is scoped to `crates/daemon/src/tests/chunks`, so the
root-level integration tests were invisible to it. It now also counts
files under `tests/` that call `run_daemon()` without ever naming
`--no-detach`, against a shrink-only ceiling. Two remain -
`integration_daemon_server.rs` and `integration_daemon_filter_directives.rs`
- and they are vacuous on Unix for the same reason; they are left for
separate slices because their assertions need triaging once they start
executing.

No production code is changed: the cap, its wire payload and its log line
were all correct once the test could see them.
@github-actions github-actions Bot added the test label Sep 1, 2026
@oferchen
oferchen merged commit a755de3 into master Sep 1, 2026
69 of 71 checks passed
@oferchen
oferchen deleted the test/daemon-max-connections-cap-inert branch September 1, 2026 10:10
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