-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
tests(deletion): Remove original test logic #90767
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
Conversation
We have tests for this logic here: TODO
|
||
|
||
class SnubaTest(TestCase, SnubaTestCase): | ||
@pytest.mark.xfail |
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.
We should not be running a test that is known to be failing.
) == {self.project.id: 1} | ||
|
||
# delete it | ||
req = Request( |
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.
The source code has this delete logic:
sentry/src/sentry/deletions/defaults/group.py
Lines 200 to 214 in c5185a1
def delete_events_from_snuba(self) -> None: | |
requests = [] | |
for project_id, group_ids in self.project_groups.items(): | |
query = DeleteQuery( | |
self.dataset.value, | |
column_conditions={"project_id": [project_id], "group_id": group_ids}, | |
) | |
request = Request( | |
dataset=self.dataset.value, | |
app_id=self.referrer, | |
query=query, | |
tenant_ids=self.tenant_ids, | |
) | |
requests.append(request) | |
bulk_snuba_queries(requests) |
|
||
# make sure its gone | ||
time.sleep(5) # test will currently fail without the sleep (maybe it take time to delete?) | ||
assert ( |
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 test fully tests that we delete issue platform issues:
sentry/tests/sentry/deletions/test_group.py
Lines 289 to 329 in a64f27f
def test_issue_platform(self) -> None: | |
# Adding this query here to make sure that the cache is not being used | |
assert self.select_error_events(self.project.id) is None | |
assert self.select_issue_platform_events(self.project.id) is None | |
# Create initial error event and occurrence related to it; two different groups will exist | |
event = self.store_event(data={}, project_id=self.project.id) | |
occurrence, group_info = self.create_occurrence(event, type_id=FeedbackGroup.type_id) | |
# Assertions after creation | |
assert occurrence.id != event.event_id | |
assert group_info is not None | |
issue_platform_group = group_info.group | |
assert event.group_id != issue_platform_group.id | |
assert event.group.issue_category == GroupCategory.ERROR | |
assert issue_platform_group.issue_category != GroupCategory.ERROR | |
# Assert that the occurrence has been inserted in Snuba | |
error_expected = {"event_id": event.event_id, "group_id": event.group_id} | |
occurrence_expected = { | |
"event_id": event.event_id, | |
"group_id": issue_platform_group.id, | |
"occurrence_id": occurrence.id, | |
} | |
assert self.select_error_events(self.project.id) == error_expected | |
assert self.select_issue_platform_events(self.project.id) == occurrence_expected | |
# This will delete the group and the events from the node store and Snuba | |
with self.tasks(): | |
delete_groups(object_ids=[issue_platform_group.id]) | |
# The original event and group still exist | |
assert Group.objects.filter(id=event.group_id).exists() | |
event_node_id = Event.generate_node_id(event.project_id, event.event_id) | |
assert nodestore.backend.get(event_node_id) | |
assert self.select_error_events(self.project.id) == error_expected | |
# The Issue Platform group and occurrence are deleted | |
assert issue_platform_group.issue_type == FeedbackGroup | |
assert not Group.objects.filter(id=issue_platform_group.id).exists() | |
occurrence_node_id = Event.generate_node_id(occurrence.project_id, occurrence.id) | |
assert not nodestore.backend.get(occurrence_node_id) | |
# Assert that occurrence is gone | |
assert self.select_issue_platform_events(self.project.id) is None |
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #90767 +/- ##
=======================================
Coverage 87.79% 87.80%
=======================================
Files 10282 10281 -1
Lines 583491 583489 -2
Branches 22579 22579
=======================================
+ Hits 512305 512306 +1
+ Misses 70755 70752 -3
Partials 431 431 |
We have a better end-to-end test for deletions: https://github.com/getsentry/sentry/blob/master/tests/sentry/deletions/test_group.py#L289-L329
We have a better end-to-end test for deletions:
https://github.com/getsentry/sentry/blob/master/tests/sentry/deletions/test_group.py#L289-L329