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/03/23 09:41:10 UTC
incubator-ariatosca git commit:
ARIA-130-Passing-inputs-from-the-workflow-to-the-operation-changes-the-inputs
[Forced Update!]
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-130-Passing-inputs-from-the-workflow-to-the-operation-changes-the-inputs 080328c04 -> eecd8aca2 (forced update)
ARIA-130-Passing-inputs-from-the-workflow-to-the-operation-changes-the-inputs
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/eecd8aca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/eecd8aca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/eecd8aca
Branch: refs/heads/ARIA-130-Passing-inputs-from-the-workflow-to-the-operation-changes-the-inputs
Commit: eecd8aca213c565f012810dd3220488e8152217c
Parents: 9841ca4
Author: max-orlov <ma...@gigaspaces.com>
Authored: Wed Mar 22 19:19:53 2017 +0200
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Thu Mar 23 11:40:21 2017 +0200
----------------------------------------------------------------------
aria/modeling/relationship.py | 9 ++++-----
aria/modeling/service_common.py | 8 ++++++++
aria/orchestrator/workflows/api/task.py | 9 +++++----
tests/modeling/test_models.py | 20 +++++++++++++++++++-
tests/orchestrator/context/test_operation.py | 6 ++----
.../executor/test_process_executor_extension.py | 4 ++--
.../test_process_executor_tracked_changes.py | 4 ++--
7 files changed, 42 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eecd8aca/aria/modeling/relationship.py
----------------------------------------------------------------------
diff --git a/aria/modeling/relationship.py b/aria/modeling/relationship.py
index bed1599..ef2bcdd 100644
--- a/aria/modeling/relationship.py
+++ b/aria/modeling/relationship.py
@@ -305,11 +305,10 @@ def many_to_many(model_class,
secondary_table = '{0}_{1}'.format(this_table, other_table)
- if other_property is None:
- other_property = formatting.pluralize(this_table)
- if prefix is not None:
- secondary_table = '{0}_{1}'.format(prefix, secondary_table)
- other_property = '{0}_{1}'.format(prefix, other_property)
+ if prefix is not None:
+ secondary_table = '{0}_{1}'.format(prefix, secondary_table)
+ if other_property is None:
+ other_property = '{0}_{1}'.format(prefix, this_table)
backref_kwargs = backref_kwargs or {}
backref_kwargs.setdefault('uselist', True)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eecd8aca/aria/modeling/service_common.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index dfe4674..3f49645 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -202,6 +202,14 @@ class TypeBase(InstanceModelMixin):
types.append(raw_child)
child._append_raw_children(types)
+ @property
+ def hierarchy(self):
+ """
+ Return the type hierarchy.
+ :return:
+ """
+ return [self] + (self.parent.hierarchy if self.parent else [])
+
class MetadataBase(TemplateModelMixin):
"""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eecd8aca/aria/orchestrator/workflows/api/task.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/api/task.py b/aria/orchestrator/workflows/api/task.py
index 9522d7a..009b81c 100644
--- a/aria/orchestrator/workflows/api/task.py
+++ b/aria/orchestrator/workflows/api/task.py
@@ -16,6 +16,7 @@
"""
Provides the tasks to be entered into the task graph
"""
+import copy
from ....modeling import models
from ....utils.collections import OrderedDict
@@ -91,10 +92,10 @@ class OperationTask(BaseTask):
self.runs_on = runs_on
# Wrap inputs
- if inputs:
- for k, v in inputs.iteritems():
- if not isinstance(v, models.Parameter):
- inputs[k] = models.Parameter.wrap(k, v)
+ inputs = copy.deepcopy(inputs) if inputs else {}
+ for k, v in inputs.iteritems():
+ if not isinstance(v, models.Parameter):
+ inputs[k] = models.Parameter.wrap(k, v)
# TODO: Suggestion: these extra inputs could be stored as a separate entry in the task
# model, because they are different from the operation inputs. If we do this, then the two
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eecd8aca/tests/modeling/test_models.py
----------------------------------------------------------------------
diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py
index 5266d79..8c5e23a 100644
--- a/tests/modeling/test_models.py
+++ b/tests/modeling/test_models.py
@@ -36,7 +36,8 @@ from aria.modeling.models import (
Relationship,
NodeTemplate,
Node,
- Parameter
+ Parameter,
+ Type
)
from tests import mock
@@ -835,3 +836,20 @@ class TestTask(object):
create_task(max_attempts=0)
with pytest.raises(ValueError):
create_task(max_attempts=-2)
+
+
+class TestType(object):
+ def test_type_hierarchy(self):
+ super_type = Type(variant='variant', name='super')
+ sub_type = Type(variant='variant', parent=super_type, name='sub')
+ additional_type = Type(variant='variant', name='non_related')
+
+ assert super_type.hierarchy == [super_type]
+ assert sub_type.hierarchy == [sub_type, super_type]
+ assert additional_type.hierarchy == [additional_type]
+
+ super_type.parent = additional_type
+
+ assert super_type.hierarchy == [super_type, additional_type]
+ assert sub_type.hierarchy == [sub_type, super_type, additional_type]
+
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eecd8aca/tests/orchestrator/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py
index 05c9656..f8a79c5 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -363,13 +363,11 @@ def _assert_loggins(ctx, inputs):
assert all(l.execution == execution for l in logs)
assert all(l in logs and l.task == task for l in task.logs)
- op_start_log = [l for l in logs if
- inputs['op_start'].value in l.msg and l.level.lower() == 'info']
+ op_start_log = [l for l in logs if inputs['op_start'] in l.msg and l.level.lower() == 'info']
assert len(op_start_log) == 1
op_start_log = op_start_log[0]
- op_end_log = [l for l in logs
- if inputs['op_end'].value in l.msg and l.level.lower() == 'debug']
+ op_end_log = [l for l in logs if inputs['op_end'] in l.msg and l.level.lower() == 'debug']
assert len(op_end_log) == 1
op_end_log = op_end_log[0]
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eecd8aca/tests/orchestrator/workflows/executor/test_process_executor_extension.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_process_executor_extension.py b/tests/orchestrator/workflows/executor/test_process_executor_extension.py
index 1c4cda6..0988fae 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor_extension.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor_extension.py
@@ -55,8 +55,8 @@ def test_decorate_extension(context, executor):
eng = engine.Engine(executor=executor, workflow_context=context, tasks_graph=graph)
eng.execute()
out = get_node(context).runtime_properties['out']
- assert out['wrapper_inputs'] == dict((k, v.value) for k, v in inputs.iteritems())
- assert out['function_inputs'] == dict((k, v.value) for k, v in inputs.iteritems())
+ assert out['wrapper_inputs'] == inputs
+ assert out['function_inputs'] == inputs
@extension.process_executor
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/eecd8aca/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 a3957c3..5512189 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py
@@ -73,9 +73,9 @@ def test_apply_tracked_changes_during_an_operation(context, executor):
inputs=inputs)
expected_after_update = expected_initial.copy()
- expected_after_update.update(inputs['committed'].value) # pylint: disable=no-member
+ expected_after_update.update(inputs['committed']) # pylint: disable=no-member
expected_after_change = expected_after_update.copy()
- expected_after_change.update(inputs['changed_but_refreshed'].value) # pylint: disable=no-member
+ expected_after_change.update(inputs['changed_but_refreshed']) # pylint: disable=no-member
expected_after_refresh = expected_after_update
assert out['initial'] == expected_initial