@@ -202,13 +202,14 @@ def test_partial_move(default_project, fast_save):
202
202
203
203
204
204
class EventManagerGroupingTest (TestCase ):
205
- def save_event (self , timestamp , ts_offset ):
206
- ts = timestamp + ts_offset
205
+ def setUp (self ):
206
+ super ().setUp ()
207
+
208
+ def save_event (self ):
207
209
manager = EventManager (
208
210
make_event (
209
211
message = "foo 123" ,
210
- event_id = hex (2 ** 127 + int (ts ))[- 32 :],
211
- timestamp = ts ,
212
+ event_id = hex (2 ** 127 )[- 32 :],
212
213
exception = {
213
214
"values" : [
214
215
{
@@ -232,7 +233,7 @@ def set_options(self, primary_config):
232
233
self .project .update_option ("sentry:grouping_config" , primary_config )
233
234
self .project .update_option ("sentry:secondary_grouping_expiry" , 0 )
234
235
235
- def change_configuration (self , new_config ):
236
+ def transition_to_new_config (self , new_config ):
236
237
original_config = self .project .get_option ("sentry:grouping_config" )
237
238
self .project .update_option ("sentry:grouping_config" , new_config )
238
239
self .project .update_option ("sentry:secondary_grouping_config" , original_config )
@@ -241,18 +242,24 @@ def change_configuration(self, new_config):
241
242
)
242
243
243
244
def test_applies_secondary_grouping_hierarchical (self ):
244
- self .set_options ("legacy:2019-03-12" )
245
-
246
- timestamp = time .time () - 300
247
- event = self .save_event (timestamp , 0 )
248
-
249
- self .change_configuration ("mobile:2021-02-12" )
250
-
251
- # Switching to newstyle grouping changes hashes as 123 will be removed
252
- event2 = self .save_event (timestamp , 2 )
253
-
254
- # make sure that events did get into same group because of fallback grouping, not because of hashes which come from primary grouping only
245
+ self .set_options ("legacy:2019-03-12" ) # Starting configuration
246
+ event = self .save_event ()
247
+ assert event .get_hashes ().hashes == ["8b1a9953c4611296a827abf8c47804d7" ]
248
+ assert event .get_hashes ().hierarchical_hashes == []
249
+
250
+ self .transition_to_new_config ("mobile:2021-02-12" )
251
+ # This event will have two sets of hashes
252
+ event2 = self .save_event ()
253
+ hierarchical_hashes = [
254
+ "be778d6d6543432ae89b3e0f94ebff80" ,
255
+ "4e536cc423da0e1e2101b30688aab6b1" ,
256
+ ]
257
+ # The hashes propery gets the last hierarchical hash assigned
258
+ assert event2 .get_hashes ().hashes == [hierarchical_hashes [- 1 ]]
259
+ assert event2 .get_hashes ().hierarchical_hashes == hierarchical_hashes
260
+ # The hashes property between the two events do not intersect
255
261
assert not set (event .get_hashes ().hashes ) & set (event2 .get_hashes ().hashes )
262
+ # They both belong to the same group be
256
263
assert event .group_id == event2 .group_id
257
264
258
265
group = Group .objects .get (id = event .group_id )
@@ -262,20 +269,15 @@ def test_applies_secondary_grouping_hierarchical(self):
262
269
263
270
# After expiry, new events are still assigned to the same group:
264
271
self .project .update_option ("sentry:secondary_grouping_expiry" , 0 )
265
- event3 = self .save_event (timestamp , 4 )
272
+ event3 = self .save_event ()
266
273
assert event3 .group_id == event2 .group_id
267
274
268
275
def test_applies_downgrade_hierarchical (self ):
269
276
self .set_options ("mobile:2021-02-12" )
270
-
271
- timestamp = time .time () - 300
272
-
273
- event = self .save_event (timestamp , 0 )
274
-
275
- self .change_configuration ("mobile:2021-02-12" )
276
-
277
+ event = self .save_event ()
278
+ self .transition_to_new_config ("legacy:2019-03-12" )
277
279
# Switching to newstyle grouping changes hashes as 123 will be removed
278
- event2 = self .save_event (timestamp , 2 )
280
+ event2 = self .save_event ()
279
281
280
282
# make sure that events did get into same group because of fallback grouping, not because of hashes which come from primary grouping only
281
283
assert not set (event .get_hashes ().hashes ) & set (event2 .get_hashes ().hashes )
@@ -295,5 +297,5 @@ def test_applies_downgrade_hierarchical(self):
295
297
296
298
# After expiry, new events are still assigned to the same group:
297
299
self .project .update_option ("sentry:secondary_grouping_expiry" , 0 )
298
- event3 = self .save_event (timestamp , 4 )
300
+ event3 = self .save_event ()
299
301
assert event3 .group_id == event2 .group_id
0 commit comments