ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxmrlv <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #158: ARIA-236 Resumable workflow execution...
Date Wed, 21 Jun 2017 13:58:33 GMT
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/158#discussion_r123254882
  
    --- Diff: tests/orchestrator/test_workflow_runner.py ---
    @@ -293,3 +304,129 @@ def _create_workflow_runner(request, workflow_name, inputs=None,
executor=None,
             resource_storage=resource,
             plugin_manager=plugin_manager,
             **task_configuration_kwargs)
    +
    +
    +class TestResumableWorkflows(object):
    +
    +    def test_resume_workflow(self, workflow_context, executor):
    +        self._create_interface(workflow_context, mock_success_task)
    +
    +        service = workflow_context.service
    +        service.workflows['custom_workflow'] = tests_mock.models.create_operation(
    +            'custom_workflow',
    +            operation_kwargs={'function': '{0}.{1}'.format(__name__, mock_workflow.__name__)}
    +        )
    +        workflow_context.model.service.update(service)
    +
    +        wf_runner = WorkflowRunner(
    +            service_id=workflow_context.service.id,
    +            inputs={},
    +            model_storage=workflow_context.model,
    +            resource_storage=workflow_context.resource,
    +            plugin_manager=None,
    +            workflow_name='custom_workflow',
    +            executor=executor)
    +        wf_thread = Thread(target=wf_runner.execute)
    +        try:
    +            wf_thread.start()
    +
    +            # Wait for the execution to start
    +            while global_test_holder.get('state') != 'active':
    +                pass
    +            global_test_holder['state'] = 'terminated'
    +            wf_runner.cancel()
    +
    +            # Make sure the execution was canceled and the task has not ended
    +            while wf_runner.execution.status != workflow_context.execution.CANCELLED:
    +                pass
    +            task = workflow_context.model.task.list(filters={'_stub_type': None})[0]
    +            assert task.status in (task.FAILED, task.RETRYING)
    +            assert global_test_holder['state'] == 'idle'
    +
    +            # Create a new workflow runner, with an existing execution id. This would
cause
    +            # the old execution to restart.
    +            new_wf_runner = WorkflowRunner(
    +                service_id=wf_runner.service.id,
    +                inputs={},
    +                model_storage=workflow_context.model,
    +                resource_storage=workflow_context.resource,
    +                plugin_manager=None,
    +                execution_id=wf_runner.execution.id,
    +                executor=executor)
    +
    +            # Set the resumed to True, for the execution to succeed.
    +            global_test_holder['resumed'] = True
    +            new_wf_runner.execute()
    +
    +            # Wait for it to finish and assert changes.
    +            while global_test_holder.get('state') != 'ended':
    +                pass
    +            assert task.status == task.SUCCESS
    +            assert wf_runner.execution.status == wf_runner.execution.SUCCEEDED
    +
    +        except:
    --- End diff --
    
    no needed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message