test: assert TaskQueueProducer burst keeps newest values#1007
Merged
Conversation
SafeQueue is bounded (default 10) and evicts the oldest on overflow, so a no-yield burst of 50 cannot deliver all 50. Drain only after the burst completes and assert the survivors are the newest contiguous suffix.
Collaborator
Author
Automated reviewVerdict: LGTM. The rewrite is correct and deterministic; the assertions match SafeQueue's bounded evict-oldest contract and don't hardcode the capacity. Source-traced, no blocking issues. Correctness (verified)
Nit (non-blocking)
Meta
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
test_task_queue_producer_burstasserted that a no-yield burst of 50 values is delivered losslessly and in order. ButSafeQueueis intentionally bounded (default capacity 10) and evicts the oldest on overflow (it logs "Queue full, dropping oldest entry"). So the test's expectation contradicts the queue's documented contract — it's a test bug, not a product bug (confirmed with the maintainer).Fix
Rewrite the assertion to match the lossy-bounded contract: let the burst complete without draining (the event loop isn't ticked while blocked on the producer's done semaphore), then drain once and assert the survivors are the newest contiguous, in-order suffix ending at the last value pushed. This avoids the producer/consumer race and doesn't hardcode the capacity.
How it was found
On-device execution (
test_task_queue_producer_burst— "Expected 50 Was 10"); compile-only CI never ran it. Passes on-device after this change.