You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by ra...@apache.org on 2017/04/06 08:29:56 UTC
[30/32] incubator-ariatosca git commit: added doc to WorkflowRunner
added doc to WorkflowRunner
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/ee3d67fa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ee3d67fa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ee3d67fa
Branch: refs/heads/ARIA-48-aria-cli
Commit: ee3d67fa7f977c8d6af2cb658596a92095919e57
Parents: ecbf7e4
Author: Ran Ziv <ra...@gigaspaces.com>
Authored: Tue Apr 4 16:44:51 2017 +0300
Committer: Ran Ziv <ra...@gigaspaces.com>
Committed: Thu Apr 6 11:29:17 2017 +0300
----------------------------------------------------------------------
aria/orchestrator/workflow_runner.py | 16 ++++++-
tests/orchestrator/test_runner.py | 74 -------------------------------
2 files changed, 14 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ee3d67fa/aria/orchestrator/workflow_runner.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflow_runner.py b/aria/orchestrator/workflow_runner.py
index b7a81f4..65c0d4c 100644
--- a/aria/orchestrator/workflow_runner.py
+++ b/aria/orchestrator/workflow_runner.py
@@ -42,6 +42,18 @@ class WorkflowRunner(object):
model_storage, resource_storage, plugin_manager,
executor=None, task_max_attempts=DEFAULT_TASK_MAX_ATTEMPTS,
task_retry_interval=DEFAULT_TASK_RETRY_INTERVAL):
+ """
+ Manages a single workflow execution on a given service
+ :param workflow_name: Workflow name
+ :param service_id: Service id
+ :param inputs: A key-value dict of inputs for the execution
+ :param model_storage: Model storage
+ :param resource_storage: Resource storage
+ :param plugin_manager: Plugin manager
+ :param executor: Executor for tasks. Defaults to a ProcessExecutor instance.
+ :param task_max_attempts: Maximum attempts of repeating each failing task
+ :param task_retry_interval: Retry interval in between retry attempts of a failing task
+ """
self._model_storage = model_storage
self._workflow_name = workflow_name
@@ -54,7 +66,7 @@ class WorkflowRunner(object):
workflow_fn = self._get_workflow_fn()
- execution = self._create_execution_models(inputs)
+ execution = self._create_execution_model(inputs)
self._execution_id = execution.id
workflow_context = WorkflowContext(
@@ -93,7 +105,7 @@ class WorkflowRunner(object):
def cancel(self):
self._engine.cancel_execution()
- def _create_execution_models(self, inputs):
+ def _create_execution_model(self, inputs):
execution = models.Execution(
created_at=datetime.utcnow(),
service=self.service,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ee3d67fa/tests/orchestrator/test_runner.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/test_runner.py b/tests/orchestrator/test_runner.py
deleted file mode 100644
index 74e98ad..0000000
--- a/tests/orchestrator/test_runner.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from aria import workflow
-from aria.orchestrator import operation
-from aria.orchestrator.workflows.api.task import OperationTask
-from aria.orchestrator.runner import Runner
-
-from tests import mock
-
-import pytest
-
-
-OPERATION_RESULTS = {}
-
-
-@operation
-def mock_create_operation(ctx, key, value, **kwargs): # pylint: disable=unused-argument
- OPERATION_RESULTS[key] = value
-
-
-@pytest.fixture(autouse=True)
-def cleanup():
- OPERATION_RESULTS.clear()
-
-
-def test_runner_no_tasks():
- @workflow
- def workflow_fn(ctx, graph): # pylint: disable=unused-argument
- pass
-
- _test_runner(workflow_fn)
-
-
-def test_runner_tasks():
- @workflow
- def workflow_fn(ctx, graph):
- for node in ctx.model.node:
- graph.add_tasks(
- OperationTask.for_node(node=node,
- interface_name='Standard',
- operation_name='create'))
-
- _test_runner(workflow_fn)
-
- assert OPERATION_RESULTS.get('create') is True
-
-
-def _initialize_model_storage_fn(model_storage):
- mock.topology.create_simple_topology_single_node(
- model_storage,
- '{0}.{1}'.format(__name__, mock_create_operation.__name__)
- )
-
-
-def _test_runner(workflow_fn):
- runner = Runner(workflow_name='runner workflow',
- workflow_fn=workflow_fn,
- inputs={},
- initialize_model_storage_fn=_initialize_model_storage_fn,
- service_id_fn=lambda: 1)
- runner.run()