From b7cb057b740609f5c10d6fa86d24afd3cffc6371 Mon Sep 17 00:00:00 2001 From: Ryan Skonnord Date: Thu, 12 Oct 2023 15:22:30 -0700 Subject: [PATCH] hc(fix): Fix silo availability error in NotifyEventServiceAction (#58028) Mark NotifyEventServiceActionTest as stable. --- src/sentry/rules/actions/notify_event_service.py | 7 +------ tests/sentry/rules/actions/test_notify_event_service.py | 8 +++++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/sentry/rules/actions/notify_event_service.py b/src/sentry/rules/actions/notify_event_service.py index 5aba9991a3b06e..85a575f63b8a93 100644 --- a/src/sentry/rules/actions/notify_event_service.py +++ b/src/sentry/rules/actions/notify_event_service.py @@ -11,7 +11,6 @@ from sentry.eventstore.models import GroupEvent from sentry.incidents.models import AlertRuleTriggerAction, Incident, IncidentStatus from sentry.integrations.metric_alerts import incident_attachment_info -from sentry.models.integrations.sentry_app import SentryApp from sentry.plugins.base import plugins from sentry.rules import EventState from sentry.rules.actions.base import EventAction @@ -149,11 +148,7 @@ def after( return plugin = None - app = None - try: - app = SentryApp.objects.get(slug=service) - except SentryApp.DoesNotExist: - pass + app = app_service.get_sentry_app_by_slug(slug=service) if app: kwargs = {"sentry_app": app} diff --git a/tests/sentry/rules/actions/test_notify_event_service.py b/tests/sentry/rules/actions/test_notify_event_service.py index 95a4e04fa37fa4..894c84f7f86a2d 100644 --- a/tests/sentry/rules/actions/test_notify_event_service.py +++ b/tests/sentry/rules/actions/test_notify_event_service.py @@ -3,15 +3,16 @@ from django.utils import timezone from sentry.rules.actions.notify_event_service import NotifyEventServiceAction +from sentry.silo import SiloMode from sentry.tasks.sentry_apps import notify_sentry_app from sentry.testutils.cases import RuleTestCase -from sentry.testutils.silo import region_silo_test +from sentry.testutils.silo import assume_test_silo_mode, region_silo_test from sentry.testutils.skips import requires_snuba pytestmark = [requires_snuba] -@region_silo_test +@region_silo_test(stable=True) class NotifyEventServiceActionTest(RuleTestCase): rule_cls = NotifyEventServiceAction @@ -85,7 +86,8 @@ def test_sentry_app_installed(self): assert len(results) == 1 self.install.date_deleted = timezone.now() - self.install.save() + with assume_test_silo_mode(SiloMode.CONTROL): + self.install.save() results = rule.get_services() assert len(results) == 0