@@ -343,6 +343,58 @@ def test_enqueues_workflow_any_logic_type(self):
343
343
)
344
344
assert project_ids [0 ][0 ] == self .project .id
345
345
346
+ def test_skips_enqueuing_any (self ):
347
+ # skips slow conditions if the condition group evaluates to True without evaluating them
348
+ assert self .workflow .when_condition_group
349
+ self .workflow .when_condition_group .update (
350
+ logic_type = DataConditionGroup .Type .ANY_SHORT_CIRCUIT
351
+ )
352
+
353
+ self .create_data_condition (
354
+ condition_group = self .workflow .when_condition_group ,
355
+ type = Condition .EVENT_FREQUENCY_COUNT ,
356
+ comparison = {
357
+ "interval" : "1h" ,
358
+ "value" : 100 ,
359
+ },
360
+ condition_result = True ,
361
+ )
362
+
363
+ triggered_workflows = evaluate_workflow_triggers ({self .workflow }, self .job )
364
+ assert triggered_workflows == {self .workflow }
365
+ project_ids = buffer .backend .get_sorted_set (
366
+ WORKFLOW_ENGINE_BUFFER_LIST_KEY , 0 , self .buffer_timestamp
367
+ )
368
+ assert len (project_ids ) == 0
369
+
370
+ def test_skips_enqueuing_all (self ):
371
+ assert self .workflow .when_condition_group
372
+ self .workflow .when_condition_group .conditions .all ().delete ()
373
+ self .workflow .when_condition_group .update (logic_type = DataConditionGroup .Type .ALL )
374
+
375
+ self .create_data_condition (
376
+ condition_group = self .workflow .when_condition_group ,
377
+ type = Condition .EVENT_FREQUENCY_COUNT ,
378
+ comparison = {
379
+ "interval" : "1h" ,
380
+ "value" : 100 ,
381
+ },
382
+ condition_result = True ,
383
+ )
384
+ self .create_data_condition (
385
+ condition_group = self .workflow .when_condition_group ,
386
+ type = Condition .REGRESSION_EVENT , # fast condition, does not pass
387
+ comparison = True ,
388
+ condition_result = True ,
389
+ )
390
+
391
+ triggered_workflows = evaluate_workflow_triggers ({self .workflow }, self .job )
392
+ assert not triggered_workflows
393
+ project_ids = buffer .backend .get_sorted_set (
394
+ WORKFLOW_ENGINE_BUFFER_LIST_KEY , 0 , self .buffer_timestamp
395
+ )
396
+ assert len (project_ids ) == 0
397
+
346
398
347
399
class TestEvaluateWorkflowActionFilters (BaseWorkflowTest ):
348
400
def setUp (self ):
0 commit comments