@@ -167,14 +167,28 @@ def assert_alert_rule_trigger_migrated(alert_rule_trigger):
167
167
workflow_dcgs = DataConditionGroup .objects .filter (workflowdataconditiongroup__workflow = workflow )
168
168
169
169
data_condition = DataCondition .objects .get (
170
- comparison = condition_result , condition_result = True , condition_group__in = workflow_dcgs
170
+ comparison = condition_result ,
171
+ condition_result = True ,
172
+ condition_group__in = workflow_dcgs ,
173
+ type = Condition .ISSUE_PRIORITY_GREATER_OR_EQUAL ,
171
174
)
172
175
assert data_condition .type == Condition .ISSUE_PRIORITY_GREATER_OR_EQUAL
173
176
assert data_condition .condition_result is True
174
177
assert WorkflowDataConditionGroup .objects .filter (
175
178
condition_group = data_condition .condition_group
176
179
).exists ()
177
180
181
+ resolve_data_condition = DataCondition .objects .get (
182
+ comparison = condition_result ,
183
+ condition_result = True ,
184
+ condition_group__in = workflow_dcgs ,
185
+ type = Condition .ISSUE_PRIORITY_DEESCALATING ,
186
+ )
187
+ assert resolve_data_condition .condition_group == data_condition .condition_group
188
+ assert WorkflowDataConditionGroup .objects .filter (
189
+ condition_group = resolve_data_condition .condition_group
190
+ ).exists ()
191
+
178
192
179
193
def build_sentry_app_compare_blob (
180
194
sentry_app_config : list [dict [str , Any ]],
@@ -333,7 +347,7 @@ def create_migrated_metric_alert_rule_trigger_objects(
333
347
alert_rule_trigger : AlertRuleTrigger ,
334
348
priority : DetectorPriorityLevel ,
335
349
detector_trigger_type : Condition ,
336
- ) -> tuple [DataCondition , DataCondition ]:
350
+ ) -> tuple [DataCondition , DataCondition , DataCondition ]:
337
351
"""
338
352
Set up all the necessary ACI objects for a dual written metric alert trigger.
339
353
"""
@@ -365,7 +379,13 @@ def create_migrated_metric_alert_rule_trigger_objects(
365
379
condition_group = data_condition_group ,
366
380
)
367
381
368
- return detector_trigger , action_filter
382
+ resolve_action_filter = self .create_data_condition (
383
+ comparison = priority ,
384
+ condition_result = True ,
385
+ type = Condition .ISSUE_PRIORITY_DEESCALATING ,
386
+ condition_group = data_condition_group ,
387
+ )
388
+ return detector_trigger , action_filter , resolve_action_filter
369
389
370
390
def create_migrated_metric_alert_rule_resolve_objects (
371
391
self , alert_rule : AlertRule , resolve_threshold , detector_trigger_type : Condition
@@ -516,8 +536,10 @@ def test_dual_delete_comprehensive(self):
516
536
alert_rule_trigger = alert_rule_trigger
517
537
)
518
538
519
- detector_trigger , action_filter = self .create_migrated_metric_alert_rule_trigger_objects (
520
- alert_rule_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
539
+ detector_trigger , action_filter , resolve_action_filter = (
540
+ self .create_migrated_metric_alert_rule_trigger_objects (
541
+ alert_rule_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
542
+ )
521
543
)
522
544
action_filter_dcg = action_filter .condition_group
523
545
action , data_condition_group_action , aarta = (
@@ -541,6 +563,7 @@ def test_dual_delete_comprehensive(self):
541
563
# check trigger objects
542
564
assert not DataConditionGroup .objects .filter (id = action_filter_dcg .id ).exists ()
543
565
assert not DataCondition .objects .filter (id = detector_trigger .id ).exists ()
566
+ assert not DataCondition .objects .filter (id = resolve_action_filter .id ).exists ()
544
567
assert not DataConditionAlertRuleTrigger .objects .filter (
545
568
data_condition = detector_trigger
546
569
).exists ()
@@ -594,10 +617,12 @@ def setUp(self):
594
617
self .alert_rule_trigger = self .create_alert_rule_trigger (
595
618
alert_rule = self .metric_alert , label = "critical" , alert_threshold = 200
596
619
)
597
- self .critical_detector_trigger , self .critical_action_filter = (
598
- self .create_migrated_metric_alert_rule_trigger_objects (
599
- self .alert_rule_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
600
- )
620
+ (
621
+ self .critical_detector_trigger ,
622
+ self .critical_action_filter ,
623
+ self .critical_resolve_action_filter ,
624
+ ) = self .create_migrated_metric_alert_rule_trigger_objects (
625
+ self .alert_rule_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
601
626
)
602
627
self .resolve_detector_trigger = self .create_migrated_metric_alert_rule_resolve_objects (
603
628
self .metric_alert , 200 , Condition .LESS_OR_EQUAL
@@ -736,7 +761,7 @@ def setUp(self):
736
761
alert_rule = self .metric_alert , label = "critical"
737
762
)
738
763
self .create_migrated_metric_alert_objects (self .metric_alert )
739
- self .detector_trigger , self .action_filter = (
764
+ self .detector_trigger , self .action_filter , self . resolve_action_filter = (
740
765
self .create_migrated_metric_alert_rule_trigger_objects (
741
766
self .alert_rule_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
742
767
)
@@ -792,10 +817,12 @@ def setUp(self):
792
817
alert_rule = self .metric_alert , label = "critical" , alert_threshold = 200
793
818
)
794
819
self .create_migrated_metric_alert_objects (self .metric_alert )
795
- self .critical_detector_trigger , self .critical_action_filter = (
796
- self .create_migrated_metric_alert_rule_trigger_objects (
797
- self .alert_rule_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
798
- )
820
+ (
821
+ self .critical_detector_trigger ,
822
+ self .critical_action_filter ,
823
+ self .critical_resolve_action_filter ,
824
+ ) = self .create_migrated_metric_alert_rule_trigger_objects (
825
+ self .alert_rule_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
799
826
)
800
827
self .resolve_detector_trigger = self .create_migrated_metric_alert_rule_resolve_objects (
801
828
self .metric_alert , 200 , Condition .LESS_OR_EQUAL
@@ -1254,7 +1281,7 @@ def setUp(self):
1254
1281
alert_rule = self .metric_alert , label = "critical"
1255
1282
)
1256
1283
self .create_migrated_metric_alert_objects (self .metric_alert )
1257
- self .detector_trigger , self .action_filter = (
1284
+ self .detector_trigger , self .action_filter , self . resolve_action_filter = (
1258
1285
self .create_migrated_metric_alert_rule_trigger_objects (
1259
1286
self .alert_rule_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
1260
1287
)
@@ -1337,7 +1364,7 @@ def setUp(self):
1337
1364
)
1338
1365
1339
1366
self .create_migrated_metric_alert_objects (self .dual_written_alert )
1340
- self .detector_trigger , self .action_filter = (
1367
+ self .detector_trigger , self .action_filter , self . resolve_action_filter = (
1341
1368
self .create_migrated_metric_alert_rule_trigger_objects (
1342
1369
self .dual_written_trigger , DetectorPriorityLevel .HIGH , Condition .GREATER
1343
1370
)
0 commit comments