Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-92-plugin-in-implementation-string fb804058c -> 3bb7e4ca0 (forced update)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/tests/modeling/test_models.py ---------------------------------------------------------------------- diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py index 8cd00f8..7599402 100644 --- a/tests/modeling/test_models.py +++ b/tests/modeling/test_models.py @@ -585,48 +585,49 @@ class TestNode(object): node_template_storage.service.list()[0] -class TestNodeIP(object): +class TestNodeHostAddress(object): - ip = '1.1.1.1' + host_address = '1.1.1.1' - def test_ip_on_none_hosted_node(self, service_storage): - node_template = self._node_template(service_storage, ip='not considered') + def test_host_address_on_none_hosted_node(self, service_storage): + node_template = self._node_template(service_storage, host_address='not considered') node = self._node(service_storage, node_template, is_host=False, - ip='not considered') - assert node.ip is None + host_address='not considered') + assert node.host_address is None - def test_property_ip_on_host_node(self, service_storage): - node_template = self._node_template(service_storage, ip=self.ip) - node = self._node(service_storage, node_template, is_host=True, ip=None) - assert node.ip == self.ip + def test_property_host_address_on_host_node(self, service_storage): + node_template = self._node_template(service_storage, host_address=self.host_address) + node = self._node(service_storage, node_template, is_host=True, host_address=None) + assert node.host_address == self.host_address - def test_runtime_property_ip_on_host_node(self, service_storage): - node_template = self._node_template(service_storage, ip='not considered') - node = self._node(service_storage, node_template, is_host=True, ip=self.ip) - assert node.ip == self.ip + def test_runtime_property_host_address_on_host_node(self, service_storage): + node_template = self._node_template(service_storage, host_address='not considered') + node = self._node(service_storage, node_template, is_host=True, + host_address=self.host_address) + assert node.host_address == self.host_address - def test_no_ip_configured_on_host_node(self, service_storage): - node_template = self._node_template(service_storage, ip=None) - node = self._node(service_storage, node_template, is_host=True, ip=None) - assert node.ip is None + def test_no_host_address_configured_on_host_node(self, service_storage): + node_template = self._node_template(service_storage, host_address=None) + node = self._node(service_storage, node_template, is_host=True, host_address=None) + assert node.host_address is None def test_runtime_property_on_hosted_node(self, service_storage): - host_node_template = self._node_template(service_storage, ip=None) + host_node_template = self._node_template(service_storage, host_address=None) host_node = self._node(service_storage, host_node_template, is_host=True, - ip=self.ip) - node_template = self._node_template(service_storage, ip=None) + host_address=self.host_address) + node_template = self._node_template(service_storage, host_address=None) node = self._node(service_storage, node_template, is_host=False, - ip=None, + host_address=None, host_fk=host_node.id) - assert node.ip == self.ip + assert node.host_address == self.host_address - def _node_template(self, storage, ip): + def _node_template(self, storage, host_address): kwargs = dict( name='node_template', type=storage.type.list()[0], @@ -635,23 +636,27 @@ class TestNodeIP(object): min_instances=1, service_template=storage.service_template.list()[0] ) - if ip: - kwargs['properties'] = {'ip': Parameter.wrap('ip', ip)} + if host_address: + kwargs['properties'] = {'host_address': Parameter.wrap('host_address', host_address)} node = NodeTemplate(**kwargs) storage.node_template.put(node) return node - def _node(self, storage, node, is_host, ip, host_fk=None): + def _node(self, storage, node_template, is_host, host_address, host_fk=None): kwargs = dict( name='node', - node_template=node, + node_template=node_template, type=storage.type.list()[0], runtime_properties={}, state='initial', service=storage.service.list()[0] ) - if ip: - kwargs['runtime_properties']['ip'] = ip + if is_host and (host_address is None): + host_address = node_template.properties.get('host_address') + if host_address is not None: + host_address = host_address.value + if host_address: + kwargs['runtime_properties']['host_address'] = host_address if is_host: kwargs['host_fk'] = 1 elif host_fk: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/tests/orchestrator/context/test_operation.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py index f55b83e..af8b454 100644 --- a/tests/orchestrator/context/test_operation.py +++ b/tests/orchestrator/context/test_operation.py @@ -230,7 +230,6 @@ def test_plugin_workdir(ctx, thread_executor, tmpdir): plugin = mock.models.create_plugin() ctx.model.plugin.put(plugin) - plugin_specification = mock.models.create_plugin_specification() node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface = mock.models.create_interface( node.service, @@ -238,7 +237,7 @@ def test_plugin_workdir(ctx, thread_executor, tmpdir): operation_name, operation_kwargs=dict( implementation='{0}.{1}'.format(__name__, _test_plugin_workdir.__name__), - plugin_specification=plugin_specification) + plugin=plugin) ) node.interfaces[interface.name] = interface ctx.model.node.update(node) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/tests/orchestrator/context/test_serialize.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_serialize.py b/tests/orchestrator/context/test_serialize.py index db45e8e..8b809b3 100644 --- a/tests/orchestrator/context/test_serialize.py +++ b/tests/orchestrator/context/test_serialize.py @@ -45,13 +45,12 @@ def _mock_workflow(ctx, graph): node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) plugin = mock.models.create_plugin() ctx.model.plugin.put(plugin) - plugin_specification = mock.models.create_plugin_specification() interface = mock.models.create_interface( node.service, 'test', 'op', operation_kwargs=dict(implementation=_operation_mapping(), - plugin_specification=plugin_specification) + plugin=plugin) ) node.interfaces[interface.name] = interface task = api.task.OperationTask.for_node(node=node, interface_name='test', operation_name='op') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/tests/orchestrator/execution_plugin/test_ssh.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/execution_plugin/test_ssh.py b/tests/orchestrator/execution_plugin/test_ssh.py index dd36466..d86b6d2 100644 --- a/tests/orchestrator/execution_plugin/test_ssh.py +++ b/tests/orchestrator/execution_plugin/test_ssh.py @@ -292,12 +292,13 @@ class TestFabricEnvHideGroupsAndRunCommands(object): assert self.mock.settings_merged['timeout'] == timeout def test_implicit_host_string(self, mocker): - expected_ip = '1.1.1.1' - mocker.patch.object(self._Ctx.task.runs_on, 'ip', expected_ip) + expected_host_address = '1.1.1.1' + mocker.patch.object(self._Ctx.task.actor, 'host') + mocker.patch.object(self._Ctx.task.actor.host, 'host_address', expected_host_address) fabric_env = self.default_fabric_env.copy() del fabric_env['host_string'] self._run(fabric_env=fabric_env) - assert self.mock.settings_merged['host_string'] == expected_ip + assert self.mock.settings_merged['host_string'] == expected_host_address def test_explicit_host_string(self): fabric_env = self.default_fabric_env.copy() @@ -409,13 +410,15 @@ class TestFabricEnvHideGroupsAndRunCommands(object): raise RuntimeError class _Ctx(object): - class Stub(object): + class Task(object): @staticmethod def abort(message=None): models.Task.abort(message) - ip = None - task = Stub - task.runs_on = Stub + actor = None + class Actor(object): + host = None + task = Task + task.actor = Actor logger = logging.getLogger() @staticmethod http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/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 index 80d2351..a705199 100644 --- a/tests/orchestrator/workflows/api/test_task.py +++ b/tests/orchestrator/workflows/api/test_task.py @@ -18,7 +18,6 @@ import pytest from aria.orchestrator import context from aria.orchestrator.workflows import api -from aria.modeling import models from tests import mock, storage @@ -45,13 +44,11 @@ class TestOperationTask(object): plugin = mock.models.create_plugin('test_plugin', '0.1') ctx.model.node.update(plugin) - plugin_specification = mock.models.create_plugin_specification('test_plugin', '0.1') - interface = mock.models.create_interface( ctx.service, interface_name, operation_name, - operation_kwargs=dict(plugin_specification=plugin_specification, + operation_kwargs=dict(plugin=plugin, implementation='op_path')) node = ctx.model.node.get_by_name(mock.models.DEPENDENT_NODE_NAME) @@ -85,7 +82,6 @@ class TestOperationTask(object): assert api_task.max_attempts == max_attempts assert api_task.ignore_failure == ignore_failure assert api_task.plugin.name == 'test_plugin' - assert api_task.runs_on == models.Task.RUNS_ON_NODE def test_source_relationship_operation_task_creation(self, ctx): interface_name = 'test_interface' @@ -94,13 +90,11 @@ class TestOperationTask(object): plugin = mock.models.create_plugin('test_plugin', '0.1') ctx.model.plugin.update(plugin) - plugin_specification = mock.models.create_plugin_specification('test_plugin', '0.1') - interface = mock.models.create_interface( ctx.service, interface_name, operation_name, - operation_kwargs=dict(plugin_specification=plugin_specification, + operation_kwargs=dict(plugin=plugin, implementation='op_path') ) @@ -131,7 +125,6 @@ class TestOperationTask(object): assert api_task.retry_interval == retry_interval assert api_task.max_attempts == max_attempts assert api_task.plugin.name == 'test_plugin' - assert api_task.runs_on == models.Task.RUNS_ON_SOURCE def test_target_relationship_operation_task_creation(self, ctx): interface_name = 'test_interface' @@ -140,13 +133,11 @@ class TestOperationTask(object): plugin = mock.models.create_plugin('test_plugin', '0.1') ctx.model.node.update(plugin) - plugin_specification = mock.models.create_plugin_specification('test_plugin', '0.1') - interface = mock.models.create_interface( ctx.service, interface_name, operation_name, - operation_kwargs=dict(plugin_specification=plugin_specification, + operation_kwargs=dict(plugin=plugin, implementation='op_path') ) @@ -163,8 +154,7 @@ class TestOperationTask(object): operation_name=operation_name, inputs=inputs, max_attempts=max_attempts, - retry_interval=retry_interval, - runs_on=models.Task.RUNS_ON_TARGET) + retry_interval=retry_interval) assert api_task.name == api.task.OperationTask.NAME_FORMAT.format( type='relationship', @@ -178,7 +168,6 @@ class TestOperationTask(object): assert api_task.retry_interval == retry_interval assert api_task.max_attempts == max_attempts assert api_task.plugin.name == 'test_plugin' - assert api_task.runs_on == models.Task.RUNS_ON_TARGET def test_operation_task_default_values(self, ctx): interface_name = 'test_interface' @@ -187,15 +176,13 @@ class TestOperationTask(object): plugin = mock.models.create_plugin('package', '0.1') ctx.model.node.update(plugin) - plugin_specification = mock.models.create_plugin_specification('package', '0.1') - dependency_node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) interface = mock.models.create_interface( ctx.service, interface_name, operation_name, - operation_kwargs=dict(plugin_specification=plugin_specification, + operation_kwargs=dict(plugin=plugin, implementation='op_path')) dependency_node.interfaces[interface_name] = interface @@ -210,7 +197,6 @@ class TestOperationTask(object): assert task.max_attempts == ctx._task_max_attempts assert task.ignore_failure == ctx._task_ignore_failure assert task.plugin is plugin - assert task.runs_on == models.Task.RUNS_ON_NODE class TestWorkflowTask(object): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/tests/orchestrator/workflows/builtin/__init__.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/workflows/builtin/__init__.py b/tests/orchestrator/workflows/builtin/__init__.py index 8a67247..1809f82 100644 --- a/tests/orchestrator/workflows/builtin/__init__.py +++ b/tests/orchestrator/workflows/builtin/__init__.py @@ -31,16 +31,13 @@ def _assert_relationships(operations, expected_op_full_name, relationships=0): # suffix once operation = next(operations) relationship_id_1 = operation.actor.id - edge1 = operation.runs_on _assert_cfg_interface_op(operation, expected_op_name) operation = next(operations) relationship_id_2 = operation.actor.id - edge2 = operation.runs_on _assert_cfg_interface_op(operation, expected_op_name) assert relationship_id_1 == relationship_id_2 - assert edge1 != edge2 def assert_node_install_operations(operations, relationships=0): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/tests/orchestrator/workflows/builtin/test_execute_operation.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/workflows/builtin/test_execute_operation.py b/tests/orchestrator/workflows/builtin/test_execute_operation.py index 360e17d..4cddbe6 100644 --- a/tests/orchestrator/workflows/builtin/test_execute_operation.py +++ b/tests/orchestrator/workflows/builtin/test_execute_operation.py @@ -34,7 +34,8 @@ def test_execute_operation(ctx): interface = mock.models.create_interface( ctx.service, interface_name, - operation_name + operation_name, + operation_kwargs={'implementation': 'test'} ) node.interfaces[interface.name] = interface ctx.model.node.update(node) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/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 18ca056..8dda209 100644 --- a/tests/orchestrator/workflows/core/test_task.py +++ b/tests/orchestrator/workflows/core/test_task.py @@ -19,7 +19,6 @@ from datetime import ( import pytest -from aria.modeling import models from aria.orchestrator.context import workflow as workflow_context from aria.orchestrator.workflows import ( api, @@ -43,7 +42,8 @@ def ctx(tmpdir): interface = mock.models.create_interface( relationship.source_node.service, RELATIONSHIP_INTERFACE_NAME, - RELATIONSHIP_OPERATION_NAME + RELATIONSHIP_OPERATION_NAME, + operation_kwargs={'implementation': 'test'} ) relationship.interfaces[interface.name] = interface context.model.relationship.update(relationship) @@ -52,7 +52,8 @@ def ctx(tmpdir): interface = mock.models.create_interface( node.service, NODE_INTERFACE_NAME, - NODE_OPERATION_NAME + NODE_OPERATION_NAME, + operation_kwargs={'implementation': 'test'} ) node.interfaces[interface.name] = interface context.model.node.update(node) @@ -72,13 +73,12 @@ class TestOperationTask(object): core_task = core.task.OperationTask(api_task=api_task) return api_task, core_task - def _create_relationship_operation_task(self, ctx, relationship, runs_on): + def _create_relationship_operation_task(self, ctx, relationship): with workflow_context.current.push(ctx): api_task = api.task.OperationTask.for_relationship( relationship=relationship, interface_name=RELATIONSHIP_INTERFACE_NAME, - operation_name=RELATIONSHIP_OPERATION_NAME, - runs_on=runs_on) + operation_name=RELATIONSHIP_OPERATION_NAME) core_task = core.task.OperationTask(api_task=api_task) return api_task, core_task @@ -88,12 +88,11 @@ class TestOperationTask(object): ctx.model.plugin.put(storage_plugin) ctx.model.plugin.put(storage_plugin_other) node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) - storage_plugin_specification = mock.models.create_plugin_specification('p1', '0.1') interface = mock.models.create_interface( node.service, NODE_INTERFACE_NAME, NODE_OPERATION_NAME, - operation_kwargs=dict(plugin_specification=storage_plugin_specification) + operation_kwargs=dict(plugin=storage_plugin, implementation='test') ) node.interfaces[interface.name] = interface ctx.model.node.update(node) @@ -101,7 +100,7 @@ class TestOperationTask(object): storage_task = ctx.model.task.get_by_name(core_task.name) assert storage_task.plugin is storage_plugin assert storage_task.execution_name == ctx.execution.name - assert storage_task.runs_on == core_task.context.node + assert storage_task.actor == core_task.context.node assert core_task.model_task == storage_task assert core_task.name == api_task.name assert core_task.implementation == api_task.implementation @@ -109,18 +108,12 @@ class TestOperationTask(object): assert core_task.inputs == api_task.inputs == storage_task.inputs assert core_task.plugin == storage_plugin - def test_source_relationship_operation_task_creation(self, ctx): + def test_relationship_operation_task_creation(self, ctx): relationship = ctx.model.relationship.list()[0] ctx.model.relationship.update(relationship) _, core_task = self._create_relationship_operation_task( - ctx, relationship, models.Task.RUNS_ON_SOURCE) - assert core_task.model_task.runs_on == relationship.source_node - - def test_target_relationship_operation_task_creation(self, ctx): - relationship = ctx.model.relationship.list()[0] - _, core_task = self._create_relationship_operation_task( - ctx, relationship, models.Task.RUNS_ON_TARGET) - assert core_task.model_task.runs_on == relationship.target_node + ctx, relationship) + assert core_task.model_task.actor == relationship def test_operation_task_edit_locked_attribute(self, ctx): node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/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 0a95d43..514bce9 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 @@ -30,7 +30,8 @@ def test_task_graph_into_execution_graph(tmpdir): interface = mock.models.create_interface( node.service, interface_name, - operation_name + operation_name, + operation_kwargs={'implementation': 'test'} ) node.interfaces[interface.name] = interface task_context.model.node.update(node) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/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 d84d1ec..a7619de 100644 --- a/tests/orchestrator/workflows/executor/test_executor.py +++ b/tests/orchestrator/workflows/executor/test_executor.py @@ -119,6 +119,7 @@ class MockTask(object): self.ignore_failure = False self.interface_name = 'interface_name' self.operation_name = 'operation_name' + self.model_task = None for state in models.Task.STATES: setattr(self, state.upper(), state) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/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 436e7b6..502c9fd 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor.py +++ b/tests/orchestrator/workflows/executor/test_process_executor.py @@ -142,6 +142,7 @@ class MockTask(object): self.ignore_failure = False self.interface_name = 'interface_name' self.operation_name = 'operation_name' + self.model_task = None for state in aria_models.Task.STATES: setattr(self, state.upper(), state) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml index 3b4f371..2dcf0ec 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml @@ -98,8 +98,8 @@ topology_template: #token: { get_property: [ HOST, flavor_name ] } interfaces: Maintenance: - enable: juju > charm.maintenance_on - disable: juju > charm.maintenance_off + enable: juju \> charm.maintenance_on + disable: juju \> charm.maintenance_off requirements: - database: node_cellar_database capabilities: @@ -154,14 +154,33 @@ topology_template: - scalable: properties: - max_instances: { greater_or_equal: 8 } - + relationship: + interfaces: + Configure: + target_changed: + implementation: + primary: changed.sh + dependencies: + #- { concat: [ process.args.1 >, mongodb ] } + - process.args.1 > mongodb + - process.args.2 > host + - ssh.user > admin + - ssh.password > 1234 + - ssh.use_sudo > true + + nginx: + type: nginx.Nginx + requirements: + - host: loadbalancer_host + - feature: loadbalancer + + # Features + loadbalancer: type: nginx.LoadBalancer properties: - algorithm: round-robin - requirements: - - host: loadbalancer_host - + algorithm: round-robin + # Hosts loadbalancer_host: @@ -177,7 +196,11 @@ topology_template: Standard: inputs: openstack_credential: { get_input: openstack_credential } - configure: juju > charm.loadbalancer + configure: + implementation: + primary: juju \> run_charm + dependencies: + - charm > loadbalancer application_host: copy: loadbalancer_host http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bb7e4ca/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml index eab130f..3621360 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml @@ -15,12 +15,15 @@ node_types: + nginx.Nginx: + description: >- + Nginx instance. + derived_from: tosca.nodes.SoftwareComponent + requirements: + - feature: + capability: tosca.capabilities.Node + nginx.LoadBalancer: description: >- - Nginx as a loadbalancer. + Nginx loadbalancer feature. derived_from: tosca.nodes.LoadBalancer - requirements: - - host: - capability: tosca.capabilities.Container - node: tosca.nodes.Compute - relationship: tosca.relationships.HostedOn
