idGen tests: Add test to verify parallelism#45
idGen tests: Add test to verify parallelism#45rmandvikar wants to merge 1 commit intoRobThree:masterfrom rmandvikar:add-parallel-test
Conversation
|
There's no guarantee a race condition will occur; whatever the odds (low or high), a unittest should produce deterministic results. Besides that, this slows the unittests down considerably. That's not to say we shouldn't test for race conditions, I'm currently just short for time. |
Sure. But how do you plan to avoid like what happened in pr #23?
The test takes 34 ms to run. How is that slow? It's top 3 in the slowest tests, but it's faster than 2 other tests. IMO, 34 ms is worth it rather than shipping code with bugs, no?
I'm using this nuget in PRD, so I'm investing time to make patches to it to make it potentially less buggy. What do you propose instead? |
I'd rather have a deterministic unittest than one that fails on uneven tuesdays on a full moon and passes all other days.
Deterministic unittests.
You're always welcome to fork and do anything you want with it 😉 All I'm saying is I'm open to better methods of testing for race conditions (like use Concurrency Testing Frameworks or something, code reviews, static code analysis, ...) instead of just doing some arbitrary number of iterations and hope a race occurs (which may differ wildly on machines with less or more cores, more concurrent threads, faster or slower CPU's etc.). Anyway, your feedback is appreciated, as is you making an effort to improve this library. Let that be clear. I just don't agree on this way of testing. |
Just curious, how, for the issue at hand? |
|
I don't know off-hand. I'll have to sit down and think about that. |
Summary
Add a test to verify things work with parallel calls.
Changes
For ex, if I regress the above mentioned bug, this test correctly throws
IdGen.InvalidSystemClockException.Testing