test(api): drop an assertion on who won a race with the drainer - #70
Merged
Merged
Conversation
RequestIsSafeUnderConcurrentPublishAndDrain asserted served > 0: that at least one of 20,000 request() calls found a value in the slot. The drainer in the same test is a tight loop emptying that slot, so the assertion is a statement about scheduling, not about the code under test. It passed 200 consecutive local runs and failed once in CI under the BDE allocators on a loaded runner. Nothing is lost. That request() returns a present value is pinned deterministically by RequestReturnsTheCurrentValueWithoutSubscribing, and the assertion this test exists for - requests_served + requests_denied equals the number of calls made - is unaffected by who wins the race. A test that reddens the build at random teaches you to ignore red.
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.
RequestIsSafeUnderConcurrentPublishAndDrainassertedserved > 0: that atleast one of 20,000
request()calls found a value in the subscriber's slot.The drainer in the same test is a tight loop emptying that slot, so the
assertion is a statement about scheduling, not about the code under test.
It passed 200 consecutive local runs and failed once in CI, under the BDE
allocators on a loaded runner:
A re-run with no code change went green, which is the definition of the
problem.
Nothing is lost
That
request()returns a present value is already pinned deterministicallyby
RequestReturnsTheCurrentValueWithoutSubscribingandRequestSeesTheLatestValueNotTheFirst. The assertion this test actuallyexists for,
requests_served + requests_denied == 20000, is unaffected bywho wins the race and still runs.
The test's own comment already said the right thing - "the exact value read is
whatever was current at that instant" - and then asserted otherwise on the
next line.
A test that reddens the build at random teaches you to ignore red.