-
Notifications
You must be signed in to change notification settings - Fork 0
Add time slice fairness test #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideAdds a new integration test that configures ConnectionActor with a zero high-before-low limit and a 10 ms time slice, then drives the actor through interleaved high- and low-priority pushes to verify low-priority items are emitted in the middle of the sequence once the time slice elapses. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
✨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai review |
✅ Actions performedReview triggered.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (2)
tests/connection_actor.rs (2)
17-17
: Replace forbidden#[allow]
attributes with#[expect]
.The coding guidelines explicitly forbid
#[allow]
and require narrowly scoped#[expect(lint, reason = "...")]
instead.-#[allow(unused_braces)] +#[expect(unused_braces, reason = "rstest fixture requires braces for consistency")]Apply this change to all three fixture functions.
Also applies to: 21-21, 25-25
117-146
: Add missing test attributes to prevent clippy error.The function
fairness_disabled_processes_all_high_first
is missing the#[rstest]
and#[tokio::test]
attributes, causing it to be unused and triggering a clippy error.+#[rstest] +#[tokio::test] async fn fairness_disabled_processes_all_high_first(
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
tests/connection_actor.rs
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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
return
in single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafe
unless 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
rstest
fixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]
parameterised cases.Prefer
mockall
for 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
🪛 GitHub Actions: CI
tests/connection_actor.rs
[error] 117-117: Clippy error: function fairness_disabled_processes_all_high_first
is never used.
🔇 Additional comments (1)
tests/connection_actor.rs (1)
73-115
: Well-implemented time slice fairness test.The test correctly validates time-based queue fairness behaviour by:
- Configuring
max_high_before_low: 0
to disable count-based fairness- Setting a 10ms time slice
- Carefully timing the push operations to exceed the time slice
- Verifying that the low-priority item appears in the middle of the output sequence
The use of
tokio::spawn
andoneshot
channel is appropriate for testing the asynchronous behaviour.
use std::time::Duration; | ||
|
||
use tokio::{sync::oneshot, time::sleep}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove redundant imports.
The imports std::time::Duration
and tokio::{sync::oneshot, time::sleep}
are redundant. Duration
and sleep
are already imported at the module level (lines 8-9), and oneshot
should be imported at the module level for consistency.
- use std::time::Duration;
-
- use tokio::{sync::oneshot, time::sleep};
Add oneshot
to the existing tokio imports at the module level:
-use tokio::time::{Duration, sleep, timeout};
+use tokio::{sync::oneshot, time::{Duration, sleep, timeout}};
🤖 Prompt for AI Agents
In tests/connection_actor.rs around lines 77 to 79, remove the redundant imports
of std::time::Duration and tokio::{sync::oneshot, time::sleep} since Duration
and sleep are already imported at the module level. Instead, add oneshot to the
existing tokio imports at the module level for consistency and clean up
duplicate imports in this section.
@coderabbitai what's causing this error?
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@leynos The error is occurring because the function From the structure of other tests in the file, it appears this function should be annotated as a test. Here's what needs to be fixed: #[tokio::test]
async fn fairness_disabled_processes_all_high_first(
// ... rest of function The function is defined but not marked as a test, so the Rust compiler sees it as dead code since it's never called. You have a few options to fix this:
The most likely solution is that this function should have the 🏁 Script executed:
Length of output: 9955 🏁 Script executed:
Length of output: 681 🏁 Script executed:
Length of output: 2529 @leynos I can see exactly what's causing the error. The function Looking at the code, all the other test functions have both async fn fairness_disabled_processes_all_high_first( It should be: #[rstest]
#[tokio::test]
async fn fairness_disabled_processes_all_high_first( The function appears to be a legitimate test that verifies fairness behavior when fairness is disabled (with The fix: Add the missing annotations at line 117: #[rstest]
#[tokio::test]
async fn fairness_disabled_processes_all_high_first(
queues: (PushQueues<u8>, wireframe::push::PushHandle<u8>),
shutdown_token: CancellationToken,
) {
// ... rest of the function The |
Summary
max_high_before_low
is zeroTesting
make fmt
make lint
make test
cargo test fairness_yields_low_with_time_slice -- --nocapture
https://chatgpt.com/codex/tasks/task_e_68684cd037548322a494feb0d1e8476d
Summary by Sourcery
Tests: