fix(tests): Fix flaky SessionFetchProjectReleaseHealthTotalsTest timing#108959
Merged
fix(tests): Fix flaky SessionFetchProjectReleaseHealthTotalsTest timing#108959
Conversation
The test was flaky because build_session uses time.time() for session timestamps while the Snuba query uses datetime.utcnow(). These can drift between calls, especially across minute boundaries. Fix by freezing time with a deterministic timestamp and adding the missing super().setUp() call. Fixes #108953
rbro112
reviewed
Feb 24, 2026
| MOCK_DATETIME = (timezone.now() - timedelta(hours=1)).replace(second=30, microsecond=0) | ||
|
|
||
| def setUp(self) -> None: | ||
| super().setUp() |
Member
Author
There was a problem hiding this comment.
nope, if it's overridden it needs to be explicitly called
rbro112
approved these changes
Feb 24, 2026
mchen-sentry
pushed a commit
that referenced
this pull request
Feb 24, 2026
…ng (#108959) ## Summary - Fix flaky `SessionFetchProjectReleaseHealthTotalsTest::test` by freezing time - `build_session()` uses `time.time()` for session timestamps while the Snuba query uses `datetime.utcnow()` — these can drift between calls, especially across minute boundaries - Added `freeze_time` decorator with a deterministic timestamp and the missing `super().setUp()` call Fixes #108953 ## Test plan - [x] `test` passes 10/10 locally - [x] `test_no_data` also passes
wedamija
pushed a commit
that referenced
this pull request
Feb 24, 2026
…ng (#108959) ## Summary - Fix flaky `SessionFetchProjectReleaseHealthTotalsTest::test` by freezing time - `build_session()` uses `time.time()` for session timestamps while the Snuba query uses `datetime.utcnow()` — these can drift between calls, especially across minute boundaries - Added `freeze_time` decorator with a deterministic timestamp and the missing `super().setUp()` call Fixes #108953 ## Test plan - [x] `test` passes 10/10 locally - [x] `test_no_data` also passes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
SessionFetchProjectReleaseHealthTotalsTest::testby freezing timebuild_session()usestime.time()for session timestamps while the Snuba query usesdatetime.utcnow()— these can drift between calls, especially across minute boundariesfreeze_timedecorator with a deterministic timestamp and the missingsuper().setUp()callFixes #108953
Test plan
testpasses 10/10 locallytest_no_dataalso passes