-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
ref(grouping): Rewrite hierarchical grouping tests #74144
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
Changes from all commits
84129d1
10e593a
eec5fc2
fdf97ec
b90de58
740fa2a
5b59591
6b932c1
91c244c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,54 +202,19 @@ def test_partial_move(default_project, fast_save): | |
|
||
|
||
class EventManagerGroupingTest(TestCase): | ||
def test_applies_secondary_grouping_hierarchical(self): | ||
project = self.project | ||
project.update_option("sentry:grouping_config", "legacy:2019-03-12") | ||
project.update_option("sentry:secondary_grouping_expiry", 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
timestamp = time.time() - 300 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def save_event(ts_offset): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function has been converted into a helper function. See down below. |
||
ts = timestamp + ts_offset | ||
manager = EventManager( | ||
make_event( | ||
message="foo 123", | ||
event_id=hex(2**127 + int(ts))[-32:], | ||
timestamp=ts, | ||
exception={ | ||
"values": [ | ||
{ | ||
"type": "Hello", | ||
"stacktrace": { | ||
"frames": [ | ||
{ | ||
"function": "not_in_app_function", | ||
}, | ||
{ | ||
"function": "in_app_function", | ||
}, | ||
] | ||
}, | ||
} | ||
] | ||
}, | ||
) | ||
) | ||
manager.normalize() | ||
with self.tasks(): | ||
return manager.save(project.id) | ||
def test_can_upgrade_to_hierarchical_config(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More meaningful naming. |
||
self.set_options("legacy:2019-03-12") # Starting configuration | ||
|
||
event = save_event(0) | ||
event = self.save_event() | ||
|
||
project.update_option("sentry:grouping_config", "mobile:2021-02-12") | ||
project.update_option("sentry:secondary_grouping_config", "legacy:2019-03-12") | ||
project.update_option("sentry:secondary_grouping_expiry", time.time() + (24 * 90 * 3600)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
self.transition_to_new_config("mobile:2021-02-12") | ||
|
||
# Switching to newstyle grouping changes hashes as 123 will be removed | ||
event2 = save_event(2) | ||
# This event will have two sets of hashes | ||
event2 = self.save_event() | ||
|
||
# make sure that events did get into same group because of fallback grouping, not because of hashes which come from primary grouping only | ||
# The hashes property between the two events do not intersect | ||
assert not set(event.get_hashes().hashes) & set(event2.get_hashes().hashes) | ||
# They are both grouped together | ||
assert event.group_id == event2.group_id | ||
|
||
group = Group.objects.get(id=event.group_id) | ||
|
@@ -258,58 +223,23 @@ def save_event(ts_offset): | |
assert group.last_seen == event2.datetime | ||
|
||
# After expiry, new events are still assigned to the same group: | ||
project.update_option("sentry:secondary_grouping_expiry", 0) | ||
event3 = save_event(4) | ||
self.project.update_option("sentry:secondary_grouping_expiry", 0) | ||
event3 = self.save_event() | ||
assert event3.group_id == event2.group_id | ||
|
||
def test_applies_downgrade_hierarchical(self): | ||
project = self.project | ||
project.update_option("sentry:grouping_config", "mobile:2021-02-12") | ||
project.update_option("sentry:secondary_grouping_expiry", 0) | ||
|
||
timestamp = time.time() - 300 | ||
|
||
def save_event(ts_offset): | ||
ts = timestamp + ts_offset | ||
manager = EventManager( | ||
make_event( | ||
message="foo 123", | ||
event_id=hex(2**127 + int(ts))[-32:], | ||
timestamp=ts, | ||
exception={ | ||
"values": [ | ||
{ | ||
"type": "Hello", | ||
"stacktrace": { | ||
"frames": [ | ||
{ | ||
"function": "not_in_app_function", | ||
}, | ||
{ | ||
"function": "in_app_function", | ||
}, | ||
] | ||
}, | ||
} | ||
] | ||
}, | ||
) | ||
) | ||
manager.normalize() | ||
with self.tasks(): | ||
return manager.save(project.id) | ||
def test_can_downgrade_from_hierarchical_config(self): | ||
self.set_options("mobile:2021-02-12") # Starting configuration | ||
|
||
event = save_event(0) | ||
event = self.save_event() | ||
|
||
project.update_option("sentry:grouping_config", "legacy:2019-03-12") | ||
project.update_option("sentry:secondary_grouping_config", "mobile:2021-02-12") | ||
project.update_option("sentry:secondary_grouping_expiry", time.time() + (24 * 90 * 3600)) | ||
self.transition_to_new_config("legacy:2019-03-12") | ||
|
||
# Switching to newstyle grouping changes hashes as 123 will be removed | ||
event2 = save_event(2) | ||
# This event will have two sets of hashes | ||
event2 = self.save_event() | ||
|
||
# make sure that events did get into same group because of fallback grouping, not because of hashes which come from primary grouping only | ||
# The hashes property between the two events do not intersect | ||
assert not set(event.get_hashes().hashes) & set(event2.get_hashes().hashes) | ||
# They are both grouped together | ||
assert event.group_id == event2.group_id | ||
|
||
group = Group.objects.get(id=event.group_id) | ||
|
@@ -325,6 +255,42 @@ def save_event(ts_offset): | |
assert group.last_seen == event2.datetime | ||
|
||
# After expiry, new events are still assigned to the same group: | ||
project.update_option("sentry:secondary_grouping_expiry", 0) | ||
event3 = save_event(4) | ||
self.project.update_option("sentry:secondary_grouping_expiry", 0) | ||
event3 = self.save_event() | ||
assert event3.group_id == event2.group_id | ||
|
||
def save_event(self): | ||
manager = EventManager( | ||
make_event( | ||
message="foo 123", | ||
event_id=hex(2**127)[-32:], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
exception={ | ||
"values": [ | ||
{ | ||
"type": "Hello", | ||
"stacktrace": { | ||
"frames": [ | ||
{"function": "not_in_app_function"}, | ||
{"function": "in_app_function"}, | ||
] | ||
}, | ||
} | ||
] | ||
}, | ||
) | ||
) | ||
manager.normalize() | ||
with self.tasks(): | ||
return manager.save(self.project.id) | ||
|
||
def set_options(self, primary_config): | ||
self.project.update_option("sentry:grouping_config", primary_config) | ||
self.project.update_option("sentry:secondary_grouping_expiry", 0) | ||
|
||
def transition_to_new_config(self, new_config): | ||
original_config = self.project.get_option("sentry:grouping_config") | ||
self.project.update_option("sentry:grouping_config", new_config) | ||
self.project.update_option("sentry:secondary_grouping_config", original_config) | ||
self.project.update_option( | ||
"sentry:secondary_grouping_expiry", time.time() + (24 * 90 * 3600) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is easier to review with the split view
