Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several tweaks to the testing clock. #3

Merged
merged 2 commits into from
Feb 4, 2019
Merged

Conversation

jameinel
Copy link
Member

@jameinel jameinel commented Feb 3, 2019

  1. Actually wire up the tests for the testing clock. In moving them out
    of 'util' we missed having the TestAll function.
  2. Fix a test that checked the logs, but didn't tell the logging
    infrastructure that it needed to read all Debug level log messages.
  3. Change clock.WaitAdvance to not break the time into 10 even slices.
    This is because many tests use WaitAdvance(..., LongWait), which
    means that if they aren't ready immediately, then they way 1s before
    checking again, which is way too long. Instead we cap out at 10ms, so
    we don't spin waiting for the right number of waiters, but we also
    don't wait too long. We still stop at the same time, and we still
    stop as soon as we have the expected number of waiters.
  4. Track the stack traces of who is waiting for the clock. This makes it
    possible to know who has actually called clock.After() and co, so
    you can figure out why there are a particular number of Waiters, and
    whether that is the correct number or not.

Nothing about the interface to the testing clock changes with this, it is just hopefully slightly nicer to debug issues when using the testing clock.

1) Actually wire up the tests for the testing clock. In moving them out
   of 'util' we missed having the TestAll function.
2) Fix a test that checked the logs, but didn't tell the logging
   infrastructure that it needed to read all Debug level log messages.
3) Change clock.WaitAdvance to not break the time into 10 even slices.
   This is because *many* tests use WaitAdvance(..., LongWait), which
   means that if they aren't ready immediately, then they way 1s before
   checking again, which is way too long. Instead we cap out at 10ms, so
   we don't spin waiting for the right number of waiters, but we also
   don't wait too long. We still stop at the same time, and we still
   stop as soon as we have the expected number of waiters.
4) Track the stack traces of who is waiting for the clock. This makes it
   possible to know *who* has actually called clock.After() and co, so
   you can figure out why there are a particular number of Waiters, and
   whether that is the correct number or not.
We assumed that doing WaitAdvance(0,0,0) was valid. However, that
triggers final before next, which means we don't see the 'everything is
ok' event. Instead put one final check during WaitAdvance that we got
what we wanted.
@jameinel
Copy link
Member Author

jameinel commented Feb 4, 2019

$$merge$$

@jujubot jujubot merged commit 88c0f73 into juju:master Feb 4, 2019
jujubot added a commit to juju/juju that referenced this pull request Feb 5, 2019
#9709

## Description of change

The testing clock now iterates faster when given a long timeout, and
gives stack traces when the waiters don't match expectations.

This is just cleanup of the testing clock that helped when I was debugging something else, but we may as well get it into our core code. Only changes the testing clock, so it may change the test suite, but doesn't change production code.

juju/clock#3
juju/clock#4

We need (4) #9712

## QA steps

None.

## Documentation changes

None.

## Bug reference

None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants