Skip to content

Commit 7c93d37

Browse files
committed
Add hashes logic
1 parent 56bac5a commit 7c93d37

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

tests/sentry/event_manager/test_hierarchical_hashes.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ def transition_to_new_config(self, new_config):
241241
"sentry:secondary_grouping_expiry", time.time() + (24 * 90 * 3600)
242242
)
243243

244-
def test_applies_secondary_grouping_hierarchical(self):
244+
def test_can_upgrade_to_hierarchical_config(self):
245+
hierarchical_hashes = [
246+
"be778d6d6543432ae89b3e0f94ebff80",
247+
"4e536cc423da0e1e2101b30688aab6b1",
248+
]
245249
self.set_options("legacy:2019-03-12") # Starting configuration
246250
event = self.save_event()
247251
assert event.get_hashes().hashes == ["8b1a9953c4611296a827abf8c47804d7"]
@@ -250,10 +254,6 @@ def test_applies_secondary_grouping_hierarchical(self):
250254
self.transition_to_new_config("mobile:2021-02-12")
251255
# This event will have two sets of hashes
252256
event2 = self.save_event()
253-
hierarchical_hashes = [
254-
"be778d6d6543432ae89b3e0f94ebff80",
255-
"4e536cc423da0e1e2101b30688aab6b1",
256-
]
257257
# The hashes propery gets the last hierarchical hash assigned
258258
assert event2.get_hashes().hashes == [hierarchical_hashes[-1]]
259259
assert event2.get_hashes().hierarchical_hashes == hierarchical_hashes
@@ -272,15 +272,26 @@ def test_applies_secondary_grouping_hierarchical(self):
272272
event3 = self.save_event()
273273
assert event3.group_id == event2.group_id
274274

275-
def test_applies_downgrade_hierarchical(self):
276-
self.set_options("mobile:2021-02-12")
275+
def test_can_downgrade_from_hierarchical_config(self):
276+
hierarchical_hashes = [
277+
"be778d6d6543432ae89b3e0f94ebff80",
278+
"4e536cc423da0e1e2101b30688aab6b1",
279+
]
280+
self.set_options("mobile:2021-02-12") # Starting configuration
277281
event = self.save_event()
282+
assert event.get_hashes().hashes == ["4e536cc423da0e1e2101b30688aab6b1"]
283+
assert event.get_hashes().hierarchical_hashes == hierarchical_hashes
284+
278285
self.transition_to_new_config("legacy:2019-03-12")
279-
# Switching to newstyle grouping changes hashes as 123 will be removed
286+
# This event will have two sets of hashes
280287
event2 = self.save_event()
281288

282-
# make sure that events did get into same group because of fallback grouping, not because of hashes which come from primary grouping only
289+
# The hashes propery gets the last hierarchical hash assigned
290+
assert event2.get_hashes().hashes == ["8b1a9953c4611296a827abf8c47804d7"]
291+
assert event2.get_hashes().hierarchical_hashes == []
292+
# The hashes property between the two events do not intersect
283293
assert not set(event.get_hashes().hashes) & set(event2.get_hashes().hashes)
294+
# They both belong to the same group be
284295
assert event.group_id == event2.group_id
285296

286297
group = Group.objects.get(id=event.group_id)

0 commit comments

Comments
 (0)