Browse Source

chore(hybridcloud) Remove import shims for outbox model (#75971)

With getsentry updated we don't need these import shims anymore.

Requires https://github.com/getsentry/getsentry/pull/14877
Mark Story 7 months ago
parent
commit
2d4c51ac63

+ 1 - 1
src/sentry/middleware/integrations/integration_control_middleware.md

@@ -22,7 +22,7 @@ The parsers vary per integration but they follow the same basic steps:
 - Lastly, identify the relevant Region Silos we need to forward to from looking at the `OrganizationMapping`s.
 - Now, depending on the payload we can choose how to respond to the initial request:
   - Some requests will require synchronous responses with an expected response pattern, (e.g. Slack).
-  - Others don't care about the response, and we may opt to handle them asynchronously via the [`ControlOutbox` model](src/sentry/models/outbox.py), (e.g. GitHub).
+  - Others don't care about the response, and we may opt to handle them asynchronously via the [`ControlOutbox` model](src/sentry/hybridcloud/models/outbox.py), (e.g. GitHub).
   - And others may require fanning out identical webhooks to multiple regions where the integration is installed on an organization, (e.g. Jira).
 
 ## Adding Integration Parsers

+ 4 - 4
src/sentry/migrations/0726_apitoken_backfill_hashes.py

@@ -31,7 +31,7 @@ def backfill_hash_values(apps: StateApps, schema_editor: BaseDatabaseSchemaEdito
         logger.exception("Cannot execute migration. Required symbols could not be imported")
         return
 
-    # copied from src/sentry/models/outbox.py
+    # copied from src/sentry/hybridcloud/outbox/category.py
     class OutboxCategory(IntEnum):
         USER_UPDATE = 0
         UNUSED_TWO = 4
@@ -40,11 +40,11 @@ def backfill_hash_values(apps: StateApps, schema_editor: BaseDatabaseSchemaEdito
         AUTH_IDENTITY_UPDATE = 25
         API_TOKEN_UPDATE = 32
 
-    # copied from src/sentry/models/outbox.py
+    # copied from src/sentry/hybridcloud/outbox/category.py
     _outbox_categories_for_scope: dict[int, set[OutboxCategory]] = {}
     _used_categories: set[OutboxCategory] = set()
 
-    # copied from src/sentry/models/outbox.py
+    # copied from src/sentry/hybridcloud/outbox/category.py
     def scope_categories(enum_value: int, categories: set[OutboxCategory]) -> int:
         _outbox_categories_for_scope[enum_value] = categories
         inter = _used_categories.intersection(categories)
@@ -52,7 +52,7 @@ def backfill_hash_values(apps: StateApps, schema_editor: BaseDatabaseSchemaEdito
         _used_categories.update(categories)
         return enum_value
 
-    # copied from src/sentry/models/outbox.py
+    # copied from src/sentry/hybridcloud/outbox/category.py
     class OutboxScope(IntEnum):
         USER_SCOPE = scope_categories(
             1,

+ 0 - 1
src/sentry/models/__init__.py

@@ -79,7 +79,6 @@ from .organizationonboardingtask import *  # NOQA
 from .organizationslugreservation import *  # NOQA
 from .organizationslugreservationreplica import *  # NOQA
 from .orgauthtoken import *  # NOQA
-from .outbox import *  # NOQA
 from .platformexternalissue import *  # NOQA
 from .project import *  # NOQA
 from .projectbookmark import *  # NOQA

+ 0 - 17
src/sentry/models/outbox.py

@@ -1,17 +0,0 @@
-# Import shims for getsentry
-from sentry.hybridcloud.models.outbox import RegionOutboxBase, outbox_context
-from sentry.hybridcloud.outbox.category import (
-    OutboxCategory,
-    OutboxScope,
-    WebhookProviderIdentifier,
-)
-from sentry.hybridcloud.outbox.signals import process_region_outbox
-
-__all__ = (
-    "OutboxCategory",
-    "OutboxScope",
-    "WebhookProviderIdentifier",
-    "outbox_context",
-    "RegionOutboxBase",
-    "process_region_outbox",
-)

+ 7 - 5
tests/sentry/hybridcloud/models/test_outbox.py

@@ -146,7 +146,7 @@ class ControlOutboxTest(TestCase):
 
 
 class OutboxDrainTest(TransactionTestCase):
-    @patch("sentry.models.outbox.process_region_outbox.send")
+    @patch("sentry.hybridcloud.models.outbox.process_region_outbox.send")
     def test_draining_with_disabled_shards(self, mock_send: Mock) -> None:
         outbox1 = Organization(id=1).outbox_for_update()
         outbox2 = Organization(id=1).outbox_for_update()
@@ -196,7 +196,7 @@ class OutboxDrainTest(TransactionTestCase):
         assert not RegionOutbox.objects.filter(id=outbox1.id).first()
         assert RegionOutbox.objects.filter(id=outbox2.id).first()
 
-    @patch("sentry.models.outbox.process_region_outbox.send")
+    @patch("sentry.hybridcloud.models.outbox.process_region_outbox.send")
     def test_drain_shard_not_flush_all__concurrent_processing(
         self, mock_process_region_outbox: Mock
     ) -> None:
@@ -265,7 +265,7 @@ class OutboxDrainTest(TransactionTestCase):
         assert not RegionOutbox.objects.filter(id=outbox1.id).first()
         assert not RegionOutbox.objects.filter(id=outbox2.id).first()
 
-    @patch("sentry.models.outbox.process_region_outbox.send")
+    @patch("sentry.hybridcloud.models.outbox.process_region_outbox.send")
     def test_drain_shard_flush_all__concurrent_processing__cooperation(
         self, mock_process_region_outbox: Mock
     ) -> None:
@@ -375,7 +375,9 @@ class RegionOutboxTest(TestCase):
             raise
 
     def test_outbox_rescheduling(self) -> None:
-        with patch("sentry.models.outbox.process_region_outbox.send") as mock_process_region_outbox:
+        with patch(
+            "sentry.hybridcloud.models.outbox.process_region_outbox.send"
+        ) as mock_process_region_outbox:
 
             def raise_exception(**kwargs: Any) -> None:
                 raise ValueError("This is just a test mock exception")
@@ -436,7 +438,7 @@ class RegionOutboxTest(TestCase):
 
     def test_outbox_converges(self) -> None:
         with patch(
-            "sentry.models.outbox.process_region_outbox.send"
+            "sentry.hybridcloud.models.outbox.process_region_outbox.send"
         ) as mock_process_region_outbox, outbox_context(flush=False):
             Organization(id=10001).outbox_for_update().save()
             Organization(id=10001).outbox_for_update().save()

+ 1 - 1
tests/sentry/migrations/test_0565_fix_diff_env_dupe_alerts.py

@@ -1,7 +1,7 @@
 import pytest
 
 from sentry.constants import ObjectStatus
-from sentry.models.outbox import outbox_context
+from sentry.hybridcloud.models.outbox import outbox_context
 from sentry.testutils.cases import TestMigrations