Skip to content

Conversation

@armenzg
Copy link
Member

@armenzg armenzg commented Nov 25, 2025

The changes includes allow replacing the task_queue with a custom class to support testing of cleanup functions.

@armenzg armenzg self-assigned this Nov 25, 2025
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 25, 2025
# Configure within each Process
import logging

from sentry.utils.imports import import_string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the logic from the multiprocess_worker function is moved into a new function called task_execution.

This allows testing the deletion without being impacted by the multiprocessing set up (DB changes by the tests are not seen by the processes).

)

for chunk in q.iterator(chunk_size=100):
for chunk in q.iterator(chunk_size=DELETES_BY_PROJECT_CHUNK_SIZE):
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 will allow patching within the test.


with (
assume_test_silo_mode(SiloMode.REGION),
patch("sentry.runner.commands.cleanup.DELETES_BY_PROJECT_CHUNK_SIZE", 2),
Copy link
Member Author

@armenzg armenzg Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two groups at a time will be processed.

def test_run_bulk_query_deletes_by_project(self) -> None:
"""Test that the function runs bulk query deletes by project as expected."""
days = 30
self.create_group()
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 only group that won't be past retention.

The changes includes allow replacing the task_queue with a custom class to support testing of cleanup functions.
@armenzg armenzg force-pushed the 11_25/run_by_project_changes/armenzg branch from 4613654 to b0a31a6 Compare November 25, 2025 15:54
@codecov
Copy link

codecov bot commented Nov 25, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
30037 1 30036 240
View the top 1 failed test(s) by shortest run time
tests.sentry.core.endpoints.test_organization_index.OrganizationsCreateTest::test_valid_slugs
Stack Traces | 1.69s run time
#x1B[1m#x1B[.../core/endpoints/test_organization_index.py#x1B[0m:190: in test_valid_slugs
    response = self.get_success_response(name=input_slug, slug=input_slug)
#x1B[1m#x1B[.../sentry/testutils/cases.py#x1B[0m:628: in get_success_response
    assert_status_code(response, 200, 300)
#x1B[1m#x1B[.../sentry/testutils/asserts.py#x1B[0m:47: in assert_status_code
    assert minimum <= response.status_code < maximum, (
#x1B[1m#x1B[31mE   AssertionError: (500, b'{"detail":"Internal Error","errorId":null}')#x1B[0m
#x1B[1m#x1B[31mE   assert 500 < 300#x1B[0m
#x1B[1m#x1B[31mE    +  where 500 = <Response status_code=500, "application/json">.status_code#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
Member

@yuvmen yuvmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! just handle the few bot comments I think they could be right

@armenzg armenzg enabled auto-merge (squash) November 25, 2025 18:40
@armenzg armenzg merged commit 35c0a62 into master Nov 25, 2025
97 of 99 checks passed
@armenzg armenzg deleted the 11_25/run_by_project_changes/armenzg branch November 25, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants