-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore(aci): default tests to workflow engine #106589
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from unittest import mock | ||
|
|
||
| import pytest | ||
| import sentry_sdk | ||
|
|
||
| from sentry.integrations.jira.integration import JiraIntegration | ||
|
|
@@ -22,7 +23,7 @@ | |
| from sentry.shared_integrations.exceptions import IntegrationFormError | ||
| from sentry.silo.base import SiloMode | ||
| from sentry.testutils.cases import APITestCase | ||
| from sentry.testutils.helpers import with_feature | ||
| from sentry.testutils.helpers.options import override_options | ||
| from sentry.testutils.silo import assume_test_silo_mode | ||
| from sentry.testutils.skips import requires_snuba | ||
| from tests.sentry.workflow_engine.test_base import BaseWorkflowTest | ||
|
|
@@ -155,7 +156,6 @@ def test_no_events(self) -> None: | |
| assert response.status_code == 400 | ||
|
|
||
|
|
||
| @with_feature("organizations:workflow-engine-single-process-workflows") | ||
| class ProjectRuleActionsEndpointWorkflowEngineTest(APITestCase, BaseWorkflowTest): | ||
| endpoint = "sentry-api-0-project-rule-actions" | ||
| method = "POST" | ||
|
|
@@ -165,6 +165,15 @@ def setUp(self) -> None: | |
| self.login_as(self.user) | ||
| self.workflow = self.create_workflow() | ||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def with_feature_flags(self): | ||
| with override_options( | ||
| { | ||
| "workflow_engine.issue_alert.group.type_id.ga": [1], | ||
| } | ||
| ): | ||
| yield | ||
|
|
||
| def setup_pd_service(self) -> PagerDutyServiceDict: | ||
| service_info = { | ||
| "type": "service", | ||
|
|
@@ -226,7 +235,7 @@ def test_name_action_default( | |
| self, mock_get_issue_alert_handler, mock_get_group_type_handler, mock_send_trigger | ||
| ): | ||
| """ | ||
| Tests that label will be used as 'Test Alert' if not present. Uses PagerDuty since those | ||
| Tests that label will be used as 'Error Monitor' if not present. Uses PagerDuty since those | ||
| notifications will differ based on the name of the alert. | ||
| """ | ||
| service_info = self.setup_pd_service() | ||
|
|
@@ -242,41 +251,7 @@ def test_name_action_default( | |
|
|
||
| assert mock_send_trigger.call_count == 1 | ||
| pagerduty_data = mock_send_trigger.call_args.kwargs.get("data") | ||
| assert pagerduty_data["payload"]["summary"].startswith("[Test Alert]:") | ||
|
|
||
| @mock.patch.object(PagerDutyClient, "send_trigger") | ||
| @mock.patch( | ||
| "sentry.notifications.notification_action.registry.group_type_notification_registry.get", | ||
| return_value=IssueAlertRegistryHandler, | ||
| ) | ||
| @mock.patch( | ||
| "sentry.notifications.notification_action.registry.issue_alert_handler_registry.get", | ||
| return_value=PagerDutyIssueAlertHandler, | ||
| ) | ||
| def test_name_action_with_custom_name( | ||
|
Member
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 not have custom names in workflow engine?
Contributor
Author
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. The error detector is always named Error Monitor... we can change this though |
||
| self, mock_get_issue_alert_handler, mock_get_group_type_handler, mock_send_trigger | ||
| ): | ||
| """ | ||
| Tests that custom names can be provided to the test notification. Uses PagerDuty since those | ||
| notifications will differ based on the name of the alert. | ||
| """ | ||
| service_info = self.setup_pd_service() | ||
| action_data = [ | ||
| { | ||
| "account": service_info["integration_id"], | ||
| "service": service_info["id"], | ||
| "severity": "info", | ||
| "id": "sentry.integrations.pagerduty.notify_action.PagerDutyNotifyServiceAction", | ||
| } | ||
| ] | ||
| custom_alert_name = "Check #feed-issues" | ||
|
|
||
| self.get_success_response( | ||
| self.organization.slug, self.project.slug, actions=action_data, name=custom_alert_name | ||
| ) | ||
| assert mock_send_trigger.call_count == 1 | ||
| pagerduty_data = mock_send_trigger.call_args.kwargs.get("data") | ||
| assert pagerduty_data["payload"]["summary"].startswith(f"[{custom_alert_name}]:") | ||
| assert pagerduty_data["payload"]["summary"].startswith("[Error Monitor]:") | ||
|
|
||
| @mock.patch.object(JiraIntegration, "create_issue") | ||
| @mock.patch.object(sentry_sdk, "capture_exception") | ||
|
|
@@ -343,9 +318,6 @@ def test_email_action( | |
|
|
||
| assert mock_notify.call_count == 1 | ||
|
|
||
| @mock.patch( | ||
| "sentry.api.endpoints.project_rule_actions.should_fire_workflow_actions", return_value=True | ||
| ) | ||
| @mock.patch( | ||
| "sentry.rules.actions.sentry_apps.utils.app_service.trigger_sentry_app_action_creators" | ||
| ) | ||
|
|
@@ -362,7 +334,6 @@ def test_sentry_app_action( | |
| mock_get_issue_alert_handler, | ||
| mock_get_group_type_handler, | ||
| mock_trigger_sentry_app_action_creators: mock.MagicMock, | ||
| mock_should_fire_workflow_actions: mock.MagicMock, | ||
| ) -> None: | ||
| self.create_detector(project=self.project) | ||
| schema = { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.