Skip to content

chore: add Now, Since, AfterFunc to clock; use clock for configmaps test #13476

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

Merged
merged 2 commits into from
Jun 5, 2024

Conversation

spikecurtis
Copy link
Contributor

@spikecurtis spikecurtis commented Jun 5, 2024

Add Now(), Since(), AfterFunc() to clock

Use clock for configmaps test

Copy link
Contributor Author

spikecurtis commented Jun 5, 2024

@spikecurtis spikecurtis requested review from johnstcn and mafredri June 5, 2024 09:58
@spikecurtis spikecurtis marked this pull request as ready for review June 5, 2024 09:58
@spikecurtis spikecurtis force-pushed the spike/clock-testing-example branch from ddbd5b9 to 9492dac Compare June 5, 2024 10:01
@spikecurtis spikecurtis force-pushed the spike/clock-testing-configmaps branch from ec72835 to 1da8c45 Compare June 5, 2024 10:01
Comment on lines -633 to -639
// Before we update the clock again, we need to be sure the timeout has
// completed running. To do that, we check the new lastHandshake has been set
require.Eventually(t, func() bool {
uut.L.Lock()
defer uut.L.Unlock()
return uut.peers[p1ID].lastHandshake == lh
}, testutil.WaitShort, testutil.IntervalFast)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we no longer need this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad you asked! One of the benefits of this library compared with benbjohnson/clock is that we can use Advance().MustWait() to wait for all the AfterFunc() functions to run. So, we don't need to use require.Eventually() and peer into the internal state in order to ensure the timeout has been processed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@spikecurtis spikecurtis force-pushed the spike/clock-testing-example branch from 9492dac to 087459c Compare June 5, 2024 11:37
Base automatically changed from spike/clock-testing-example to main June 5, 2024 11:49
@spikecurtis spikecurtis force-pushed the spike/clock-testing-configmaps branch from 1da8c45 to d5ad7ac Compare June 5, 2024 11:49
Copy link
Contributor Author

spikecurtis commented Jun 5, 2024

Merge activity

  • Jun 5, 7:50 AM EDT: Graphite rebased this pull request after merging its parent, because this pull request is set to merge when ready.
  • Jun 5, 8:00 AM EDT: @spikecurtis merged this pull request with Graphite.

@spikecurtis spikecurtis merged commit 775fc3f into main Jun 5, 2024
29 checks passed
@spikecurtis spikecurtis deleted the spike/clock-testing-configmaps branch June 5, 2024 12:00
@github-actions github-actions bot locked and limited conversation to collaborators Jun 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants