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

ref: fix flaky digests test #81256

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Conversation

asottile-sentry
Copy link
Member

relay rounds timestamps whereas the test truncates

I first forced the test to fail with:

diff --git a/tests/sentry/notifications/notifications/test_digests.py b/tests/sentry/notifications/notifications/test_digests.py
index be02406aa1..2943b1875e 100644
--- a/tests/sentry/notifications/notifications/test_digests.py
+++ b/tests/sentry/notifications/notifications/test_digests.py
@@ -163,7 +163,10 @@ class DigestSlackNotification(SlackActivityNotificationTest):
         backend = RedisBackend()
         digests.backend.digest = backend.digest
         digests.enabled.return_value = True
-        timestamp_raw = before_now(days=1)
+        while True:
+            timestamp_raw = before_now(days=1)
+            if int(timestamp_raw.timestamp()) != round(timestamp_raw.timestamp()):
+                break
         timestamp_secs = int(timestamp_raw.timestamp())
         timestamp = timestamp_raw.isoformat()
         key = f"slack:p:{self.project.id}:IssueOwners::AllMembers"

@asottile-sentry asottile-sentry requested review from a team November 25, 2024 18:28
@asottile-sentry asottile-sentry enabled auto-merge (squash) November 25, 2024 18:28
@asottile-sentry asottile-sentry merged commit be87cf8 into master Nov 25, 2024
48 checks passed
@asottile-sentry asottile-sentry deleted the asottile-flaky-digests-test branch November 25, 2024 19:33
andrewshie-sentry pushed a commit that referenced this pull request Dec 2, 2024
relay [rounds
timestamps](https://github.com/getsentry/relay/blob/0459abec0ee79f773d163f35e742cebd34134793/relay-event-schema/src/protocol/types.rs#L896)
whereas the test truncates

I first forced the test to fail with:

```diff
diff --git a/tests/sentry/notifications/notifications/test_digests.py b/tests/sentry/notifications/notifications/test_digests.py
index be02406aa1..2943b1875e 100644
--- a/tests/sentry/notifications/notifications/test_digests.py
+++ b/tests/sentry/notifications/notifications/test_digests.py
@@ -163,7 +163,10 @@ class DigestSlackNotification(SlackActivityNotificationTest):
         backend = RedisBackend()
         digests.backend.digest = backend.digest
         digests.enabled.return_value = True
-        timestamp_raw = before_now(days=1)
+        while True:
+            timestamp_raw = before_now(days=1)
+            if int(timestamp_raw.timestamp()) != round(timestamp_raw.timestamp()):
+                break
         timestamp_secs = int(timestamp_raw.timestamp())
         timestamp = timestamp_raw.isoformat()
         key = f"slack:p:{self.project.id}:IssueOwners::AllMembers"
```

<!-- Describe your PR here. -->
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 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