Skip to content

Commit 79904fd

Browse files
committed
WIP
1 parent 8183801 commit 79904fd

4 files changed

Lines changed: 24 additions & 42 deletions

File tree

tests/sentry/incidents/test_metric_issue_post_process.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
from sentry.issues.issue_occurrence import IssueOccurrence
55
from sentry.issues.status_change_consumer import update_status
66
from sentry.issues.status_change_message import StatusChangeMessage
7-
from sentry.models.group import Group
7+
from sentry.models.group import Group, GroupStatus
88
from sentry.notifications.models.notificationaction import ActionTarget
99
from sentry.services import eventstore
1010
from sentry.tasks.post_process import post_process_group
1111
from sentry.types.activity import ActivityType
12+
from sentry.types.group import GroupSubStatus
1213
from sentry.workflow_engine.models import Detector
1314
from sentry.workflow_engine.models.data_condition import Condition
1415
from sentry.workflow_engine.types import DetectorPriorityLevel
@@ -202,6 +203,9 @@ def test_resolution_from_critical(self, mock_trigger: MagicMock) -> None:
202203
evaluation_result = self.process_packet_and_return_result(data_packet)
203204
assert isinstance(evaluation_result, StatusChangeMessage)
204205
message = evaluation_result.to_dict()
206+
# Packet processing already resolved the group; reset it so update_status creates a
207+
# genuine SET_RESOLVED activity, which is what dispatches workflow processing.
208+
group.update(status=GroupStatus.UNRESOLVED, substatus=GroupSubStatus.ONGOING)
205209
# TODO: Actions don't trigger on resolution yet. Update this test when this functionality exists.
206210
with patch("sentry.workflow_engine.tasks.workflows.metrics.incr") as mock_incr:
207211
with self.tasks():
@@ -233,6 +237,9 @@ def test_resolution_from_warning(self, mock_trigger: MagicMock) -> None:
233237
evaluation_result = self.process_packet_and_return_result(data_packet)
234238
assert isinstance(evaluation_result, StatusChangeMessage)
235239
message = evaluation_result.to_dict()
240+
# Packet processing already resolved the group; reset it so update_status creates a
241+
# genuine SET_RESOLVED activity, which is what dispatches workflow processing.
242+
group.update(status=GroupStatus.UNRESOLVED, substatus=GroupSubStatus.ONGOING)
236243
# TODO: Actions don't trigger on resolution yet. Update this test when this functionality exists.
237244
with patch("sentry.workflow_engine.tasks.workflows.metrics.incr") as mock_incr:
238245
with self.tasks():

tests/sentry/workflow_engine/handlers/workflow/test_workflow_activity_handlers.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,6 @@ def setUp(self) -> None:
132132
)
133133
self.detector = Detector.objects.get(project=self.project, type=ErrorGroupType.slug)
134134

135-
@mock.patch(
136-
"sentry.workflow_engine.handlers.workflow.workflow_activity_handlers.process_workflow_activity"
137-
)
138-
def test_feature_flag_disabled(self, mock_process_workflow_activity: MagicMock) -> None:
139-
activity_handler(self.group, self.activity, self.detector.id)
140-
mock_process_workflow_activity.delay.assert_not_called()
141-
142135
@mock.patch("sentry.workflow_engine.handlers.workflow.workflow_activity_handlers.metrics")
143136
def test_invalid_activity_type(self, mock_metrics: MagicMock) -> None:
144137
self.activity.type = -1

tests/sentry/workflow_engine/test_task.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,6 @@ def test__e2e__issue_plat_to_processed(
240240
with self.tasks():
241241
update_status(self.group, self.message)
242242

243-
# Issue platform is forwarding the activity update
244-
mock_incr.assert_any_call(
245-
"workflow_engine.issue_platform.status_change_handler",
246-
amount=1,
247-
tags={"activity_type": self.activity.type},
248-
sample_rate=1.0,
249-
)
250-
251-
# Workflow engine is correctly registered for the activity update
252-
mock_incr.assert_any_call(
253-
"workflow_engine.tasks.process_workflows.activity_update",
254-
tags={"activity_type": self.activity.type},
255-
)
256-
257243
# Workflow engine evaluated activity update in process_workflows
258244
mock_incr.assert_any_call(
259245
"workflow_engine.tasks.process_workflows.activity_update.executed",
@@ -296,20 +282,6 @@ def test__e2e__issue_plat_to_processed_activity_data_is_set(
296282
):
297283
process_status_change_message(self.message, txn)
298284

299-
# Issue platform is forwarding the activity update
300-
mock_incr.assert_any_call(
301-
"workflow_engine.issue_platform.status_change_handler",
302-
amount=1,
303-
tags={"activity_type": self.activity.type},
304-
sample_rate=1.0,
305-
)
306-
307-
# Workflow engine is correctly registered for the activity update
308-
mock_incr.assert_any_call(
309-
"workflow_engine.tasks.process_workflows.activity_update",
310-
tags={"activity_type": self.activity.type},
311-
)
312-
313285
# Workflow engine evaluated activity update in process_workflows
314286
mock_incr.assert_any_call(
315287
"workflow_engine.tasks.process_workflows.activity_update.executed",

tests/sentry/workflow_engine/test_task_integration.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,16 @@ def test_handler_invoked__when_update_status_called(self) -> None:
4040
)
4141

4242
with mock.patch("sentry.workflow_engine.tasks.workflows.metrics.incr") as mock_incr:
43-
_process_message(message)
43+
with self.tasks():
44+
_process_message(message)
4445

4546
mock_incr.assert_any_call(
46-
"workflow_engine.tasks.process_workflows.activity_update",
47-
tags={"activity_type": ActivityType.SET_RESOLVED.value},
47+
"workflow_engine.tasks.process_workflows.activity_update.executed",
48+
tags={
49+
"activity_type": ActivityType.SET_RESOLVED.value,
50+
"detector_type": self.detector.type,
51+
},
52+
sample_rate=1.0,
4853
)
4954

5055
def test_handler_invoked__when_resolved(self) -> None:
@@ -63,10 +68,15 @@ def test_handler_invoked__when_resolved(self) -> None:
6368
)
6469

6570
with mock.patch("sentry.workflow_engine.tasks.workflows.metrics.incr") as mock_incr:
66-
update_status(self.group, message)
71+
with self.tasks():
72+
update_status(self.group, message)
6773
mock_incr.assert_any_call(
68-
"workflow_engine.tasks.process_workflows.activity_update",
69-
tags={"activity_type": ActivityType.SET_RESOLVED.value},
74+
"workflow_engine.tasks.process_workflows.activity_update.executed",
75+
tags={
76+
"activity_type": ActivityType.SET_RESOLVED.value,
77+
"detector_type": self.detector.type,
78+
},
79+
sample_rate=1.0,
7080
)
7181

7282
def _resolved_message(self) -> StatusChangeMessageData:

0 commit comments

Comments
 (0)