Add specs to check randomness of ID generation#743
Merged
ybasket merged 3 commits intotrace4cats:masterfrom May 22, 2022
Merged
Add specs to check randomness of ID generation#743ybasket merged 3 commits intotrace4cats:masterfrom
ybasket merged 3 commits intotrace4cats:masterfrom
Conversation
catostrophe
reviewed
Apr 27, 2022
| generate | ||
| .parReplicateA(16) // don't choose too high or the test might sometimes fail by chance (birthday paradoxon) | ||
| .map { ids => | ||
| assert(Eq.eqv(ids.distinct, ids), s"got only ${ids.distinct.size} distinct IDs instead of 16") |
Member
There was a problem hiding this comment.
I think it's better to compare just the sizes of collections.
Contributor
Author
There was a problem hiding this comment.
I can change it, no problem, but may I ask why do you think it's better? We're on List here, so order is no issue. I only see a minor speed improvement as benefit.
catostrophe
reviewed
Apr 27, 2022
|
|
||
| it should "generate distinct SpanId instances when using ThreadLocalRandom" in { | ||
| val instance = implicitly[SpanId.Gen[IO]] | ||
| GenAssertions.assertAllDistinct(instance.gen).unsafeRunSync() |
Member
There was a problem hiding this comment.
Why not just SpanId.gen[IO]?
Contributor
Author
There was a problem hiding this comment.
No particular reason, changed it :)
added 3 commits
May 21, 2022 19:43
Check that SpanIDs and TraceIds are not repeating within a small sample to detect issues with the random generator used or the resolved implicit Gen instances. Relates to trace4cats#740.
7a6218b to
ef7343e
Compare
catostrophe
approved these changes
May 22, 2022
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.
Check that SpanIDs and TraceIds are not repeating within a small sample to detect issues with the random generator used or the resolved implicit
Geninstances.Proposed in #740 (comment). As the upstream issue in CE still exists, two test cases fail right now. Hence marked as draft, will update once resolved.