Improve reliability of scheduler tests #304
Merged
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.
We got a failure in Jenkins:
The test schedules a job for 1 second in the future and then checks that
it took
(0.99, 2.01) sto run it.But the scheduler, and indeed Thread.delay cannot make such guarantees.
It can only ensure that the job is scheduled at least 1 s in the future.
If the system is busy it can take 2s, 30s, 10m, etc. the kernel provides
no upper bound, this is not a real-time operating system.
Replace the strict check with a timeout based one instead: wait up to a
maximum allowed time, and then check how soon the callback actually got
invoked (i.e. that it didn't run too early).
We need the maximum allowed time because we don't want the test to be
stuck forever, but we also want the test to stop as soon as the callback
is executed, i.e. so it doesn't needlessly wait a minute on each test if
the scheduler actually finished in 1s.
Signed-off-by: Edwin Török [email protected]