You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2016/11/16 10:41:31 UTC
[4/4] incubator-ariatosca git commit: moved tests and celery executor
moved tests and celery executor
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/7f0be027
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/7f0be027
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/7f0be027
Branch: refs/heads/ARIA-21-reorder-repository-sturcutre
Commit: 7f0be027e65750812d1abc6d18099e70828c39a8
Parents: 61dc4d9
Author: mxmrlv <mx...@gmail.com>
Authored: Wed Nov 16 12:41:19 2016 +0200
Committer: mxmrlv <mx...@gmail.com>
Committed: Wed Nov 16 12:41:19 2016 +0200
----------------------------------------------------------------------
.../orchestrator/workflows/executor/__init__.py | 3 +-
aria/orchestrator/workflows/executor/celery.py | 97 ---
extensions/celery/__init__.py | 14 +
extensions/celery/execution.py | 97 +++
tests/context/__init__.py | 33 -
tests/context/test_operation.py | 156 ----
tests/context/test_toolbelt.py | 172 -----
tests/context/test_workflow.py | 63 --
tests/events/__init__.py | 14 -
tests/events/test_builtin_event_handlers.py | 14 -
.../test_workflow_enginge_event_handlers.py | 0
tests/orchestrator/__init__.py | 14 +
tests/orchestrator/context/__init__.py | 33 +
tests/orchestrator/context/test_operation.py | 156 ++++
tests/orchestrator/context/test_toolbelt.py | 172 +++++
tests/orchestrator/context/test_workflow.py | 63 ++
tests/orchestrator/events/__init__.py | 14 +
.../events/test_builtin_event_handlers.py | 14 +
.../test_workflow_enginge_event_handlers.py | 0
tests/orchestrator/workflows/__init__.py | 16 +
tests/orchestrator/workflows/api/__init__.py | 14 +
tests/orchestrator/workflows/api/test_task.py | 150 ++++
.../workflows/api/test_task_graph.py | 745 +++++++++++++++++++
.../orchestrator/workflows/builtin/__init__.py | 86 +++
.../workflows/builtin/test_execute_operation.py | 51 ++
.../orchestrator/workflows/builtin/test_heal.py | 88 +++
.../workflows/builtin/test_install.py | 39 +
.../workflows/builtin/test_uninstall.py | 39 +
tests/orchestrator/workflows/core/__init__.py | 14 +
.../orchestrator/workflows/core/test_engine.py | 435 +++++++++++
tests/orchestrator/workflows/core/test_task.py | 113 +++
.../test_task_graph_into_exececution_graph.py | 105 +++
.../orchestrator/workflows/executor/__init__.py | 14 +
.../workflows/executor/test_executor.py | 141 ++++
tests/workflows/__init__.py | 16 -
tests/workflows/api/__init__.py | 14 -
tests/workflows/api/test_task.py | 150 ----
tests/workflows/api/test_task_graph.py | 745 -------------------
tests/workflows/builtin/__init__.py | 86 ---
.../workflows/builtin/test_execute_operation.py | 51 --
tests/workflows/builtin/test_heal.py | 88 ---
tests/workflows/builtin/test_install.py | 39 -
tests/workflows/builtin/test_uninstall.py | 39 -
tests/workflows/core/__init__.py | 14 -
tests/workflows/core/test_engine.py | 433 -----------
tests/workflows/core/test_task.py | 113 ---
.../test_task_graph_into_exececution_graph.py | 105 ---
tests/workflows/executor/__init__.py | 14 -
tests/workflows/executor/test_executor.py | 141 ----
49 files changed, 2629 insertions(+), 2598 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/aria/orchestrator/workflows/executor/__init__.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/__init__.py b/aria/orchestrator/workflows/executor/__init__.py
index 09fb12c..16b6c9b 100644
--- a/aria/orchestrator/workflows/executor/__init__.py
+++ b/aria/orchestrator/workflows/executor/__init__.py
@@ -18,4 +18,5 @@ Executors for task execution
"""
-from . import blocking, celery, multiprocess, thread
+from . import blocking, multiprocess, thread
+from .base import BaseExecutor
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/aria/orchestrator/workflows/executor/celery.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/celery.py b/aria/orchestrator/workflows/executor/celery.py
deleted file mode 100644
index baa97bd..0000000
--- a/aria/orchestrator/workflows/executor/celery.py
+++ /dev/null
@@ -1,97 +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.
-
-"""
-Celery based executor
-"""
-
-import threading
-import Queue
-
-from .base import BaseExecutor
-
-
-class CeleryExecutor(BaseExecutor):
- """
- Executor which runs tasks using celery
- """
-
- def __init__(self, app, *args, **kwargs):
- super(CeleryExecutor, self).__init__(*args, **kwargs)
- self._app = app
- self._started_signaled = False
- self._started_queue = Queue.Queue(maxsize=1)
- self._tasks = {}
- self._results = {}
- self._receiver = None
- self._stopped = False
- self._receiver_thread = threading.Thread(target=self._events_receiver)
- self._receiver_thread.daemon = True
- self._receiver_thread.start()
- self._started_queue.get(timeout=30)
-
- def execute(self, task):
- self._tasks[task.id] = task
- inputs = task.inputs.copy()
- inputs['ctx'] = task.context
- self._results[task.id] = self._app.send_task(
- task.operation_mapping,
- kwargs=inputs,
- task_id=task.id,
- queue=self._get_queue(task))
-
- def close(self):
- self._stopped = True
- if self._receiver:
- self._receiver.should_stop = True
- self._receiver_thread.join()
-
- @staticmethod
- def _get_queue(task):
- return None if task else None # TODO
-
- def _events_receiver(self):
- with self._app.connection() as connection:
- self._receiver = self._app.events.Receiver(connection, handlers={
- 'task-started': self._celery_task_started,
- 'task-succeeded': self._celery_task_succeeded,
- 'task-failed': self._celery_task_failed,
- })
- for _ in self._receiver.itercapture(limit=None, timeout=None, wakeup=True):
- if not self._started_signaled:
- self._started_queue.put(True)
- self._started_signaled = True
- if self._stopped:
- return
-
- def _celery_task_started(self, event):
- self._task_started(self._tasks[event['uuid']])
-
- def _celery_task_succeeded(self, event):
- task, _ = self._remove_task(event['uuid'])
- self._task_succeeded(task)
-
- def _celery_task_failed(self, event):
- task, async_result = self._remove_task(event['uuid'])
- try:
- exception = async_result.result
- except BaseException as e:
- exception = RuntimeError(
- 'Could not de-serialize exception of task {0} --> {1}: {2}'
- .format(task.name, type(e).__name__, str(e)))
- self._task_failed(task, exception=exception)
-
- def _remove_task(self, task_id):
- return self._tasks.pop(task_id), self._results.pop(task_id)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/extensions/celery/__init__.py
----------------------------------------------------------------------
diff --git a/extensions/celery/__init__.py b/extensions/celery/__init__.py
new file mode 100644
index 0000000..13878a1
--- /dev/null
+++ b/extensions/celery/__init__.py
@@ -0,0 +1,14 @@
+# 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.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/extensions/celery/execution.py
----------------------------------------------------------------------
diff --git a/extensions/celery/execution.py b/extensions/celery/execution.py
new file mode 100644
index 0000000..9e7c4a7
--- /dev/null
+++ b/extensions/celery/execution.py
@@ -0,0 +1,97 @@
+# 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.
+
+"""
+Celery based executor
+"""
+
+import threading
+import Queue
+
+from aria.orchestrator.workflows.executor import BaseExecutor
+
+
+class CeleryExecutor(BaseExecutor):
+ """
+ Executor which runs tasks using celery
+ """
+
+ def __init__(self, app, *args, **kwargs):
+ super(CeleryExecutor, self).__init__(*args, **kwargs)
+ self._app = app
+ self._started_signaled = False
+ self._started_queue = Queue.Queue(maxsize=1)
+ self._tasks = {}
+ self._results = {}
+ self._receiver = None
+ self._stopped = False
+ self._receiver_thread = threading.Thread(target=self._events_receiver)
+ self._receiver_thread.daemon = True
+ self._receiver_thread.start()
+ self._started_queue.get(timeout=30)
+
+ def execute(self, task):
+ self._tasks[task.id] = task
+ inputs = task.inputs.copy()
+ inputs['ctx'] = task.context
+ self._results[task.id] = self._app.send_task(
+ task.operation_mapping,
+ kwargs=inputs,
+ task_id=task.id,
+ queue=self._get_queue(task))
+
+ def close(self):
+ self._stopped = True
+ if self._receiver:
+ self._receiver.should_stop = True
+ self._receiver_thread.join()
+
+ @staticmethod
+ def _get_queue(task):
+ return None if task else None # TODO
+
+ def _events_receiver(self):
+ with self._app.connection() as connection:
+ self._receiver = self._app.events.Receiver(connection, handlers={
+ 'task-started': self._celery_task_started,
+ 'task-succeeded': self._celery_task_succeeded,
+ 'task-failed': self._celery_task_failed,
+ })
+ for _ in self._receiver.itercapture(limit=None, timeout=None, wakeup=True):
+ if not self._started_signaled:
+ self._started_queue.put(True)
+ self._started_signaled = True
+ if self._stopped:
+ return
+
+ def _celery_task_started(self, event):
+ self._task_started(self._tasks[event['uuid']])
+
+ def _celery_task_succeeded(self, event):
+ task, _ = self._remove_task(event['uuid'])
+ self._task_succeeded(task)
+
+ def _celery_task_failed(self, event):
+ task, async_result = self._remove_task(event['uuid'])
+ try:
+ exception = async_result.result
+ except BaseException as e:
+ exception = RuntimeError(
+ 'Could not de-serialize exception of task {0} --> {1}: {2}'
+ .format(task.name, type(e).__name__, str(e)))
+ self._task_failed(task, exception=exception)
+
+ def _remove_task(self, task_id):
+ return self._tasks.pop(task_id), self._results.pop(task_id)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/context/__init__.py
----------------------------------------------------------------------
diff --git a/tests/context/__init__.py b/tests/context/__init__.py
deleted file mode 100644
index ea0fea9..0000000
--- a/tests/context/__init__.py
+++ /dev/null
@@ -1,33 +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.
-
-import sys
-
-from aria.orchestrator.workflows.core import engine
-
-
-def op_path(func, module_path=None):
- module_path = module_path or sys.modules[__name__].__name__
- return '{0}.{1}'.format(module_path, func.__name__)
-
-
-def op_name(actor, operation_name):
- return '{name}.{actor.id}'.format(name=operation_name, actor=actor)
-
-
-def execute(workflow_func, workflow_context, executor):
- graph = workflow_func(ctx=workflow_context)
- eng = engine.Engine(executor=executor, workflow_context=workflow_context, tasks_graph=graph)
- eng.execute()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/context/test_operation.py b/tests/context/test_operation.py
deleted file mode 100644
index 9128bd6..0000000
--- a/tests/context/test_operation.py
+++ /dev/null
@@ -1,156 +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.
-
-import pytest
-
-from aria import (
- workflow,
- operation,
-)
-from aria.orchestrator import context
-from aria.orchestrator.workflows import api
-from aria.orchestrator.workflows.executor import thread
-
-from .. import mock
-from . import (
- op_path,
- op_name,
- execute,
-)
-
-global_test_holder = {}
-
-
-@pytest.fixture
-def ctx():
- return mock.context.simple()
-
-
-@pytest.fixture
-def executor():
- result = thread.ThreadExecutor()
- try:
- yield result
- finally:
- result.close()
-
-
-def test_node_operation_task_execution(ctx, executor):
- operation_name = 'aria.interfaces.lifecycle.create'
-
- node = mock.models.get_dependency_node()
- node.operations[operation_name] = {
- 'operation': op_path(my_operation, module_path=__name__)
-
- }
- node_instance = mock.models.get_dependency_node_instance(node)
- ctx.model.node.store(node)
- ctx.model.node_instance.store(node_instance)
-
- inputs = {'putput': True}
-
- @workflow
- def basic_workflow(graph, **_):
- graph.add_tasks(
- api.task.OperationTask.node_instance(
- name=operation_name,
- instance=node_instance,
- inputs=inputs
- )
- )
-
- execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
-
- operation_context = global_test_holder[op_name(node_instance, operation_name)]
-
- assert isinstance(operation_context, context.operation.NodeOperationContext)
-
- # Task bases assertions
- assert operation_context.task.actor == node_instance
- assert operation_context.task.name == op_name(node_instance, operation_name)
- assert operation_context.task.operation_mapping == node.operations[operation_name]['operation']
- assert operation_context.task.inputs == inputs
-
- # Context based attributes (sugaring)
- assert operation_context.node == node_instance.node
- assert operation_context.node_instance == node_instance
-
-
-def test_relationship_operation_task_execution(ctx, executor):
- operation_name = 'aria.interfaces.relationship_lifecycle.postconfigure'
-
- dependency_node = mock.models.get_dependency_node()
- dependency_node_instance = mock.models.get_dependency_node_instance()
- relationship = mock.models.get_relationship(target=dependency_node)
- relationship.source_operations[operation_name] = {
- 'operation': op_path(my_operation, module_path=__name__)
- }
- relationship_instance = mock.models.get_relationship_instance(
- target_instance=dependency_node_instance,
- relationship=relationship)
- dependent_node = mock.models.get_dependent_node()
- dependent_node_instance = mock.models.get_dependent_node_instance(
- relationship_instance=relationship_instance,
- dependent_node=dependency_node)
- ctx.model.node.store(dependency_node)
- ctx.model.node_instance.store(dependency_node_instance)
- ctx.model.relationship.store(relationship)
- ctx.model.relationship_instance.store(relationship_instance)
- ctx.model.node.store(dependent_node)
- ctx.model.node_instance.store(dependent_node_instance)
-
- inputs = {'putput': True}
-
- @workflow
- def basic_workflow(graph, **_):
- graph.add_tasks(
- api.task.OperationTask.relationship_instance(
- instance=relationship_instance,
- name=operation_name,
- operation_end=api.task.OperationTask.SOURCE_OPERATION,
- inputs=inputs
- )
- )
-
- execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
-
- operation_context = global_test_holder[op_name(relationship_instance, operation_name)]
-
- assert isinstance(operation_context, context.operation.RelationshipOperationContext)
-
- # Task bases assertions
- assert operation_context.task.actor == relationship_instance
- assert operation_context.task.name == op_name(relationship_instance, operation_name)
- assert operation_context.task.operation_mapping == \
- relationship.source_operations[operation_name]['operation']
- assert operation_context.task.inputs == inputs
-
- # Context based attributes (sugaring)
- assert operation_context.target_node == dependency_node
- assert operation_context.target_node_instance == dependency_node_instance
- assert operation_context.relationship == relationship
- assert operation_context.relationship_instance == relationship_instance
- assert operation_context.source_node == dependent_node
- assert operation_context.source_node_instance == dependent_node_instance
-
-
-@operation
-def my_operation(ctx, **_):
- global_test_holder[ctx.name] = ctx
-
-
-@pytest.fixture(autouse=True)
-def cleanup():
- global_test_holder.clear()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/context/test_toolbelt.py
----------------------------------------------------------------------
diff --git a/tests/context/test_toolbelt.py b/tests/context/test_toolbelt.py
deleted file mode 100644
index ede1864..0000000
--- a/tests/context/test_toolbelt.py
+++ /dev/null
@@ -1,172 +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.
-
-import pytest
-
-from aria import workflow, operation
-from aria.orchestrator import context
-from aria.orchestrator.workflows import api
-from aria.orchestrator.workflows.executor import thread
-from aria.orchestrator.context.toolbelt import RelationshipToolBelt
-
-from .. import mock
-from . import (
- op_path,
- op_name,
- execute,
-)
-
-global_test_holder = {}
-
-
-@pytest.fixture
-def workflow_context():
- return mock.context.simple()
-
-
-@pytest.fixture
-def executor():
- result = thread.ThreadExecutor()
- try:
- yield result
- finally:
- result.close()
-
-
-def _create_simple_model_in_storage(workflow_context):
- dependency_node = mock.models.get_dependency_node()
- dependency_node_instance = mock.models.get_dependency_node_instance(
- dependency_node=dependency_node)
- relationship = mock.models.get_relationship(target=dependency_node)
- relationship_instance = mock.models.get_relationship_instance(
- target_instance=dependency_node_instance, relationship=relationship)
- dependent_node = mock.models.get_dependent_node()
- dependent_node_instance = mock.models.get_dependent_node_instance(
- relationship_instance=relationship_instance, dependent_node=dependency_node)
- workflow_context.model.node.store(dependency_node)
- workflow_context.model.node_instance.store(dependency_node_instance)
- workflow_context.model.relationship.store(relationship)
- workflow_context.model.relationship_instance.store(relationship_instance)
- workflow_context.model.node.store(dependent_node)
- workflow_context.model.node_instance.store(dependent_node_instance)
- return dependency_node, dependency_node_instance, \
- dependent_node, dependent_node_instance, \
- relationship, relationship_instance
-
-
-def test_host_ip(workflow_context, executor):
- operation_name = 'aria.interfaces.lifecycle.create'
- dependency_node, dependency_node_instance, _, _, _, _ = \
- _create_simple_model_in_storage(workflow_context)
- dependency_node.operations[operation_name] = {
- 'operation': op_path(host_ip, module_path=__name__)
-
- }
- workflow_context.model.node.store(dependency_node)
- inputs = {'putput': True}
-
- @workflow
- def basic_workflow(graph, **_):
- graph.add_tasks(
- api.task.OperationTask.node_instance(
- instance=dependency_node_instance,
- name=operation_name,
- inputs=inputs
- )
- )
-
- execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
-
- assert global_test_holder.get('host_ip') == \
- dependency_node_instance.runtime_properties.get('ip')
-
-
-def test_dependent_node_instances(workflow_context, executor):
- operation_name = 'aria.interfaces.lifecycle.create'
- dependency_node, dependency_node_instance, _, dependent_node_instance, _, _ = \
- _create_simple_model_in_storage(workflow_context)
- dependency_node.operations[operation_name] = {
- 'operation': op_path(dependent_nodes, module_path=__name__)
-
- }
- workflow_context.model.node.store(dependency_node)
- inputs = {'putput': True}
-
- @workflow
- def basic_workflow(graph, **_):
- graph.add_tasks(
- api.task.OperationTask.node_instance(
- instance=dependency_node_instance,
- name=operation_name,
- inputs=inputs
- )
- )
-
- execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
-
- assert list(global_test_holder.get('dependent_node_instances', [])) == \
- list([dependent_node_instance])
-
-
-def test_relationship_tool_belt(workflow_context, executor):
- operation_name = 'aria.interfaces.relationship_lifecycle.postconfigure'
- _, _, _, _, relationship, relationship_instance = \
- _create_simple_model_in_storage(workflow_context)
- relationship.source_operations[operation_name] = {
- 'operation': op_path(relationship_operation, module_path=__name__)
- }
- workflow_context.model.relationship.store(relationship)
-
- inputs = {'putput': True}
-
- @workflow
- def basic_workflow(graph, **_):
- graph.add_tasks(
- api.task.OperationTask.relationship_instance(
- instance=relationship_instance,
- name=operation_name,
- operation_end=api.task.OperationTask.SOURCE_OPERATION,
- inputs=inputs
- )
- )
-
- execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
-
- assert isinstance(global_test_holder.get(op_name(relationship_instance, operation_name)),
- RelationshipToolBelt)
-
-
-def test_wrong_model_toolbelt():
- with pytest.raises(RuntimeError):
- context.toolbelt(None)
-
-@operation(toolbelt=True)
-def host_ip(toolbelt, **_):
- global_test_holder['host_ip'] = toolbelt.host_ip
-
-
-@operation(toolbelt=True)
-def dependent_nodes(toolbelt, **_):
- global_test_holder['dependent_node_instances'] = list(toolbelt.dependent_node_instances)
-
-
-@operation(toolbelt=True)
-def relationship_operation(ctx, toolbelt, **_):
- global_test_holder[ctx.name] = toolbelt
-
-
-@pytest.fixture(autouse=True)
-def cleanup():
- global_test_holder.clear()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/context/test_workflow.py
----------------------------------------------------------------------
diff --git a/tests/context/test_workflow.py b/tests/context/test_workflow.py
deleted file mode 100644
index bc73b9c..0000000
--- a/tests/context/test_workflow.py
+++ /dev/null
@@ -1,63 +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 datetime import datetime
-
-import pytest
-
-from aria import application_model_storage
-from aria.orchestrator import context
-
-from ..mock import models
-from ..storage import InMemoryModelDriver
-
-
-class TestWorkflowContext(object):
-
- def test_execution_creation_on_workflow_context_creation(self, storage):
- self._create_ctx(storage)
- execution = storage.execution.get(models.EXECUTION_ID)
- assert execution.id == models.EXECUTION_ID
- assert execution.deployment_id == models.DEPLOYMENT_ID
- assert execution.workflow_id == models.WORKFLOW_ID
- assert execution.blueprint_id == models.BLUEPRINT_ID
- assert execution.status == storage.execution.model_cls.PENDING
- assert execution.parameters == {}
- assert execution.created_at <= datetime.utcnow()
-
- def test_subsequent_workflow_context_creation_do_not_fail(self, storage):
- self._create_ctx(storage)
- self._create_ctx(storage)
-
- @staticmethod
- def _create_ctx(storage):
- return context.workflow.WorkflowContext(
- name='simple_context',
- model_storage=storage,
- resource_storage=None,
- deployment_id=models.DEPLOYMENT_ID,
- workflow_id=models.WORKFLOW_ID,
- execution_id=models.EXECUTION_ID,
- task_max_attempts=models.TASK_MAX_ATTEMPTS,
- task_retry_interval=models.TASK_RETRY_INTERVAL
- )
-
-
-@pytest.fixture(scope='function')
-def storage():
- result = application_model_storage(InMemoryModelDriver())
- result.setup()
- result.deployment.store(models.get_deployment())
- return result
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/events/__init__.py
----------------------------------------------------------------------
diff --git a/tests/events/__init__.py b/tests/events/__init__.py
deleted file mode 100644
index ae1e83e..0000000
--- a/tests/events/__init__.py
+++ /dev/null
@@ -1,14 +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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/events/test_builtin_event_handlers.py
----------------------------------------------------------------------
diff --git a/tests/events/test_builtin_event_handlers.py b/tests/events/test_builtin_event_handlers.py
deleted file mode 100644
index ae1e83e..0000000
--- a/tests/events/test_builtin_event_handlers.py
+++ /dev/null
@@ -1,14 +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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/events/test_workflow_enginge_event_handlers.py
----------------------------------------------------------------------
diff --git a/tests/events/test_workflow_enginge_event_handlers.py b/tests/events/test_workflow_enginge_event_handlers.py
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/__init__.py b/tests/orchestrator/__init__.py
new file mode 100644
index 0000000..13878a1
--- /dev/null
+++ b/tests/orchestrator/__init__.py
@@ -0,0 +1,14 @@
+# 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.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/context/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/__init__.py b/tests/orchestrator/context/__init__.py
new file mode 100644
index 0000000..ea0fea9
--- /dev/null
+++ b/tests/orchestrator/context/__init__.py
@@ -0,0 +1,33 @@
+# 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.
+
+import sys
+
+from aria.orchestrator.workflows.core import engine
+
+
+def op_path(func, module_path=None):
+ module_path = module_path or sys.modules[__name__].__name__
+ return '{0}.{1}'.format(module_path, func.__name__)
+
+
+def op_name(actor, operation_name):
+ return '{name}.{actor.id}'.format(name=operation_name, actor=actor)
+
+
+def execute(workflow_func, workflow_context, executor):
+ graph = workflow_func(ctx=workflow_context)
+ eng = engine.Engine(executor=executor, workflow_context=workflow_context, tasks_graph=graph)
+ eng.execute()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py
new file mode 100644
index 0000000..6b3e28d
--- /dev/null
+++ b/tests/orchestrator/context/test_operation.py
@@ -0,0 +1,156 @@
+# 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.
+
+import pytest
+
+from aria import (
+ workflow,
+ operation,
+)
+from aria.orchestrator import context
+from aria.orchestrator.workflows import api
+from aria.orchestrator.workflows.executor import thread
+
+from tests import mock
+from . import (
+ op_path,
+ op_name,
+ execute,
+)
+
+global_test_holder = {}
+
+
+@pytest.fixture
+def ctx():
+ return mock.context.simple()
+
+
+@pytest.fixture
+def executor():
+ result = thread.ThreadExecutor()
+ try:
+ yield result
+ finally:
+ result.close()
+
+
+def test_node_operation_task_execution(ctx, executor):
+ operation_name = 'aria.interfaces.lifecycle.create'
+
+ node = mock.models.get_dependency_node()
+ node.operations[operation_name] = {
+ 'operation': op_path(my_operation, module_path=__name__)
+
+ }
+ node_instance = mock.models.get_dependency_node_instance(node)
+ ctx.model.node.store(node)
+ ctx.model.node_instance.store(node_instance)
+
+ inputs = {'putput': True}
+
+ @workflow
+ def basic_workflow(graph, **_):
+ graph.add_tasks(
+ api.task.OperationTask.node_instance(
+ name=operation_name,
+ instance=node_instance,
+ inputs=inputs
+ )
+ )
+
+ execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
+
+ operation_context = global_test_holder[op_name(node_instance, operation_name)]
+
+ assert isinstance(operation_context, context.operation.NodeOperationContext)
+
+ # Task bases assertions
+ assert operation_context.task.actor == node_instance
+ assert operation_context.task.name == op_name(node_instance, operation_name)
+ assert operation_context.task.operation_mapping == node.operations[operation_name]['operation']
+ assert operation_context.task.inputs == inputs
+
+ # Context based attributes (sugaring)
+ assert operation_context.node == node_instance.node
+ assert operation_context.node_instance == node_instance
+
+
+def test_relationship_operation_task_execution(ctx, executor):
+ operation_name = 'aria.interfaces.relationship_lifecycle.postconfigure'
+
+ dependency_node = mock.models.get_dependency_node()
+ dependency_node_instance = mock.models.get_dependency_node_instance()
+ relationship = mock.models.get_relationship(target=dependency_node)
+ relationship.source_operations[operation_name] = {
+ 'operation': op_path(my_operation, module_path=__name__)
+ }
+ relationship_instance = mock.models.get_relationship_instance(
+ target_instance=dependency_node_instance,
+ relationship=relationship)
+ dependent_node = mock.models.get_dependent_node()
+ dependent_node_instance = mock.models.get_dependent_node_instance(
+ relationship_instance=relationship_instance,
+ dependent_node=dependency_node)
+ ctx.model.node.store(dependency_node)
+ ctx.model.node_instance.store(dependency_node_instance)
+ ctx.model.relationship.store(relationship)
+ ctx.model.relationship_instance.store(relationship_instance)
+ ctx.model.node.store(dependent_node)
+ ctx.model.node_instance.store(dependent_node_instance)
+
+ inputs = {'putput': True}
+
+ @workflow
+ def basic_workflow(graph, **_):
+ graph.add_tasks(
+ api.task.OperationTask.relationship_instance(
+ instance=relationship_instance,
+ name=operation_name,
+ operation_end=api.task.OperationTask.SOURCE_OPERATION,
+ inputs=inputs
+ )
+ )
+
+ execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
+
+ operation_context = global_test_holder[op_name(relationship_instance, operation_name)]
+
+ assert isinstance(operation_context, context.operation.RelationshipOperationContext)
+
+ # Task bases assertions
+ assert operation_context.task.actor == relationship_instance
+ assert operation_context.task.name == op_name(relationship_instance, operation_name)
+ assert operation_context.task.operation_mapping == \
+ relationship.source_operations[operation_name]['operation']
+ assert operation_context.task.inputs == inputs
+
+ # Context based attributes (sugaring)
+ assert operation_context.target_node == dependency_node
+ assert operation_context.target_node_instance == dependency_node_instance
+ assert operation_context.relationship == relationship
+ assert operation_context.relationship_instance == relationship_instance
+ assert operation_context.source_node == dependent_node
+ assert operation_context.source_node_instance == dependent_node_instance
+
+
+@operation
+def my_operation(ctx, **_):
+ global_test_holder[ctx.name] = ctx
+
+
+@pytest.fixture(autouse=True)
+def cleanup():
+ global_test_holder.clear()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/context/test_toolbelt.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_toolbelt.py b/tests/orchestrator/context/test_toolbelt.py
new file mode 100644
index 0000000..547e62b
--- /dev/null
+++ b/tests/orchestrator/context/test_toolbelt.py
@@ -0,0 +1,172 @@
+# 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.
+
+import pytest
+
+from aria import workflow, operation
+from aria.orchestrator import context
+from aria.orchestrator.workflows import api
+from aria.orchestrator.workflows.executor import thread
+from aria.orchestrator.context.toolbelt import RelationshipToolBelt
+
+from tests import mock
+from . import (
+ op_path,
+ op_name,
+ execute,
+)
+
+global_test_holder = {}
+
+
+@pytest.fixture
+def workflow_context():
+ return mock.context.simple()
+
+
+@pytest.fixture
+def executor():
+ result = thread.ThreadExecutor()
+ try:
+ yield result
+ finally:
+ result.close()
+
+
+def _create_simple_model_in_storage(workflow_context):
+ dependency_node = mock.models.get_dependency_node()
+ dependency_node_instance = mock.models.get_dependency_node_instance(
+ dependency_node=dependency_node)
+ relationship = mock.models.get_relationship(target=dependency_node)
+ relationship_instance = mock.models.get_relationship_instance(
+ target_instance=dependency_node_instance, relationship=relationship)
+ dependent_node = mock.models.get_dependent_node()
+ dependent_node_instance = mock.models.get_dependent_node_instance(
+ relationship_instance=relationship_instance, dependent_node=dependency_node)
+ workflow_context.model.node.store(dependency_node)
+ workflow_context.model.node_instance.store(dependency_node_instance)
+ workflow_context.model.relationship.store(relationship)
+ workflow_context.model.relationship_instance.store(relationship_instance)
+ workflow_context.model.node.store(dependent_node)
+ workflow_context.model.node_instance.store(dependent_node_instance)
+ return dependency_node, dependency_node_instance, \
+ dependent_node, dependent_node_instance, \
+ relationship, relationship_instance
+
+
+def test_host_ip(workflow_context, executor):
+ operation_name = 'aria.interfaces.lifecycle.create'
+ dependency_node, dependency_node_instance, _, _, _, _ = \
+ _create_simple_model_in_storage(workflow_context)
+ dependency_node.operations[operation_name] = {
+ 'operation': op_path(host_ip, module_path=__name__)
+
+ }
+ workflow_context.model.node.store(dependency_node)
+ inputs = {'putput': True}
+
+ @workflow
+ def basic_workflow(graph, **_):
+ graph.add_tasks(
+ api.task.OperationTask.node_instance(
+ instance=dependency_node_instance,
+ name=operation_name,
+ inputs=inputs
+ )
+ )
+
+ execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
+
+ assert global_test_holder.get('host_ip') == \
+ dependency_node_instance.runtime_properties.get('ip')
+
+
+def test_dependent_node_instances(workflow_context, executor):
+ operation_name = 'aria.interfaces.lifecycle.create'
+ dependency_node, dependency_node_instance, _, dependent_node_instance, _, _ = \
+ _create_simple_model_in_storage(workflow_context)
+ dependency_node.operations[operation_name] = {
+ 'operation': op_path(dependent_nodes, module_path=__name__)
+
+ }
+ workflow_context.model.node.store(dependency_node)
+ inputs = {'putput': True}
+
+ @workflow
+ def basic_workflow(graph, **_):
+ graph.add_tasks(
+ api.task.OperationTask.node_instance(
+ instance=dependency_node_instance,
+ name=operation_name,
+ inputs=inputs
+ )
+ )
+
+ execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
+
+ assert list(global_test_holder.get('dependent_node_instances', [])) == \
+ list([dependent_node_instance])
+
+
+def test_relationship_tool_belt(workflow_context, executor):
+ operation_name = 'aria.interfaces.relationship_lifecycle.postconfigure'
+ _, _, _, _, relationship, relationship_instance = \
+ _create_simple_model_in_storage(workflow_context)
+ relationship.source_operations[operation_name] = {
+ 'operation': op_path(relationship_operation, module_path=__name__)
+ }
+ workflow_context.model.relationship.store(relationship)
+
+ inputs = {'putput': True}
+
+ @workflow
+ def basic_workflow(graph, **_):
+ graph.add_tasks(
+ api.task.OperationTask.relationship_instance(
+ instance=relationship_instance,
+ name=operation_name,
+ operation_end=api.task.OperationTask.SOURCE_OPERATION,
+ inputs=inputs
+ )
+ )
+
+ execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
+
+ assert isinstance(global_test_holder.get(op_name(relationship_instance, operation_name)),
+ RelationshipToolBelt)
+
+
+def test_wrong_model_toolbelt():
+ with pytest.raises(RuntimeError):
+ context.toolbelt(None)
+
+@operation(toolbelt=True)
+def host_ip(toolbelt, **_):
+ global_test_holder['host_ip'] = toolbelt.host_ip
+
+
+@operation(toolbelt=True)
+def dependent_nodes(toolbelt, **_):
+ global_test_holder['dependent_node_instances'] = list(toolbelt.dependent_node_instances)
+
+
+@operation(toolbelt=True)
+def relationship_operation(ctx, toolbelt, **_):
+ global_test_holder[ctx.name] = toolbelt
+
+
+@pytest.fixture(autouse=True)
+def cleanup():
+ global_test_holder.clear()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/context/test_workflow.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_workflow.py b/tests/orchestrator/context/test_workflow.py
new file mode 100644
index 0000000..19eb57c
--- /dev/null
+++ b/tests/orchestrator/context/test_workflow.py
@@ -0,0 +1,63 @@
+# 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 datetime import datetime
+
+import pytest
+
+from aria import application_model_storage
+from aria.orchestrator import context
+
+from tests.mock import models
+from tests.storage import InMemoryModelDriver
+
+
+class TestWorkflowContext(object):
+
+ def test_execution_creation_on_workflow_context_creation(self, storage):
+ self._create_ctx(storage)
+ execution = storage.execution.get(models.EXECUTION_ID)
+ assert execution.id == models.EXECUTION_ID
+ assert execution.deployment_id == models.DEPLOYMENT_ID
+ assert execution.workflow_id == models.WORKFLOW_ID
+ assert execution.blueprint_id == models.BLUEPRINT_ID
+ assert execution.status == storage.execution.model_cls.PENDING
+ assert execution.parameters == {}
+ assert execution.created_at <= datetime.utcnow()
+
+ def test_subsequent_workflow_context_creation_do_not_fail(self, storage):
+ self._create_ctx(storage)
+ self._create_ctx(storage)
+
+ @staticmethod
+ def _create_ctx(storage):
+ return context.workflow.WorkflowContext(
+ name='simple_context',
+ model_storage=storage,
+ resource_storage=None,
+ deployment_id=models.DEPLOYMENT_ID,
+ workflow_id=models.WORKFLOW_ID,
+ execution_id=models.EXECUTION_ID,
+ task_max_attempts=models.TASK_MAX_ATTEMPTS,
+ task_retry_interval=models.TASK_RETRY_INTERVAL
+ )
+
+
+@pytest.fixture(scope='function')
+def storage():
+ result = application_model_storage(InMemoryModelDriver())
+ result.setup()
+ result.deployment.store(models.get_deployment())
+ return result
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/events/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/events/__init__.py b/tests/orchestrator/events/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/orchestrator/events/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/events/test_builtin_event_handlers.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/events/test_builtin_event_handlers.py b/tests/orchestrator/events/test_builtin_event_handlers.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/orchestrator/events/test_builtin_event_handlers.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/events/test_workflow_enginge_event_handlers.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/events/test_workflow_enginge_event_handlers.py b/tests/orchestrator/events/test_workflow_enginge_event_handlers.py
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/workflows/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/__init__.py b/tests/orchestrator/workflows/__init__.py
new file mode 100644
index 0000000..fe04b2f
--- /dev/null
+++ b/tests/orchestrator/workflows/__init__.py
@@ -0,0 +1,16 @@
+# 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 . import api, builtin, core
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/workflows/api/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/api/__init__.py b/tests/orchestrator/workflows/api/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/orchestrator/workflows/api/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7f0be027/tests/orchestrator/workflows/api/test_task.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/api/test_task.py b/tests/orchestrator/workflows/api/test_task.py
new file mode 100644
index 0000000..8536902
--- /dev/null
+++ b/tests/orchestrator/workflows/api/test_task.py
@@ -0,0 +1,150 @@
+# 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.
+
+
+import pytest
+
+from aria.orchestrator import context
+from aria.orchestrator.workflows import api
+
+from tests import mock
+
+
+@pytest.fixture()
+def ctx():
+ """
+ Create the following graph in storage:
+ dependency_node <------ dependent_node
+ :return:
+ """
+ simple_context = mock.context.simple()
+ dependency_node = mock.models.get_dependency_node()
+ dependency_node_instance = mock.models.get_dependency_node_instance(
+ dependency_node=dependency_node)
+
+ relationship = mock.models.get_relationship(dependency_node)
+ relationship_instance = mock.models.get_relationship_instance(
+ relationship=relationship,
+ target_instance=dependency_node_instance
+ )
+
+ dependent_node = mock.models.get_dependent_node(relationship)
+ dependent_node_instance = mock.models.get_dependent_node_instance(
+ dependent_node=dependent_node,
+ relationship_instance=relationship_instance
+ )
+
+ simple_context.model.node.store(dependent_node)
+ simple_context.model.node.store(dependency_node)
+ simple_context.model.node_instance.store(dependent_node_instance)
+ simple_context.model.node_instance.store(dependency_node_instance)
+ simple_context.model.relationship.store(relationship)
+ simple_context.model.relationship_instance.store(relationship_instance)
+ simple_context.model.execution.store(mock.models.get_execution())
+ simple_context.model.deployment.store(mock.models.get_deployment())
+
+ return simple_context
+
+
+class TestOperationTask(object):
+
+ def test_node_operation_task_creation(self):
+ workflow_context = mock.context.simple()
+
+ operation_name = 'aria.interfaces.lifecycle.create'
+ op_details = {'operation': True}
+ node = mock.models.get_dependency_node()
+ node.operations[operation_name] = op_details
+ node_instance = mock.models.get_dependency_node_instance(dependency_node=node)
+ inputs = {'inputs': True}
+ max_attempts = 10
+ retry_interval = 10
+ ignore_failure = True
+
+ with context.workflow.current.push(workflow_context):
+ api_task = api.task.OperationTask.node_instance(
+ name=operation_name,
+ instance=node_instance,
+ inputs=inputs,
+ max_attempts=max_attempts,
+ retry_interval=retry_interval,
+ ignore_failure=ignore_failure)
+
+ assert api_task.name == '{0}.{1}'.format(operation_name, node_instance.id)
+ assert api_task.operation_mapping is True
+ assert api_task.actor == node_instance
+ assert api_task.inputs == inputs
+ assert api_task.retry_interval == retry_interval
+ assert api_task.max_attempts == max_attempts
+ assert api_task.ignore_failure == ignore_failure
+
+ def test_relationship_operation_task_creation(self):
+ workflow_context = mock.context.simple()
+
+ operation_name = 'aria.interfaces.relationship_lifecycle.preconfigure'
+ op_details = {'operation': True}
+ relationship = mock.models.get_relationship()
+ relationship.source_operations[operation_name] = op_details
+ relationship_instance = mock.models.get_relationship_instance(relationship=relationship)
+ inputs = {'inputs': True}
+ max_attempts = 10
+ retry_interval = 10
+
+ with context.workflow.current.push(workflow_context):
+ api_task = api.task.OperationTask.relationship_instance(
+ name=operation_name,
+ instance=relationship_instance,
+ operation_end=api.task.OperationTask.SOURCE_OPERATION,
+ inputs=inputs,
+ max_attempts=max_attempts,
+ retry_interval=retry_interval)
+
+ assert api_task.name == '{0}.{1}'.format(operation_name, relationship_instance.id)
+ assert api_task.operation_mapping is True
+ assert api_task.actor == relationship_instance
+ assert api_task.inputs == inputs
+ assert api_task.retry_interval == retry_interval
+ assert api_task.max_attempts == max_attempts
+
+ def test_operation_task_default_values(self):
+ workflow_context = mock.context.simple(task_ignore_failure=True)
+ with context.workflow.current.push(workflow_context):
+ model_task = api.task.OperationTask(
+ name='stub',
+ operation_mapping='',
+ actor=mock.models.get_dependency_node_instance())
+
+ assert model_task.inputs == {}
+ assert model_task.retry_interval == workflow_context._task_retry_interval
+ assert model_task.max_attempts == workflow_context._task_max_attempts
+ assert model_task.ignore_failure == workflow_context._task_ignore_failure
+
+
+class TestWorkflowTask(object):
+
+ def test_workflow_task_creation(self, ctx):
+
+ workspace = {}
+
+ mock_class = type('mock_class', (object,), {'test_attribute': True})
+
+ def sub_workflow(**kwargs):
+ workspace.update(kwargs)
+ return mock_class
+
+ with context.workflow.current.push(ctx):
+ workflow_task = api.task.WorkflowTask(sub_workflow, kwarg='workflow_kwarg')
+ assert workflow_task.graph is mock_class
+ assert workflow_task.test_attribute is True