Skip to content

Address review findings on merged test-infra PRs#339

Merged
hardbyte merged 2 commits into
mainfrom
fix/test-review-followups
Jun 10, 2026
Merged

Address review findings on merged test-infra PRs#339
hardbyte merged 2 commits into
mainfrom
fix/test-review-followups

Conversation

@hardbyte

@hardbyte hardbyte commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up for the post-merge review comments on #334 and #336, per the CodeRabbit findings:

  1. Connection budget, not test count (Parallelize queue_storage_runtime_test via template databases #336, major). setup_pool now acquires permits equal to the pool's max_connections against an 80-permit budget, so the aggregate connection worst case is actually bounded below the server's max_connections=100 — the previous one-permit-per-test cap allowed 8 × 20-connection pools. A per-test floor of budget/8 keeps effective test concurrency near 8: at unfloored weights, small-pool tests admitted ~20 concurrent client runtimes and CPU starvation produced 5–6 wait-for-state timeouts per run (reproduced locally before adding the floor).
  2. Guard/pool drop order (Parallelize queue_storage_runtime_test via template databases #336, nitpick). setup_pool returns (guard, pool) so destructured locals drop the pool handle before releasing the permit.
  3. Snapshot-publication wait (Cut 0.6.0-beta.2 #334). test_weight_proportionality waits on the snapshot store itself instead of the completion counter, which increments a beat before the stores.

The codex lockfile finding on #334 was already fixed pre-merge (9e400ae).

Validation

  • cargo fmt --all; cargo clippy -p awa --tests -- -D warnings clean
  • 8 consecutive green queue_storage_runtime_test runs (incl. the floor-regression check), 3 consecutive green weighted_test runs

Refs #334, #336, #335.

Summary by CodeRabbit

  • Tests
    • Enhanced test infrastructure for improved connection resource management and timing reliability across concurrent test execution.

Three post-merge review findings from #334 and #336:

- The test-concurrency semaphore now budgets connections, not tests:
  setup_pool acquires permits equal to the pool's max_connections
  against an 80-permit budget, so eight 20-connection pools can no
  longer exceed the server's max_connections=100 (CodeRabbit, #336).
  A per-test floor of budget/8 keeps effective test concurrency near
  8 — without it, small-pool tests admitted ~20 concurrent client
  runtimes and CPU starvation made wait-for-state assertions time out
  (reproduced: 5-6 failures per run at unfloored weights).
- setup_pool returns (guard, pool) so the destructured locals drop
  pool-first and the permit outlives the pool handle (CodeRabbit
  nitpick, #336).
- test_weight_proportionality waits on snapshot publication rather
  than the completion counter, which increments a beat before the
  snapshot stores (CodeRabbit, #334).

Validated: 8 consecutive green queue_storage_runtime_test runs, 3
consecutive green weighted_test runs.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@hardbyte, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 46 minutes and 7 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 787b708f-113b-4e14-bdca-0a838dfe4de0

📥 Commits

Reviewing files that changed from the base of the PR and between 3e23051 and 58ce345.

📒 Files selected for processing (1)
  • awa/tests/weighted_test.rs
📝 Walkthrough

Walkthrough

Connection budgeting semaphore introduced to cap concurrent Postgres connections across integration tests. Queue storage test harness setup_pool refactored to acquire per-test permits and reverse return order so connection pool drops before permit release. All test call sites mechanically updated to new destructuring order. Separate race condition fixed in weight proportionality test by waiting on snapshot value instead of completion counter.

Changes

Test Infrastructure and Flakiness Fixes

Layer / File(s) Summary
Connection budget mechanism
awa/tests/queue_storage_runtime_test.rs
New global TEST_CONNECTION_PERMITS semaphore with TEST_CONNECTION_BUDGET total and per-test TEST_PERMIT_FLOOR floor replaces fixed concurrency semaphore, allowing connection limits to be enforced across concurrent test execution to avoid PoolTimedOut errors and starvation.
setup_pool refactor with permit acquisition
awa/tests/queue_storage_runtime_test.rs
setup_pool now asserts requested max_connections fits budget, acquires permits sized by max(max_connections, TEST_PERMIT_FLOOR), and returns (TestDbGuard, sqlx::PgPool) instead of (pool, guard) so pool drops before permit is released.
Test call sites destructuring update
awa/tests/queue_storage_runtime_test.rs
All test functions mechanically updated to destructure setup_pool result as let (_db_guard, pool) instead of let (pool, _db_guard) across the entire test file.
Weight proportionality test flakiness fix
awa/tests/weighted_test.rs
test_weight_proportionality wait loop changed from polling total_completed >= SNAPSHOT_END to waiting until snapshot_a is set by worker, avoiding race where counter increment becomes visible before snapshot store completes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • hardbyte/awa#336: Initial TestDbGuard and semaphore-based concurrency control for queue storage test suite that this PR refines with connection budgeting and drop-order fixes.
  • hardbyte/awa#334: Weight proportionality test flakiness issue that this PR addresses by waiting on snapshot publication instead of completion counter.
  • hardbyte/awa#249: Priority-aging tests added to queue storage runtime tests that would compile against the refactored setup_pool harness in this PR.

Poem

🐰 A rabbit hops through tests with care,
Connections budgeted, drop order fair,
Race conditions flee when snapshots appear,
The harness grows strong, year by year! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and generic, referring to 'review findings on merged test-infra PRs' without specifying the actual changes made. A reader scanning PR history would not understand the primary changes (connection budget handling, guard/pool drop order, or snapshot-publication wait). Revise the title to be more specific about the main change, such as 'Cap concurrent database connections with connection-budget semaphore' or similar to clearly indicate the primary purpose of the changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@awa/tests/weighted_test.rs`:
- Line 627: The steady-state loop currently checks only snapshot_a against
SNAPSHOT_UNSET, allowing the loop to exit before snapshot_b is set and causing
unsafe/flaky calculations; update the loop's exit condition to wait for both
snapshot_a and snapshot_b to be set (i.e., ensure snapshot_a.load(...) !=
SNAPSHOT_UNSET && snapshot_b.load(...) != SNAPSHOT_UNSET) so the worker's
sequential stores for snapshot_a and snapshot_b complete before computing
snapshot_b - base_b.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a3247a0-a558-404b-a1eb-1ad14a936beb

📥 Commits

Reviewing files that changed from the base of the PR and between cc935cf and 3e23051.

📒 Files selected for processing (2)
  • awa/tests/queue_storage_runtime_test.rs
  • awa/tests/weighted_test.rs

Comment thread awa/tests/weighted_test.rs Outdated
The loop exited once snapshot_a was published, but the worker stores
base_a, base_b, snapshot_a, snapshot_b sequentially; gate on all four
and use the same condition to choose the measurement window, so a
20s-timeout edge can never subtract from an unset baseline.
@hardbyte hardbyte merged commit c40c0e7 into main Jun 10, 2026
12 checks passed
@hardbyte hardbyte deleted the fix/test-review-followups branch June 10, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant