def test_check_concurrency(self): # Pipeline without concurrency defaults to infinite concurrency pipeline = PipelineFactory() pipeline_run = PipelineRunFactory(pipeline=pipeline) assert pipeline_run.check_concurrency() is True # Pipeline with concurrency and pipeline run with operation runs pipeline.concurrency = 2 pipeline.save() # No running operation runs assert pipeline_run.check_concurrency() is True # One operation run operation_run1 = OperationRunFactory(pipeline_run=pipeline_run) assert pipeline_run.check_concurrency() is True # One operation run with RUNNING status operation_run1.status = OperationStatuses.RUNNING operation_run1.save() assert pipeline_run.check_concurrency() is True # Second operation run operation_run2 = OperationRunFactory(pipeline_run=pipeline_run) assert pipeline_run.check_concurrency() is True # Second operation run with RUNNING status operation_run2.status = OperationStatuses.RUNNING operation_run2.save() assert pipeline_run.check_concurrency() is False
def test_check_concurrency(self): # Pipeline without concurrency defaults to infinite concurrency pipeline = PipelineFactory() pipeline_run = PipelineRunFactory(pipeline=pipeline) assert pipeline_run.check_concurrency() is True # Pipeline with concurrency and pipeline run with operation runs pipeline.concurrency = 2 pipeline.save() # No running operation runs assert pipeline_run.check_concurrency() is True # One operation run operation_run1 = OperationRunFactory(pipeline_run=pipeline_run) assert pipeline_run.check_concurrency() is True # One operation run with RUNNING status OperationRunStatus.objects.create(status=OperationStatuses.RUNNING, operation_run=operation_run1) assert pipeline_run.check_concurrency() is True # Second operation run operation_run2 = OperationRunFactory(pipeline_run=pipeline_run) assert pipeline_run.check_concurrency() is True # Second operation run with RUNNING status OperationRunStatus.objects.create(status=OperationStatuses.RUNNING, operation_run=operation_run2) assert pipeline_run.check_concurrency() is False
def test_dag_property(self): pipeline = PipelineFactory() operations = [OperationFactory(pipeline=pipeline) for _ in range(4)] operations[0].upstream_operations.set(operations[2:]) operations[1].upstream_operations.set(operations[2:]) operation_by_ids = {op.id: op for op in operations} assert pipeline.dag == ({ operations[0].id: set(), operations[1].id: set(), operations[2].id: {operations[0].id, operations[1].id}, operations[3].id: {operations[0].id, operations[1].id}, }, operation_by_ids) # Add operations outside the dag operation1 = OperationFactory() operation1.downstream_operations.set( [operations[1], operations[2], operations[3]]) operation2 = OperationFactory() operation2.upstream_operations.set([operations[0], operations[2]]) assert pipeline.dag == ({ operations[0].id: { operation2.id, }, operations[1].id: set(), operations[2].id: {operations[0].id, operations[1].id, operation2.id}, operations[3].id: {operations[0].id, operations[1].id}, }, operation_by_ids)
def setUp(self): super().setUp() self.pipeline = PipelineFactory() self.tested_events = { pipeline_events.PIPELINE_CREATED, pipeline_events.PIPELINE_UPDATED, pipeline_events.PIPELINE_DELETED, pipeline_events.PIPELINE_CLEANED_TRIGGERED, pipeline_events.PIPELINE_VIEWED, pipeline_events.PIPELINE_ARCHIVED, pipeline_events.PIPELINE_RESTORED, pipeline_events.PIPELINE_BOOKMARKED, pipeline_events.PIPELINE_UNBOOKMARKED, pipeline_events.PIPELINE_DELETED_TRIGGERED, }