ARIA-154 Create end-to-end test for the Nodecellar example
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8dc7b006 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8dc7b006 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8dc7b006 Branch: refs/heads/ARIA-146-Support-colorful-execution-logging Commit: 8dc7b0060bedf25c5b135b9b014c3a1f87d6aaf2 Parents: d91696b Author: Ran Ziv <r...@gigaspaces.com> Authored: Thu Apr 27 15:11:15 2017 +0300 Committer: Ran Ziv <r...@gigaspaces.com> Committed: Thu Apr 27 15:11:15 2017 +0300 ---------------------------------------------------------------------- tests/end2end/test_nodecellar.py | 42 ++++++++++++++++++++ .../tosca-simple-1.0/node-cellar/workflows.py | 5 +-- 2 files changed, 44 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8dc7b006/tests/end2end/test_nodecellar.py ---------------------------------------------------------------------- diff --git a/tests/end2end/test_nodecellar.py b/tests/end2end/test_nodecellar.py new file mode 100644 index 0000000..25ce7a0 --- /dev/null +++ b/tests/end2end/test_nodecellar.py @@ -0,0 +1,42 @@ +# 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 .testenv import testenv # pylint: disable=unused-import +from .. import helpers + + +def test_nodecellar(testenv): + nodecellar_template_uri = helpers.get_service_template_uri( + 'tosca-simple-1.0', 'node-cellar', 'node-cellar.yaml') + + service_name = testenv.install_service(nodecellar_template_uri, dry=True) + _verify_deployed_service_in_storage(service_name, testenv.model_storage) + + # testing dry execution of custom workflows + testenv.execute_workflow(service_name, 'maintenance_on', dry=True) + testenv.execute_workflow(service_name, 'maintenance_off', dry=True) + + testenv.uninstall_service(dry=True) + testenv.verify_clean_storage() + + +def _verify_deployed_service_in_storage(service_name, model_storage): + service_templates = model_storage.service_template.list() + assert len(service_templates) == 1 + assert len(service_templates[0].services) == 1 + service = service_templates[0].services[0] + assert service.name == service_name + assert len(service.executions) == 0 # dry executions leave no traces + assert len(service.nodes) == 10 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8dc7b006/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py index 94ee824..abe1ee2 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py @@ -1,6 +1,5 @@ - from aria import workflow -from aria.orchestrator.workflows.api.task import OperationTask +from aria.orchestrator.workflows.builtin import utils from aria.orchestrator.workflows.exceptions import TaskException @@ -17,7 +16,7 @@ def maintenance(ctx, graph, enabled): for node in ctx.model.node.iter(): try: - graph.add_tasks(OperationTask.for_node(node=node, + graph.add_tasks(utils.create_node_task(node=node, interface_name=INTERFACE_NAME, operation_name=ENABLE_OPERATION_NAME if enabled else DISABLE_OPERATION_NAME))