You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by ra...@apache.org on 2017/04/06 08:29:57 UTC
[31/32] incubator-ariatosca git commit: fixed and refactored tests
fixed and refactored tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/61a2b03c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/61a2b03c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/61a2b03c
Branch: refs/heads/ARIA-48-aria-cli
Commit: 61a2b03ce8b1a939cbd8d866b2a0a15e14c44900
Parents: 4534ec4
Author: Ran Ziv <ra...@gigaspaces.com>
Authored: Thu Apr 6 00:18:54 2017 +0300
Committer: Ran Ziv <ra...@gigaspaces.com>
Committed: Thu Apr 6 11:29:17 2017 +0300
----------------------------------------------------------------------
aria/modeling/utils.py | 5 +-
aria/parser/consumption/modeling.py | 2 +-
aria/utils/application.py | 294 -------------------
.../use-cases/block-storage-1/inputs.yaml | 3 +
.../use-cases/block-storage-2/inputs.yaml | 3 +
.../use-cases/block-storage-3/inputs.yaml | 2 +
.../use-cases/block-storage-4/inputs.yaml | 2 +
.../use-cases/block-storage-5/inputs.yaml | 3 +
.../use-cases/block-storage-6/inputs.yaml | 3 +
.../use-cases/compute-1/inputs.yaml | 1 +
.../use-cases/multi-tier-1/inputs.yaml | 1 +
.../use-cases/network-1/inputs.yaml | 1 +
.../use-cases/network-2/inputs.yaml | 1 +
.../use-cases/network-3/inputs.yaml | 1 +
.../use-cases/object-storage-1/inputs.yaml | 1 +
.../use-cases/software-component-1/inputs.yaml | 1 +
tests/end2end/test_orchestrator.py | 63 ----
tests/end2end/test_tosca_simple_v1_0.py | 112 -------
tests/orchestrator/context/test_serialize.py | 7 -
.../workflows/executor/test_process_executor.py | 30 +-
.../test_process_executor_tracked_changes.py | 6 +-
tests/parser/service_templates.py | 6 +-
tests/parser/test_tosca_simple_v1_0.py | 112 +++++++
tests/utils/test_plugin.py | 29 +-
24 files changed, 155 insertions(+), 534 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/aria/modeling/utils.py
----------------------------------------------------------------------
diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py
index f172a50..35ce991 100644
--- a/aria/modeling/utils.py
+++ b/aria/modeling/utils.py
@@ -78,7 +78,10 @@ def _merge_and_validate_inputs(inputs, template_inputs):
else:
# Validate input type
try:
- validate_value_type(inputs[input_name], input_template.type_name)
+ # TODO: improve type validation; Needs to consider custom data_types as well
+ if input_template.type_name in ('list', 'dict', 'tuple', 'string', 'integer',
+ 'boolean', 'float'):
+ validate_value_type(inputs[input_name], input_template.type_name)
except ValueError:
wrong_type_inputs[input_name] = input_template.type_name
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/aria/parser/consumption/modeling.py
----------------------------------------------------------------------
diff --git a/aria/parser/consumption/modeling.py b/aria/parser/consumption/modeling.py
index 4847ba7..d4f8fd0 100644
--- a/aria/parser/consumption/modeling.py
+++ b/aria/parser/consumption/modeling.py
@@ -106,7 +106,7 @@ class InstantiateServiceInstance(Consumer):
'model')
return
- self.context.modeling.template.instantiate(None)
+ self.context.modeling.template.instantiate(None, dict(self.context.modeling.inputs))
class CoerceServiceInstanceValues(Consumer):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/aria/utils/application.py
----------------------------------------------------------------------
diff --git a/aria/utils/application.py b/aria/utils/application.py
deleted file mode 100644
index 2f40825..0000000
--- a/aria/utils/application.py
+++ /dev/null
@@ -1,294 +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.
-
-"""
-Convenience storage related tools.
-# TODO rename module name
-"""
-
-import json
-import os
-import shutil
-import tarfile
-import tempfile
-from datetime import datetime
-
-from aria.storage.exceptions import StorageError
-from aria.logger import LoggerMixin
-
-
-class StorageManager(LoggerMixin):
- """
- Convenience wrapper to simplify work with the lower level storage mechanism
- """
-
- def __init__(
- self,
- model_storage,
- resource_storage,
- blueprint_path,
- blueprint_id,
- blueprint_plan,
- deployment_id,
- deployment_plan,
- **kwargs):
- super(StorageManager, self).__init__(**kwargs)
- self.model_storage = model_storage
- self.resource_storage = resource_storage
- self.blueprint_path = blueprint_path
- self.blueprint_id = blueprint_id
- self.blueprint_plan = blueprint_plan
- self.deployment_id = deployment_id
- self.deployment_plan = deployment_plan
-
- @classmethod
- def from_deployment(
- cls,
- model_storage,
- resource_storage,
- deployment_id,
- deployment_plan):
- """
- Create a StorageManager from a deployment
- """
- return cls(
- model_storage=model_storage,
- resource_storage=resource_storage,
- deployment_id=deployment_id,
- deployment_plan=deployment_plan,
- blueprint_path=None,
- blueprint_plan=None,
- blueprint_id=None
- )
-
- @classmethod
- def from_blueprint(
- cls,
- model_storage,
- resource_storage,
- blueprint_path,
- blueprint_id,
- blueprint_plan):
- """
- Create a StorageManager from a blueprint
- """
- return cls(
- model_storage=model_storage,
- resource_storage=resource_storage,
- blueprint_path=blueprint_path,
- blueprint_plan=blueprint_plan,
- blueprint_id=blueprint_id,
- deployment_id=None,
- deployment_plan=None)
-
- def create_blueprint_storage(self, source, main_file_name=None):
- """
- create blueprint model & resource
- """
- assert self.blueprint_path and self.blueprint_id
- assert hasattr(self.resource_storage, 'blueprint')
- assert hasattr(self.model_storage, 'blueprint')
-
- self.logger.debug('creating blueprint resource storage entry')
- self.resource_storage.service_template.upload(
- entry_id=self.blueprint_id,
- source=os.path.dirname(source))
- self.logger.debug('created blueprint resource storage entry')
-
- self.logger.debug('creating blueprint model storage entry')
- now = datetime.utcnow()
- blueprint = self.model_storage.service_template.model_cls(
- plan=self.blueprint_plan,
- id=self.blueprint_id,
- description=self.blueprint_plan.get('description'),
- created_at=now,
- updated_at=now,
- main_file_name=main_file_name,
- )
- self.model_storage.service_template.put(blueprint)
- self.logger.debug('created blueprint model storage entry')
-
- def create_nodes_storage(self):
- """
- create nodes model
- """
- assert self.blueprint_path and self.blueprint_id
- assert hasattr(self.model_storage, 'node')
- assert hasattr(self.model_storage, 'relationship')
-
- for node in self.blueprint_plan['nodes']:
- node_copy = node.copy()
- for field in ('name',
- 'deployment_plugins_to_install',
- 'interfaces',
- 'instances'):
- node_copy.pop(field)
- scalable = node_copy.pop('capabilities')['scalable']['properties']
- for index, relationship in enumerate(node_copy['relationships']):
- relationship = self.model_storage.relationship.model_cls(**relationship)
- self.model_storage.relationship.put(relationship)
- node_copy['relationships'][index] = relationship
-
- node_copy = self.model_storage.node.model_cls(
- blueprint_id=self.blueprint_id,
- planned_number_of_instances=scalable['current_instances'],
- deploy_number_of_instances=scalable['default_instances'],
- min_number_of_instances=scalable['min_instances'],
- max_number_of_instances=scalable['max_instances'],
- number_of_instances=scalable['current_instances'],
- **node_copy)
- self.model_storage.node.put(node_copy)
-
- def create_deployment_storage(self):
- """
- create deployment model & resource
- """
- assert self.deployment_id and self.deployment_plan
-
- assert hasattr(self.resource_storage, 'blueprint')
- assert hasattr(self.resource_storage, 'deployment')
- assert hasattr(self.model_storage, 'deployment')
-
- self.logger.debug('creating deployment resource storage entry')
- temp_dir = tempfile.mkdtemp()
- try:
- self.resource_storage.service_template.download(
- entry_id=self.blueprint_id,
- destination=temp_dir)
- self.resource_storage.service_instance.upload(
- entry_id=self.deployment_id,
- source=temp_dir)
- finally:
- shutil.rmtree(temp_dir, ignore_errors=True)
- self.logger.debug('created deployment resource storage entry')
-
- self.logger.debug('creating deployment model storage entry')
- now = datetime.utcnow()
- deployment = self.model_storage.service_instance.model_cls(
- id=self.deployment_id,
- blueprint_id=self.blueprint_id,
- description=self.deployment_plan['description'],
- workflows=self.deployment_plan['workflows'],
- inputs=self.deployment_plan['inputs'],
- policy_types=self.deployment_plan['policy_types'],
- policy_triggers=self.deployment_plan['policy_triggers'],
- groups=self.deployment_plan['groups'],
- scaling_groups=self.deployment_plan['scaling_groups'],
- outputs=self.deployment_plan['outputs'],
- created_at=now,
- updated_at=now
- )
- self.model_storage.service_instance.put(deployment)
- self.logger.debug('created deployment model storage entry')
-
- def create_node_instances_storage(self):
- """
- create node_instances model
- """
- assert self.deployment_id and self.deployment_plan
- assert hasattr(self.model_storage, 'node_instance')
- assert hasattr(self.model_storage, 'relationship_instance')
-
- self.logger.debug('creating node-instances model storage entries')
- for node_instance in self.deployment_plan['node_instances']:
- node_model = self.model_storage.node.get(node_instance['node_id'])
- relationship_instances = []
-
- for index, relationship_instance in enumerate(node_instance['relationships']):
- relationship_instance_model = self.model_storage.relationship.model_cls(
- relationship=node_model.relationships[index],
- target_name=relationship_instance['target_name'],
- type=relationship_instance['type'],
- target_id=relationship_instance['target_id'])
- relationship_instances.append(relationship_instance_model)
- self.model_storage.relationship.put(relationship_instance_model)
-
- node_instance_model = self.model_storage.node.model_cls(
- node=node_model,
- id=node_instance['id'],
- runtime_properties={},
- state=self.model_storage.node.model_cls.UNINITIALIZED,
- deployment_id=self.deployment_id,
- version='1.0',
- relationship_instances=relationship_instances)
-
- self.model_storage.node.put(node_instance_model)
- self.logger.debug('created node-instances model storage entries')
-
- def create_plugin_storage(self, plugin_id, source):
- """
- create plugin model & resource
- """
- assert hasattr(self.model_storage, 'plugin')
- assert hasattr(self.resource_storage, 'plugin')
-
- self.logger.debug('creating plugin resource storage entry')
- self.resource_storage.plugin.upload(entry_id=plugin_id, source=source)
- self.logger.debug('created plugin resource storage entry')
-
- self.logger.debug('creating plugin model storage entry')
- plugin = _load_plugin_from_archive(source)
- build_props = plugin.get('build_server_os_properties')
- now = datetime.utcnow()
-
- plugin = self.model_storage.plugin.model_cls(
- id=plugin_id,
- package_name=plugin.get('package_name'),
- package_version=plugin.get('package_version'),
- archive_name=plugin.get('archive_name'),
- package_source=plugin.get('package_source'),
- supported_platform=plugin.get('supported_platform'),
- distribution=build_props.get('distribution'),
- distribution_version=build_props.get('distribution_version'),
- distribution_release=build_props.get('distribution_release'),
- wheels=plugin.get('wheels'),
- excluded_wheels=plugin.get('excluded_wheels'),
- supported_py_versions=plugin.get('supported_python_versions'),
- uploaded_at=now
- )
- self.model_storage.plugin.put(plugin)
- self.logger.debug('created plugin model storage entry')
-
-
-def _load_plugin_from_archive(tar_source):
- if not tarfile.is_tarfile(tar_source):
- # TODO: go over the exceptions
- raise StorageError(
- 'the provided tar archive can not be read.')
-
- with tarfile.open(tar_source) as tar:
- tar_members = tar.getmembers()
- # a wheel plugin will contain exactly one sub directory
- if not tar_members:
- raise StorageError(
- 'archive file structure malformed. expecting exactly one '
- 'sub directory; got none.')
- package_json_path = os.path.join(tar_members[0].name,
- 'package.json')
- try:
- package_member = tar.getmember(package_json_path)
- except KeyError:
- raise StorageError("'package.json' was not found under {0}"
- .format(package_json_path))
- try:
- package_json = tar.extractfile(package_member)
- except tarfile.ExtractError as e:
- raise StorageError(str(e))
- try:
- return json.load(package_json)
- except ValueError as e:
- raise StorageError("'package.json' is not a valid json: "
- "{json_str}. error is {error}"
- .format(json_str=package_json.read(), error=str(e)))
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/block-storage-1/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/block-storage-1/inputs.yaml b/examples/tosca-simple-1.0/use-cases/block-storage-1/inputs.yaml
new file mode 100644
index 0000000..d0b0854
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/block-storage-1/inputs.yaml
@@ -0,0 +1,3 @@
+storage_snapshot_id: "snapshot-id"
+storage_location: /mnt
+cpus: 4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/block-storage-2/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/block-storage-2/inputs.yaml b/examples/tosca-simple-1.0/use-cases/block-storage-2/inputs.yaml
new file mode 100644
index 0000000..d0b0854
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/block-storage-2/inputs.yaml
@@ -0,0 +1,3 @@
+storage_snapshot_id: "snapshot-id"
+storage_location: /mnt
+cpus: 4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/block-storage-3/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/block-storage-3/inputs.yaml b/examples/tosca-simple-1.0/use-cases/block-storage-3/inputs.yaml
new file mode 100644
index 0000000..daca041
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/block-storage-3/inputs.yaml
@@ -0,0 +1,2 @@
+storage_location: /mnt
+cpus: 4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/block-storage-4/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/block-storage-4/inputs.yaml b/examples/tosca-simple-1.0/use-cases/block-storage-4/inputs.yaml
new file mode 100644
index 0000000..18e457d
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/block-storage-4/inputs.yaml
@@ -0,0 +1,2 @@
+storage_snapshot_id: "snapshot-id"
+cpus: 4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/block-storage-5/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/block-storage-5/inputs.yaml b/examples/tosca-simple-1.0/use-cases/block-storage-5/inputs.yaml
new file mode 100644
index 0000000..d0b0854
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/block-storage-5/inputs.yaml
@@ -0,0 +1,3 @@
+storage_snapshot_id: "snapshot-id"
+storage_location: /mnt
+cpus: 4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/block-storage-6/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/block-storage-6/inputs.yaml b/examples/tosca-simple-1.0/use-cases/block-storage-6/inputs.yaml
new file mode 100644
index 0000000..d0b0854
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/block-storage-6/inputs.yaml
@@ -0,0 +1,3 @@
+storage_snapshot_id: "snapshot-id"
+storage_location: /mnt
+cpus: 4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/compute-1/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/compute-1/inputs.yaml b/examples/tosca-simple-1.0/use-cases/compute-1/inputs.yaml
new file mode 100644
index 0000000..c1ee88a
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/compute-1/inputs.yaml
@@ -0,0 +1 @@
+cpus: 4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/multi-tier-1/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/multi-tier-1/inputs.yaml b/examples/tosca-simple-1.0/use-cases/multi-tier-1/inputs.yaml
new file mode 100644
index 0000000..5302bbf
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/multi-tier-1/inputs.yaml
@@ -0,0 +1 @@
+my_cpus: 8
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/network-1/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/network-1/inputs.yaml b/examples/tosca-simple-1.0/use-cases/network-1/inputs.yaml
new file mode 100644
index 0000000..9687bb0
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/network-1/inputs.yaml
@@ -0,0 +1 @@
+network_name: "network"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/network-2/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/network-2/inputs.yaml b/examples/tosca-simple-1.0/use-cases/network-2/inputs.yaml
new file mode 100644
index 0000000..9687bb0
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/network-2/inputs.yaml
@@ -0,0 +1 @@
+network_name: "network"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/network-3/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/network-3/inputs.yaml b/examples/tosca-simple-1.0/use-cases/network-3/inputs.yaml
new file mode 100644
index 0000000..9687bb0
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/network-3/inputs.yaml
@@ -0,0 +1 @@
+network_name: "network"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/object-storage-1/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/object-storage-1/inputs.yaml b/examples/tosca-simple-1.0/use-cases/object-storage-1/inputs.yaml
new file mode 100644
index 0000000..57f99a3
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/object-storage-1/inputs.yaml
@@ -0,0 +1 @@
+objectstore_name: "objectstore"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/examples/tosca-simple-1.0/use-cases/software-component-1/inputs.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/software-component-1/inputs.yaml b/examples/tosca-simple-1.0/use-cases/software-component-1/inputs.yaml
new file mode 100644
index 0000000..c1ee88a
--- /dev/null
+++ b/examples/tosca-simple-1.0/use-cases/software-component-1/inputs.yaml
@@ -0,0 +1 @@
+cpus: 4
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/tests/end2end/test_orchestrator.py
----------------------------------------------------------------------
diff --git a/tests/end2end/test_orchestrator.py b/tests/end2end/test_orchestrator.py
deleted file mode 100644
index 4dfca44..0000000
--- a/tests/end2end/test_orchestrator.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.
-
-import sys
-import os
-
-from aria.orchestrator.runner import Runner
-from aria.orchestrator.workflows.builtin import BUILTIN_WORKFLOWS
-from aria.utils.imports import import_fullname
-from aria.utils.collections import OrderedDict
-from aria.cli.dry import convert_to_dry
-
-from tests.parser.service_templates import consume_node_cellar
-
-
-WORKFLOW_POLICY_INTERNAL_PROPERTIES = ('implementation', 'dependencies')
-
-
-def test_install():
- _workflow('install')
-
-
-def test_custom():
- _workflow('maintenance_on')
-
-
-def _workflow(workflow_name):
- context, _ = consume_node_cellar()
-
- convert_to_dry(context.modeling.instance)
-
- # TODO: this logic will eventually stabilize and be part of the ARIA API,
- # likely somewhere in aria.orchestrator.workflows
- if workflow_name in BUILTIN_WORKFLOWS:
- workflow_fn = import_fullname('aria.orchestrator.workflows.builtin.' + workflow_name)
- inputs = {}
- else:
- workflow = context.modeling.instance.policies[workflow_name]
- sys.path.append(os.path.dirname(str(context.presentation.location)))
- workflow_fn = import_fullname(workflow.properties['implementation'].value)
- inputs = OrderedDict([
- (k, v.value) for k, v in workflow.properties.iteritems()
- if k not in WORKFLOW_POLICY_INTERNAL_PROPERTIES
- ])
-
- def _initialize_storage(model_storage):
- context.modeling.store(model_storage)
-
- runner = Runner(workflow_name, workflow_fn, inputs, _initialize_storage,
- lambda: context.modeling.instance.id)
- runner.run()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/tests/end2end/test_tosca_simple_v1_0.py
----------------------------------------------------------------------
diff --git a/tests/end2end/test_tosca_simple_v1_0.py b/tests/end2end/test_tosca_simple_v1_0.py
deleted file mode 100644
index 4658fc3..0000000
--- a/tests/end2end/test_tosca_simple_v1_0.py
+++ /dev/null
@@ -1,112 +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 tests.parser.service_templates import (consume_use_case, consume_node_cellar)
-
-
-# Use Cases
-
-def test_use_case_compute_1():
- consume_use_case('compute-1', 'instance')
-
-
-def test_use_case_software_component_1():
- consume_use_case('software-component-1', 'instance')
-
-
-def test_use_case_block_storage_1():
- consume_use_case('block-storage-1', 'instance')
-
-
-def test_use_case_block_storage_2():
- consume_use_case('block-storage-2', 'instance')
-
-
-def test_use_case_block_storage_3():
- consume_use_case('block-storage-3', 'instance')
-
-
-def test_use_case_block_storage_4():
- consume_use_case('block-storage-4', 'instance')
-
-
-def test_use_case_block_storage_5():
- consume_use_case('block-storage-5', 'instance')
-
-
-def test_use_case_block_storage_6():
- consume_use_case('block-storage-6', 'instance')
-
-
-def test_use_case_object_storage_1():
- consume_use_case('object-storage-1', 'instance')
-
-
-def test_use_case_network_1():
- consume_use_case('network-1', 'instance')
-
-
-def test_use_case_network_2():
- consume_use_case('network-2', 'instance')
-
-
-def test_use_case_network_3():
- consume_use_case('network-3', 'instance')
-
-
-def test_use_case_network_4():
- consume_use_case('network-4', 'instance')
-
-
-def test_use_case_webserver_dbms_1():
- consume_use_case('webserver-dbms-1', 'template')
-
-
-def test_use_case_webserver_dbms_2():
- consume_use_case('webserver-dbms-2', 'instance')
-
-
-def test_use_case_multi_tier_1():
- consume_use_case('multi-tier-1', 'instance')
-
-
-def test_use_case_container_1():
- consume_use_case('container-1', 'template')
-
-
-# NodeCellar
-
-def test_node_cellar_validation():
- consume_node_cellar('validate')
-
-
-def test_node_cellar_validation_no_cache():
- consume_node_cellar('validate', False)
-
-
-def test_node_cellar_presentation():
- consume_node_cellar('presentation')
-
-
-def test_node_cellar_model():
- consume_node_cellar('template')
-
-
-def test_node_cellar_types():
- consume_node_cellar('types')
-
-
-def test_node_cellar_instance():
- consume_node_cellar('instance')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/tests/orchestrator/context/test_serialize.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_serialize.py b/tests/orchestrator/context/test_serialize.py
index 5fdb674..420f7f9 100644
--- a/tests/orchestrator/context/test_serialize.py
+++ b/tests/orchestrator/context/test_serialize.py
@@ -99,10 +99,3 @@ def context(tmpdir):
yield result
storage.release_sqlite_storage(result.model)
-
-
-@pytest.fixture
-def memory_model_storage():
- result = aria.application_model_storage(sql_mapi.SQLAlchemyModelAPI)
- yield result
- storage.release_sqlite_storage(result)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/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..8f2c8a2 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor.py
@@ -21,19 +21,14 @@ from contextlib import contextmanager
import pytest
-from aria import application_model_storage
from aria.modeling import models as aria_models
-from aria.storage import sql_mapi
-from aria.orchestrator import (
- events,
- plugin
-)
+from aria.orchestrator import events
from aria.utils.plugin import create as create_plugin
from aria.orchestrator.workflows.executor import process
-
import tests.storage
import tests.resources
+from tests.fixtures import plugins_dir, plugin_manager, fs_model as model
class TestProcessExecutor(object):
@@ -75,27 +70,6 @@ class TestProcessExecutor(object):
@pytest.fixture
-def model(tmpdir):
- result = application_model_storage(sql_mapi.SQLAlchemyModelAPI,
- initiator_kwargs=dict(base_dir=str(tmpdir)),
- initiator=sql_mapi.init_storage)
- yield result
- tests.storage.release_sqlite_storage(result)
-
-
-@pytest.fixture
-def plugins_dir(tmpdir):
- result = tmpdir.join('plugins')
- result.mkdir()
- return str(result)
-
-
-@pytest.fixture
-def plugin_manager(model, plugins_dir):
- return plugin.PluginManager(model=model, plugins_dir=plugins_dir)
-
-
-@pytest.fixture
def executor(plugin_manager):
result = process.ProcessExecutor(plugin_manager=plugin_manager)
yield result
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py b/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py
index feebb6a..3a8c54b 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py
@@ -90,19 +90,19 @@ def _run_workflow(context, executor, op_func, inputs=None):
node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
interface_name = 'test_interface'
operation_name = 'operation'
- inputs = inputs or {}
+ wf_inputs = inputs or {}
interface = mock.models.create_interface(
ctx.service,
interface_name,
operation_name,
operation_kwargs=dict(implementation=_operation_mapping(op_func),
- inputs=inputs)
+ inputs=wf_inputs)
)
node.interfaces[interface.name] = interface
task = api.task.OperationTask.for_node(node=node,
interface_name=interface_name,
operation_name=operation_name,
- inputs=inputs)
+ inputs=wf_inputs)
graph.add_tasks(task)
return graph
graph = mock_workflow(ctx=context) # pylint: disable=no-value-for-parameter
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/tests/parser/service_templates.py
----------------------------------------------------------------------
diff --git a/tests/parser/service_templates.py b/tests/parser/service_templates.py
index a07fba8..a8fde14 100644
--- a/tests/parser/service_templates.py
+++ b/tests/parser/service_templates.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
+
from aria.utils.caching import cachedmethod
from .utils import (get_example_uri, get_test_uri, create_context, create_consumer)
@@ -23,7 +25,9 @@ def consume_use_case(use_case_name, consumer_class_name='instance', cache=True):
uri = get_example_uri('tosca-simple-1.0', 'use-cases', use_case_name,
'{0}.yaml'.format(use_case_name))
context = create_context(uri)
- #context.args.append('--inputs=' + get_example_uri('node-cellar', 'inputs.yaml'))
+ inputs_file = get_example_uri('tosca-simple-1.0', 'use-cases', use_case_name, 'inputs.yaml')
+ if os.path.isfile(inputs_file):
+ context.args.append('--inputs={0}'.format(inputs_file))
consumer, dumper = create_consumer(context, consumer_class_name)
consumer.consume()
context.validation.dump_issues()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/tests/parser/test_tosca_simple_v1_0.py
----------------------------------------------------------------------
diff --git a/tests/parser/test_tosca_simple_v1_0.py b/tests/parser/test_tosca_simple_v1_0.py
new file mode 100644
index 0000000..a583db5
--- /dev/null
+++ b/tests/parser/test_tosca_simple_v1_0.py
@@ -0,0 +1,112 @@
+# 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 .service_templates import (consume_use_case, consume_node_cellar)
+
+
+# Use Cases
+
+def test_use_case_compute_1():
+ consume_use_case('compute-1', 'instance')
+
+
+def test_use_case_software_component_1():
+ consume_use_case('software-component-1', 'instance')
+
+
+def test_use_case_block_storage_1():
+ consume_use_case('block-storage-1', 'instance')
+
+
+def test_use_case_block_storage_2():
+ consume_use_case('block-storage-2', 'instance')
+
+
+def test_use_case_block_storage_3():
+ consume_use_case('block-storage-3', 'instance')
+
+
+def test_use_case_block_storage_4():
+ consume_use_case('block-storage-4', 'instance')
+
+
+def test_use_case_block_storage_5():
+ consume_use_case('block-storage-5', 'instance')
+
+
+def test_use_case_block_storage_6():
+ consume_use_case('block-storage-6', 'instance')
+
+
+def test_use_case_object_storage_1():
+ consume_use_case('object-storage-1', 'instance')
+
+
+def test_use_case_network_1():
+ consume_use_case('network-1', 'instance')
+
+
+def test_use_case_network_2():
+ consume_use_case('network-2', 'instance')
+
+
+def test_use_case_network_3():
+ consume_use_case('network-3', 'instance')
+
+
+def test_use_case_network_4():
+ consume_use_case('network-4', 'instance')
+
+
+def test_use_case_webserver_dbms_1():
+ consume_use_case('webserver-dbms-1', 'template')
+
+
+def test_use_case_webserver_dbms_2():
+ consume_use_case('webserver-dbms-2', 'instance')
+
+
+def test_use_case_multi_tier_1():
+ consume_use_case('multi-tier-1', 'instance')
+
+
+def test_use_case_container_1():
+ consume_use_case('container-1', 'template')
+
+
+# NodeCellar
+
+def test_node_cellar_validation():
+ consume_node_cellar('validate')
+
+
+def test_node_cellar_validation_no_cache():
+ consume_node_cellar('validate', False)
+
+
+def test_node_cellar_presentation():
+ consume_node_cellar('presentation')
+
+
+def test_node_cellar_model():
+ consume_node_cellar('template')
+
+
+def test_node_cellar_types():
+ consume_node_cellar('types')
+
+
+def test_node_cellar_instance():
+ consume_node_cellar('instance')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/61a2b03c/tests/utils/test_plugin.py
----------------------------------------------------------------------
diff --git a/tests/utils/test_plugin.py b/tests/utils/test_plugin.py
index 09885ef..df82515 100644
--- a/tests/utils/test_plugin.py
+++ b/tests/utils/test_plugin.py
@@ -17,13 +17,14 @@ import os
import pytest
-from aria import application_model_storage
from aria.orchestrator import exceptions
-from aria.orchestrator import plugin
from aria.utils.plugin import create as create_plugin
-from aria.storage import sql_mapi
-from .. import storage
+from ..fixtures import (
+ plugins_dir,
+ plugin_manager,
+ inmemory_model as model
+)
PACKAGE_NAME = 'mock-plugin'
@@ -48,26 +49,6 @@ class TestPluginManager(object):
@pytest.fixture
-def model():
- model = application_model_storage(sql_mapi.SQLAlchemyModelAPI,
- initiator=storage.init_inmemory_model_storage)
- yield model
- storage.release_sqlite_storage(model)
-
-
-@pytest.fixture
-def plugins_dir(tmpdir):
- result = tmpdir.join('plugins')
- result.mkdir()
- return str(result)
-
-
-@pytest.fixture
-def plugin_manager(model, plugins_dir):
- return plugin.PluginManager(model=model, plugins_dir=plugins_dir)
-
-
-@pytest.fixture
def mock_plugin(tmpdir):
source_dir = tmpdir.join('mock_plugin')
source_dir.mkdir()