Github user aviyoop commented on a diff in the pull request:
https://github.com/apache/incubator-ariatosca/pull/208#discussion_r152281650
--- Diff: tests/orchestrator/execution/test_execution_compiler.py ---
@@ -296,171 +230,161 @@ def _setup_mock_workflow_in_service(request,
inputs=None):
return mock_workflow_name
-def _create_workflow_runner(request, workflow_name, inputs=None,
executor=None,
- task_max_attempts=None,
task_retry_interval=None):
+def _get_compiler(request, workflow_name):
# helper method for instantiating a workflow runner
- service_id = request.getfixturevalue('service').id
+ service = request.getfixturevalue('service')
model = request.getfixturevalue('model')
resource = request.getfixturevalue('resource')
plugin_manager = request.getfixturevalue('plugin_manager')
- # task configuration parameters can't be set to None, therefore only
- # passing those if they've been set by the test
- task_configuration_kwargs = dict()
- if task_max_attempts is not None:
- task_configuration_kwargs['task_max_attempts'] = task_max_attempts
- if task_retry_interval is not None:
- task_configuration_kwargs['task_retry_interval'] =
task_retry_interval
-
- return WorkflowRunner(
- workflow_name=workflow_name,
- service_id=service_id,
- inputs=inputs or {},
- executor=executor,
- model_storage=model,
- resource_storage=resource,
- plugin_manager=plugin_manager,
- **task_configuration_kwargs)
+ return execution_compiler.ExecutionCompiler(
+ model,
+ resource,
+ plugin_manager,
+ service,
+ workflow_name
+ )
class TestResumableWorkflows(object):
- def _create_initial_workflow_runner(
- self, workflow_context, workflow, executor, inputs=None):
+ def _compile_execution(
+ self,
+ model,
+ resource,
+ service,
+ workflow,
+ executor,
+ inputs=None):
- service = workflow_context.service
service.workflows['custom_workflow'] =
tests_mock.models.create_operation(
'custom_workflow',
operation_kwargs={
'function': '{0}.{1}'.format(__name__, workflow.__name__),
'inputs': dict((k, models.Input.wrap(k, v)) for k, v in
(inputs or {}).items())
}
)
- workflow_context.model.service.update(service)
-
- wf_runner = WorkflowRunner(
- service_id=workflow_context.service.id,
- inputs=inputs or {},
- model_storage=workflow_context.model,
- resource_storage=workflow_context.resource,
- plugin_manager=None,
- workflow_name='custom_workflow',
- executor=executor)
- return wf_runner
+ model.service.update(service)
+ compiler = execution_compiler.ExecutionCompiler(
+ model, resource, None, service, 'custom_workflow'
+ )
+ ctx = compiler.compile(inputs, executor)
+ model.execution.update(ctx.execution)
+
+ return ctx
@staticmethod
- def _wait_for_active_and_cancel(workflow_runner):
+ def _wait_for_active_and_cancel(eng, ctx):
--- End diff --
`wait_for_execution_to_be_active_and_cancel_it` or
`cancel_active_execution`.
The former is a lot better of course!
---