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 2017/01/26 14:35:11 UTC
[6/8] incubator-ariatosca git commit: all tests are passing
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4a4500/tests/orchestrator/workflows/builtin/test_uninstall.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/builtin/test_uninstall.py b/tests/orchestrator/workflows/builtin/test_uninstall.py
deleted file mode 100644
index 126c4cf..0000000
--- a/tests/orchestrator/workflows/builtin/test_uninstall.py
+++ /dev/null
@@ -1,44 +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.orchestrator.workflows.api import task
-from aria.orchestrator.workflows.builtin.uninstall import uninstall
-
-from tests import mock
-from tests import storage
-
-from . import assert_node_uninstall_operations
-
-
-@pytest.fixture
-def ctx(tmpdir):
- context = mock.context.simple(storage.get_sqlite_api_kwargs(str(tmpdir)))
- yield context
- storage.release_sqlite_storage(context.model)
-
-
-def test_uninstall(ctx):
-
- uninstall_tasks = list(task.WorkflowTask(uninstall, ctx=ctx).topological_order(True))
-
- assert len(uninstall_tasks) == 2
- dependent_node_subgraph, dependency_node_subgraph = uninstall_tasks
- dependent_node_tasks = list(dependent_node_subgraph.topological_order(reverse=True))
- dependency_node_tasks = list(dependency_node_subgraph.topological_order(reverse=True))
-
- assert_node_uninstall_operations(operations=dependency_node_tasks)
- assert_node_uninstall_operations(operations=dependent_node_tasks, with_relationships=True)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4a4500/tests/orchestrator/workflows/core/test_engine.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/core/test_engine.py b/tests/orchestrator/workflows/core/test_engine.py
index f56270e..595ed4b 100644
--- a/tests/orchestrator/workflows/core/test_engine.py
+++ b/tests/orchestrator/workflows/core/test_engine.py
@@ -60,11 +60,11 @@ class BaseTest(object):
max_attempts=None,
retry_interval=None,
ignore_failure=None):
- node = \
- ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
+ node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
node.interfaces = [mock.models.get_interface(
'aria.interfaces.lifecycle.create',
- operation_kwargs=dict(implementation='{name}.{func.__name__}'.format(name=__name__, func=func))
+ operation_kwargs=dict(implementation='{name}.{func.__name__}'.format(name=__name__,
+ func=func))
)]
return api.task.OperationTask.node_instance(
instance=node,
@@ -220,8 +220,12 @@ class TestCancel(BaseTest):
@workflow
def mock_workflow(ctx, graph):
- return graph.sequence(*(self._op(mock_sleep_task, ctx, inputs={'seconds': 0.1})
- for _ in range(number_of_tasks)))
+ operations = (
+ self._op(mock_sleep_task, ctx, inputs=dict(seconds=0.1))
+ for _ in range(number_of_tasks)
+ )
+ return graph.sequence(*operations)
+
eng = self._engine(workflow_func=mock_workflow,
workflow_context=workflow_context,
executor=executor)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4a4500/tests/orchestrator/workflows/core/test_task.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/core/test_task.py b/tests/orchestrator/workflows/core/test_task.py
index 5381f5d..cde0e99 100644
--- a/tests/orchestrator/workflows/core/test_task.py
+++ b/tests/orchestrator/workflows/core/test_task.py
@@ -51,28 +51,31 @@ class TestOperationTask(object):
storage_plugin_other = mock.models.get_plugin(package_name='p0', package_version='0.0')
ctx.model.plugin.put(storage_plugin_other)
ctx.model.plugin.put(storage_plugin)
- node_instance = \
- ctx.model.node_instance.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
- node = node_instance.node
- node.plugins = [{'name': 'plugin1',
- 'package_name': 'p1',
- 'package_version': '0.1'}]
- node.operations['aria.interfaces.lifecycle.create'] = {'plugin': 'plugin1'}
- api_task, core_task = self._create_operation_task(ctx, node_instance)
+ node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
+ node_template = node.node_template
+ node_template.plugins = [{'name': 'plugin1',
+ 'package_name': 'p1',
+ 'package_version': '0.1'}]
+ node.interfaces = [mock.models.get_interface('aria.interfaces.lifecycle.create',
+ operation_kwargs=dict(plugin='plugin1'))]
+ ctx.model.node_template.update(node_template)
+ ctx.model.node.update(node)
+ api_task, core_task = self._create_operation_task(ctx, node)
storage_task = ctx.model.task.get_by_name(core_task.name)
assert storage_task.execution_name == ctx.execution.name
assert core_task.model_task == storage_task
assert core_task.name == api_task.name
- assert core_task.operation_mapping == api_task.operation_mapping
- assert core_task.actor == api_task.actor == node_instance
+ assert core_task.implementation == api_task.implementation
+ assert core_task.actor == api_task.actor == node
assert core_task.inputs == api_task.inputs == storage_task.inputs
assert core_task.plugin == storage_plugin
def test_operation_task_edit_locked_attribute(self, ctx):
- node_instance = \
- ctx.model.node_instance.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
+ node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
+ node.interfaces = [mock.models.get_interface('aria.interfaces.lifecycle.create')]
+ ctx.model.node.update(node)
- _, core_task = self._create_operation_task(ctx, node_instance)
+ _, core_task = self._create_operation_task(ctx, node)
now = datetime.utcnow()
with pytest.raises(exceptions.TaskException):
core_task.status = core_task.STARTED
@@ -86,10 +89,11 @@ class TestOperationTask(object):
core_task.due_at = now
def test_operation_task_edit_attributes(self, ctx):
- node_instance = \
- ctx.model.node_instance.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
+ node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
+ node.interfaces = [mock.models.get_interface('aria.interfaces.lifecycle.create')]
+ ctx.model.node.update(node)
- _, core_task = self._create_operation_task(ctx, node_instance)
+ _, core_task = self._create_operation_task(ctx, node)
future_time = datetime.utcnow() + timedelta(seconds=3)
with core_task._update():
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4a4500/tests/orchestrator/workflows/core/test_task_graph_into_exececution_graph.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/core/test_task_graph_into_exececution_graph.py b/tests/orchestrator/workflows/core/test_task_graph_into_exececution_graph.py
index 18540f4..a3e216b 100644
--- a/tests/orchestrator/workflows/core/test_task_graph_into_exececution_graph.py
+++ b/tests/orchestrator/workflows/core/test_task_graph_into_exececution_graph.py
@@ -25,20 +25,22 @@ from tests import storage
def test_task_graph_into_execution_graph():
operation_name = 'aria.interfaces.lifecycle.create'
task_context = mock.context.simple(storage.get_sqlite_api_kwargs())
- node_instance = \
- task_context.model.node_instance.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
+ node = task_context.model.node.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
+ node.interfaces = [mock.models.get_interface(operation_name)]
+ task_context.model.node.update(node)
+
def sub_workflow(name, **_):
return api.task_graph.TaskGraph(name)
with context.workflow.current.push(task_context):
test_task_graph = api.task.WorkflowTask(sub_workflow, name='test_task_graph')
- simple_before_task = api.task.OperationTask.node_instance(instance=node_instance,
+ simple_before_task = api.task.OperationTask.node_instance(instance=node,
name=operation_name)
- simple_after_task = api.task.OperationTask.node_instance(instance=node_instance,
+ simple_after_task = api.task.OperationTask.node_instance(instance=node,
name=operation_name)
inner_task_graph = api.task.WorkflowTask(sub_workflow, name='test_inner_task_graph')
- inner_task = api.task.OperationTask.node_instance(instance=node_instance,
+ inner_task = api.task.OperationTask.node_instance(instance=node,
name=operation_name)
inner_task_graph.add_tasks(inner_task)
@@ -91,7 +93,7 @@ def test_task_graph_into_execution_graph():
def _assert_execution_is_api_task(execution_task, api_task):
assert execution_task.id == api_task.id
assert execution_task.name == api_task.name
- assert execution_task.operation_mapping == api_task.operation_mapping
+ assert execution_task.implementation == api_task.implementation
assert execution_task.actor == api_task.actor
assert execution_task.inputs == api_task.inputs
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4a4500/tests/orchestrator/workflows/executor/test_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_executor.py b/tests/orchestrator/workflows/executor/test_executor.py
index 913d15c..c0c62f5 100644
--- a/tests/orchestrator/workflows/executor/test_executor.py
+++ b/tests/orchestrator/workflows/executor/test_executor.py
@@ -43,9 +43,13 @@ def test_execute(executor):
expected_value = 'value'
successful_task = MockTask(mock_successful_task)
failing_task = MockTask(mock_failing_task)
- task_with_inputs = MockTask(mock_task_with_input, inputs={'input': expected_value})
+ task_with_inputs = MockTask(mock_task_with_input, inputs=dict(input='value'))
- for task in [successful_task, failing_task, task_with_inputs]:
+ for task in [
+ successful_task,
+ failing_task,
+ task_with_inputs
+ ]:
executor.execute(task)
@retrying.retry(stop_max_delay=10000, wait_fixed=100)
@@ -98,8 +102,8 @@ class MockTask(object):
self.exception = None
self.id = str(uuid.uuid4())
name = func.__name__
- operation = 'tests.orchestrator.workflows.executor.test_executor.{name}'.format(name=name)
- self.operation_mapping = operation
+ implementation = 'tests.orchestrator.workflows.executor.test_executor.{name}'.format(name=name)
+ self.implementation = implementation
self.logger = logging.getLogger()
self.name = name
self.inputs = inputs or {}
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4a4500/tests/orchestrator/workflows/executor/test_process_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py
index 0b0dc2c..ec01d60 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor.py
@@ -38,7 +38,7 @@ class TestProcessExecutor(object):
def test_plugin_execution(self, executor, mock_plugin):
task = MockTask(plugin=mock_plugin,
- operation='mock_plugin1.operation')
+ implementation='mock_plugin1.operation')
queue = Queue.Queue()
@@ -119,11 +119,11 @@ class MockTask(object):
INFINITE_RETRIES = aria_model.Task.INFINITE_RETRIES
- def __init__(self, plugin, operation):
+ def __init__(self, plugin, implementation):
self.id = str(uuid.uuid4())
- self.operation_mapping = operation
+ self.implementation = implementation
self.logger = logging.getLogger()
- self.name = operation
+ self.name = implementation
self.inputs = {}
self.context = MockContext()
self.retry_count = 0
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4a4500/tests/storage/test_resource_storage.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_resource_storage.py b/tests/storage/test_resource_storage.py
index 6913549..9b5f782 100644
--- a/tests/storage/test_resource_storage.py
+++ b/tests/storage/test_resource_storage.py
@@ -34,14 +34,14 @@ class TestResourceStorage(TestFileSystem):
with open(tmp_path, 'w') as f:
f.write('fake context')
- storage.service_template.upload(entry_id=id, source=tmp_path)
+ storage.blueprint.upload(entry_id=id, source=tmp_path)
def _upload_dir(self, storage, tmp_dir, tmp_file_name, id):
file_source = os.path.join(tmp_dir, tmp_file_name)
with open(file_source, 'w') as f:
f.write('fake context')
- storage.service_template.upload(entry_id=id, source=tmp_dir)
+ storage.blueprint.upload(entry_id=id, source=tmp_dir)
def _create_storage(self):
return ResourceStorage(FileSystemResourceAPI,