fix: pass in time parameter to prevent flakes #11023
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.
Closes #10600
I'm trying to understand why these tests flake sometimes, like here: https://github.com/coder/coder/actions/runs/6805426561/job/18504925666#step:5:428
Here's what I have so far:
insights_internal_test.go:162: now: 2023-11-08 23:59:56.781794 +0000 UTC m=+7.293516543
and upon further reading about it I think it's reasonable to strip this when dealing with parsed times since we want our operations to match the presentation time.Nvm, time.Parse already has this stripped so that won't do anything...Some tests fail with time not being an even hour, which I believe could be caused by a difference in wall vs monotonic clock.We now think this is because we create a newtime.Now()
inside the function, and with processing lag this can be significant enough to change the time returned.Location
and other times in the tests, as well as more verbose error responses so we know what times it thinks it got. My hunch is that all of these tests fail when it runs on a CI machine that has different time settings than we are used to running in.With the logs we hopefully have a better shot next time this happens.
Update:
now
time into the function. This is so if we are processing the test very slowly (like in CI) the drift can cause flakes when on a time barrier (end of hour, end of day, etc).