Skip to content

Commit

Permalink
ref: fix flaky digests test (#81256)
Browse files Browse the repository at this point in the history
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. -->
  • Loading branch information
asottile-sentry authored Nov 25, 2024
1 parent 52f5b44 commit be87cf8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/sentry/notifications/notifications/test_digests.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_slack_digest_notification_block(self, digests):
backend = RedisBackend()
digests.backend.digest = backend.digest
digests.enabled.return_value = True
timestamp_raw = before_now(days=1)
timestamp_raw = before_now(days=1).replace(microsecond=0)
timestamp_secs = int(timestamp_raw.timestamp())
timestamp = timestamp_raw.isoformat()
key = f"slack:p:{self.project.id}:IssueOwners::AllMembers"
Expand Down

0 comments on commit be87cf8

Please sign in to comment.