← Back to Pull requests

test(server): give each connect of the listener queue test its own bound #9234

Closed
unknown closed this pull request without merging on Nov 29, 2026 05:08 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 04:59 UTC
Author

Description

Problem

What changes for a reader of the test results: server::tests::the_http_listener_queues_what_its_host_allows no longer fails on a slow test host. It failed in runs of the gateway's unit tests on changes that touch no gateway file, with a connection past 128 was not queued, and passed on the same tree elsewhere.

The test binds the listeners, accepts nothing and opens min(somaxconn, 256) loopback connections one after another under one bound of three seconds for the whole loop, while the same binary runs about five thousand other tests. A connection the listener does queue can lose its first packet on a loaded host; the kernel sends it again after one second and after three. A few such connects, or a host that is only slow, carry the loop past its bound although every connection is queued, and the one message cannot tell a slow host from a short queue.

Solution

Each connect gets its own bound of five seconds, which holds both resends; the loop has none. A slow host makes the test slow, not red. A connection past a short queue never completes while nothing accepts, so the test still fails there, and names it: a listener that asks for 128 queues 129, and the test stops with connection 130 of 256 was not queued within 5s. A connect that returns an error fails with connection N of M failed: <error>. The test asserts as much as before: every one of min(somaxconn, 256) connections is queued.

Ready check

  • Architecture: the body of one test, in the module that owns the listeners. No product line moves; no new item, no dependency.

  • Engines: the listener is the gateway's own; the test reads no fact of an engine.

  • Cost: none on the request path: test code only. On a host that queues, the test's own time stays where it was (see Numbers); its red costs five seconds, not three.
  • Changes

  • model_gateway/src/server.rs: the_http_listener_queues_what_its_host_allows bounds each connect on its own and tells a bound that ran out from a connect that failed.
  • Test Plan

  • Fail-before by a reverse: with the listener asking for 128 (what the runtime's own bind asks for) in place of the host's maximum, the test fails by its own panic, connection 130 of 256 was not queued within 5s; with the line it guards in place: 1 passed.

  • 20 starts of the test alone: 20 passed.

  • A slow host, by a run: with every connect call delayed by 15 ms (256 connects take about 3.9 s, every one queued) the test of the base fails 20 of 20 starts with a connection past 128 was not queued; with the change it passes 20 of 20. A dropped first packet was not run: that five seconds hold its two resends is read from the kernel's retry times.

  • The lib tests of the gateway, whole: 5,268 passed, 0 failed, 24 ignored.

  • cargo fmt -p smg -- --check, cargo clippy -p smg --all-targets -- -D warnings and RUSTDOCFLAGS='-D warnings' cargo doc --locked -p smg --no-deps: clean. cargo test -p smg --test startup_tests: 46 passed, 0 failed.
  • Release note

    The unit test of the HTTP listener's accept queue bounds each connect on its own (five seconds) instead of the whole loop (three seconds): a slow or loaded test host no longer fails it, and a listener with a short queue still fails it, at the first connection that is not queued. Test code only: nothing the gateway does changes.

    Numbers

    | metric | before | after | setup |
    |---|---|---|---|
    | starts that pass, of 20, with every connect call delayed by 15 ms | 0 | 20 | 256 connects take about 3.9 s and every one is queued; before: a connection past 128 was not queued at the 3 s bound; after: the test takes 4.0 s to 6.3 s |
    | starts that pass, of 20, the test alone | 20 | 20 | one test executable a side, the two sides taken in turn, ten starts a turn |
    | the test's own time alone, median of 20 (min to max) | 0.08 s (0.06 to 0.15) | 0.07 s (0.06 to 0.09) | same starts, the time the test harness prints |
    | the test on a listener that asks for 128 | not run | fails after 5.34 s: connection 130 of 256 was not queued within 5s | the listener's queue length reversed to 128 on a host that allows 4096 |

    Diff: 519 lines (+389 / -130) across 6 files Reviewer: claude[bot] Review duration: 9m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.48) × (1 − Review Confidence (0.49)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 519 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 70% · Reviewer familiarity: 35%
    49%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #9234"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 49.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 49.5% · Lower = rushed or shallow review
    49.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.1% · Safe to merge
    24.1%