Skip to content

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

Merged
merged 1 commit into from
May 2, 2025

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented May 1, 2025

We have tests for this logic here: TODO
@armenzg armenzg self-assigned this May 1, 2025


class SnubaTest(TestCase, SnubaTestCase):
@pytest.mark.xfail
Copy link
Member Author

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(
Copy link
Member Author

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:

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 (
Copy link
Member Author

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:

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

@armenzg armenzg requested review from a team and MeredithAnya May 1, 2025 20:00
@armenzg armenzg marked this pull request as ready for review May 1, 2025 20:01
Copy link

codecov bot commented May 1, 2025

Codecov Report

All 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           

@armenzg armenzg merged commit 4ddfbf7 into master May 2, 2025
59 checks passed
@armenzg armenzg deleted the remove/test/deletion/armenzg branch May 2, 2025 13:52
@github-actions github-actions bot locked and limited conversation to collaborators May 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants