Conversation
Reviewer's GuideIntroduces a new time-slice–based fairness test for the connection actor and tidies up duplicate imports in the test module. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughTwo new asynchronous test functions were added to Changes
Sequence Diagram(s)sequenceDiagram
participant Test
participant ConnectionActor
Test->>ConnectionActor: Spawn with fairness config (max_high_before_low=0, no time slice)
Test->>ConnectionActor: Push high-priority items
Test->>ConnectionActor: Push low-priority items
ConnectionActor-->>Test: Output sequence (all high before any low)
Note over Test,ConnectionActor: Second test with time slice fairness
Test->>ConnectionActor: Spawn with fairness config (max_high_before_low=0, time_slice=10ms)
Test->>ConnectionActor: Push initial high-priority items
Test->>ConnectionActor: Wait (delay)
Test->>ConnectionActor: Push more high-priority items
Test->>ConnectionActor: Push low-priority item
Test->>ConnectionActor: Push additional high-priority items
ConnectionActor-->>Test: Output sequence (low-priority item appears mid-sequence)
Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
tests/connection_actor.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
tests/connection_actor.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
tests/connection_actor.rs
🧬 Code Graph Analysis (1)
tests/connection_actor.rs (2)
tests/preamble.rs (1)
oneshot(73-73)src/connection.rs (3)
shutdown_token(142-142)new(101-108)new(430-439)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (actions)
🔇 Additional comments (1)
tests/connection_actor.rs (1)
8-11: Import organisation looks correct.The addition of
tokio::sync::oneshotto the import block is properly organised and necessary for the new test function.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
Cargo.toml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`Cargo.toml`: Use explicit version ranges in `Cargo.toml` and keep dependencies up-to-date.
Cargo.toml: Use explicit version ranges inCargo.tomland keep dependencies up-to-date.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build-test
- GitHub Check: Analyze (actions)
| serde = { version = "1", features = ["derive"] } | ||
| bincode = "2" | ||
| tokio = { version = "1", default-features = false, features = ["net", "signal", "rt-multi-thread", "macros", "sync", "time", "io-util"] } | ||
| tokio = { version = "1", default-features = false, features = ["net", "signal", "rt-multi-thread", "macros", "sync", "time", "io-util", "test-util"] } |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consider scoping test-util to test-only builds.
Adding the test-util feature directly to the main tokio dependency means the extra test helpers will be compiled for release builds as well, marginally increasing compile time and binary size.
A cleaner approach is to keep the production feature list lean and add a separate tokio entry under [dev-dependencies] (or expose a crate feature) that includes test-util, e.g.:
-[dependencies]
-tokio = { version = "1", default-features = false, features = ["net", "signal", "rt-multi-thread", "macros", "sync", "time", "io-util", "test-util"] }
+[dependencies]
+tokio = { version = "1", default-features = false, features = ["net", "signal", "rt-multi-thread", "macros", "sync", "time", "io-util"] }
+
+[dev-dependencies]
+# Pulls in the extra helpers only when running `cargo test`
+tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "macros", "sync", "time", "io-util", "test-util"] }This keeps release artefacts free of test-only code while preserving determinism in your new fairness tests.
(If you decide to leave it as-is, it will still work correctly; this is purely an optimisation suggestion.)
🤖 Prompt for AI Agents
In Cargo.toml at line 9, the `test-util` feature of the `tokio` dependency is
included in the main dependency list, causing test utilities to be compiled in
release builds. To fix this, remove `test-util` from the main `tokio` features
and instead add a separate `tokio` entry under `[dev-dependencies]` with the
`test-util` feature included. This change scopes `test-util` to test-only
builds, keeping production builds lean.
Summary
max_high_before_lowis zeroTesting
make fmtmake lintmake testcargo test fairness_yields_low_with_time_slice -- --nocapturehttps://chatgpt.com/codex/tasks/task_e_68684cd037548322a494feb0d1e8476d
Summary by Sourcery
Add a test to verify time-based queue fairness with a nonzero time slice when high-priority quotas are zero and remove redundant imports from the test module
Tests:
fairness_yields_low_with_time_sliceto ensure low-priority items are yielded based on time slices whenmax_high_before_lowis zeroChores: