-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
chore(hybridcloud) Move outbox tasks to sentry.hybridcloud #75739
Changes from all commits
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
from .backfill_outboxes import * # noqa | ||
from .deliver_from_outbox import * # noqa | ||
from .deliver_webhooks import * # noqa |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
from collections.abc import Callable | ||
from typing import Any | ||
from unittest.mock import patch | ||
|
||
from django.apps import apps | ||
from django.test.utils import override_settings | ||
|
||
from sentry.db.models import BaseModel | ||
from sentry.hybridcloud.outbox.base import run_outbox_replications_for_self_hosted | ||
from sentry.hybridcloud.tasks.backfill_outboxes import ( | ||
backfill_outboxes_for, | ||
get_backfill_key, | ||
get_processing_state, | ||
process_outbox_backfill_batch, | ||
) | ||
from sentry.models.authidentity import AuthIdentity | ||
from sentry.models.authidentityreplica import AuthIdentityReplica | ||
from sentry.models.authprovider import AuthProvider | ||
|
@@ -13,12 +21,6 @@ | |
from sentry.models.organizationmapping import OrganizationMapping | ||
from sentry.models.outbox import ControlOutbox, RegionOutbox, outbox_context | ||
from sentry.silo.base import SiloMode | ||
from sentry.tasks.backfill_outboxes import ( | ||
backfill_outboxes_for, | ||
get_backfill_key, | ||
get_processing_state, | ||
process_outbox_backfill_batch, | ||
) | ||
from sentry.testutils.factories import Factories | ||
from sentry.testutils.helpers import override_options | ||
from sentry.testutils.outbox import outbox_runner | ||
|
@@ -27,7 +29,7 @@ | |
from sentry.utils import redis | ||
|
||
|
||
def reset_processing_state(): | ||
def reset_processing_state() -> None: | ||
with redis.clusters.get("default").get_local_client_for_key("backfill_outboxes") as client: | ||
for app_models in apps.all_models.values(): | ||
for model in app_models.values(): | ||
|
@@ -36,7 +38,7 @@ def reset_processing_state(): | |
|
||
@django_db_all | ||
@no_silo_test | ||
def test_processing_awaits_options(): | ||
def test_processing_awaits_options() -> None: | ||
reset_processing_state() | ||
org = Factories.create_organization() | ||
with outbox_context(flush=False): | ||
|
@@ -60,7 +62,7 @@ def test_processing_awaits_options(): | |
|
||
|
||
@django_db_all | ||
def test_region_processing(task_runner): | ||
def test_region_processing(task_runner: Callable[..., Any]) -> None: | ||
with outbox_context(flush=False): | ||
for i in range(5): | ||
Factories.create_organization() | ||
|
@@ -78,7 +80,7 @@ def test_region_processing(task_runner): | |
|
||
@django_db_all | ||
@control_silo_test | ||
def test_control_processing(task_runner): | ||
def test_control_processing(task_runner: Callable[..., Any]) -> None: | ||
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. Do we have any type exemptions on these files that we need to clear now that we're explicitly typing things? 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. In their new location they get opted into our standard mypy rules which led to additional types being added. |
||
reset_processing_state() | ||
|
||
org = Factories.create_organization() | ||
|
@@ -96,7 +98,7 @@ def test_control_processing(task_runner): | |
assert not AuthProviderReplica.objects.filter(auth_provider_id=ap.id).exists() | ||
assert not AuthIdentityReplica.objects.filter(auth_provider_id=ap.id).exists() | ||
|
||
def run_for_model(model: type[BaseModel]): | ||
def run_for_model(model: type[BaseModel]) -> None: | ||
while True: | ||
if process_outbox_backfill_batch(model, 1, force_synchronous=True) is None: | ||
break | ||
|
@@ -159,7 +161,7 @@ def run_for_model(model: type[BaseModel]): | |
|
||
@django_db_all | ||
@no_silo_test | ||
def test_run_outbox_replications_for_self_hosted(): | ||
def test_run_outbox_replications_for_self_hosted() -> None: | ||
reset_processing_state() | ||
|
||
with outbox_context(flush=False): | ||
|
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 tasks didn't have their names changed, so updating
CELERY_IMPORTS
should be all that is necessary for tasks to continue executing without interruption.