You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by em...@apache.org on 2017/07/05 20:46:43 UTC

[1/5] incubator-ariatosca git commit: ARIA-298 test suite sometimes fails or freezes while all tests pass [Forced Update!]

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-260-send-interface-inputs 299aba7a7 -> 2be2e526f (forced update)


ARIA-298 test suite sometimes fails or freezes while all tests pass


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/ca808ae5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ca808ae5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ca808ae5

Branch: refs/heads/ARIA-260-send-interface-inputs
Commit: ca808ae5eab354c267a1b42dd838ed0d7fbe03a8
Parents: 3583f8c
Author: max-orlov <ma...@gigaspaces.com>
Authored: Mon Jul 3 11:27:33 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Tue Jul 4 14:53:43 2017 +0300

----------------------------------------------------------------------
 .../execution_plugin/ctx_proxy/server.py        |  1 +
 aria/utils/threading.py                         |  1 +
 .../orchestrator/workflows/core/test_engine.py  |  1 +
 .../orchestrator/workflows/core/test_events.py  | 84 +++++++++++++-------
 4 files changed, 58 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ca808ae5/aria/orchestrator/execution_plugin/ctx_proxy/server.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/execution_plugin/ctx_proxy/server.py b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
index 0a2a606..ca910e0 100644
--- a/aria/orchestrator/execution_plugin/ctx_proxy/server.py
+++ b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
@@ -102,6 +102,7 @@ class CtxProxy(object):
                 quiet=True,
                 server=BottleServerAdapter)
         thread = threading.Thread(target=serve)
+        thread.daemon = True
         thread.start()
         return thread
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ca808ae5/aria/utils/threading.py
----------------------------------------------------------------------
diff --git a/aria/utils/threading.py b/aria/utils/threading.py
index b9d627a..f5ca302 100644
--- a/aria/utils/threading.py
+++ b/aria/utils/threading.py
@@ -269,6 +269,7 @@ class ExceptionThread(Thread):
     def __init__(self, *args, **kwargs):
         Thread.__init__(self, *args, **kwargs)
         self.exception = None
+        self.daemon = True
 
     def run(self):
         try:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ca808ae5/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 21a53d7..0c704f5 100644
--- a/tests/orchestrator/workflows/core/test_engine.py
+++ b/tests/orchestrator/workflows/core/test_engine.py
@@ -257,6 +257,7 @@ class TestCancel(BaseTest):
                            workflow_context=workflow_context,
                            executor=executor)
         t = threading.Thread(target=eng.execute, kwargs=dict(ctx=workflow_context))
+        t.daemon = True
         t.start()
         time.sleep(10)
         eng.cancel_execution(workflow_context)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ca808ae5/tests/orchestrator/workflows/core/test_events.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/core/test_events.py b/tests/orchestrator/workflows/core/test_events.py
index ff50eab..d804de5 100644
--- a/tests/orchestrator/workflows/core/test_events.py
+++ b/tests/orchestrator/workflows/core/test_events.py
@@ -45,67 +45,82 @@ TYPE_URI_NAME = 'tosca.interfaces.node.lifecycle.Standard'
 SHORTHAND_NAME = 'Standard'
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_create(ctx):
-    node = run_operation_on_node(ctx, interface_name=TYPE_URI_NAME, op_name='create')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_create(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=TYPE_URI_NAME, op_name='create', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'create')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_configure(ctx):
-    node = run_operation_on_node(ctx, interface_name=TYPE_URI_NAME, op_name='configure')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_configure(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=TYPE_URI_NAME, op_name='configure', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'configure')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_start(ctx):
-    node = run_operation_on_node(ctx, interface_name=TYPE_URI_NAME, op_name='start')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_start(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=TYPE_URI_NAME, op_name='start', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'start')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_stop(ctx):
-    node = run_operation_on_node(ctx, interface_name=TYPE_URI_NAME, op_name='stop')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_stop(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=TYPE_URI_NAME, op_name='stop', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'stop')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_delete(ctx):
-    node = run_operation_on_node(ctx, interface_name=TYPE_URI_NAME, op_name='delete')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_delete(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=TYPE_URI_NAME, op_name='delete', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'delete')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_create_shorthand_name(ctx):
-    node = run_operation_on_node(ctx, interface_name=SHORTHAND_NAME, op_name='create')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_create_shorthand_name(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=SHORTHAND_NAME, op_name='create', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'create')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_configure_shorthand_name(ctx):
-    node = run_operation_on_node(ctx, interface_name=SHORTHAND_NAME, op_name='configure')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_configure_shorthand_name(
+        ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=SHORTHAND_NAME, op_name='configure', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'configure')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_start_shorthand_name(ctx):
-    node = run_operation_on_node(ctx, interface_name=SHORTHAND_NAME, op_name='start')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_start_shorthand_name(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=SHORTHAND_NAME, op_name='start', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'start')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_stop_shorthand_name(ctx):
-    node = run_operation_on_node(ctx, interface_name=SHORTHAND_NAME, op_name='stop')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_stop_shorthand_name(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=SHORTHAND_NAME, op_name='stop', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'stop')
 
 
-def test_node_state_changes_as_a_result_of_standard_lifecycle_delete_shorthand_name(ctx):
-    node = run_operation_on_node(ctx, interface_name=SHORTHAND_NAME, op_name='delete')
+def test_node_state_changes_as_a_result_of_standard_lifecycle_delete_shorthand_name(ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name=SHORTHAND_NAME, op_name='delete', executor=executor)
     _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, 'delete')
 
 
-def test_node_state_doesnt_change_as_a_result_of_an_operation_that_is_not_standard_lifecycle1(ctx):
-    node = run_operation_on_node(ctx, interface_name='interface_name', op_name='op_name')
+def test_node_state_doesnt_change_as_a_result_of_an_operation_that_is_not_standard_lifecycle1(
+        ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name='interface_name', op_name='op_name', executor=executor)
     assert node.state == node.INITIAL
 
 
-def test_node_state_doesnt_change_as_a_result_of_an_operation_that_is_not_standard_lifecycle2(ctx):
-    node = run_operation_on_node(ctx, interface_name='interface_name', op_name='create')
+def test_node_state_doesnt_change_as_a_result_of_an_operation_that_is_not_standard_lifecycle2(
+        ctx, executor):
+    node = run_operation_on_node(
+        ctx, interface_name='interface_name', op_name='create', executor=executor)
     assert node.state == node.INITIAL
 
 
-def run_operation_on_node(ctx, op_name, interface_name):
+def run_operation_on_node(ctx, op_name, interface_name, executor):
     node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
     interface = mock.models.create_interface(
         service=node.service,
@@ -117,14 +132,16 @@ def run_operation_on_node(ctx, op_name, interface_name):
         single_operation_workflow(ctx, node=node, interface_name=interface_name, op_name=op_name)
     )
 
-    eng = engine.Engine(executors={ThreadExecutor: ThreadExecutor()})
+    eng = engine.Engine(executors={executor.__class__: executor})
     eng.execute(ctx)
     return node
 
 
-def run_standard_lifecycle_operation_on_node(ctx, op_name):
-    return run_operation_on_node(ctx, interface_name='aria.interfaces.lifecycle.Standard',
-                                 op_name=op_name)
+def run_standard_lifecycle_operation_on_node(ctx, op_name, executor):
+    return run_operation_on_node(ctx,
+                                 interface_name='aria.interfaces.lifecycle.Standard',
+                                 op_name=op_name,
+                                 executor=executor)
 
 
 def _assert_node_state_changed_as_a_result_of_standard_lifecycle_operation(node, op_name):
@@ -143,3 +160,12 @@ def single_operation_workflow(graph, node, interface_name, op_name, **_):
 @operation
 def func(ctx):
     global_test_dict['transitional_state'] = ctx.node.state
+
+
+@pytest.fixture
+def executor():
+    result = ThreadExecutor()
+    try:
+        yield result
+    finally:
+        result.close()


[2/5] incubator-ariatosca git commit: ARIA-202 Execution plugin assumes \/tmp for temp directory on the local\/remote machine

Posted by em...@apache.org.
ARIA-202 Execution plugin assumes \/tmp for temp directory on the local\/remote machine


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/cc1a2302
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/cc1a2302
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/cc1a2302

Branch: refs/heads/ARIA-260-send-interface-inputs
Commit: cc1a2302b7eae8eda05251442b0e4c8ad60dce2b
Parents: ca808ae
Author: max-orlov <ma...@gigaspaces.com>
Authored: Tue Jul 4 16:13:41 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Tue Jul 4 16:48:08 2017 +0300

----------------------------------------------------------------------
 aria/orchestrator/execution_plugin/constants.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cc1a2302/aria/orchestrator/execution_plugin/constants.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/execution_plugin/constants.py b/aria/orchestrator/execution_plugin/constants.py
index 8082e95..1953912 100644
--- a/aria/orchestrator/execution_plugin/constants.py
+++ b/aria/orchestrator/execution_plugin/constants.py
@@ -16,6 +16,8 @@
 """
 Execution plugin constants.
 """
+import os
+import tempfile
 
 from . import exceptions
 
@@ -28,7 +30,7 @@ DEFAULT_POWERSHELL_EXECUTABLE = 'powershell'
 ILLEGAL_CTX_OPERATION_MESSAGE = 'ctx may only abort or retry once'
 
 # related to ssh
-DEFAULT_BASE_DIR = '/tmp/aria-ctx'
+DEFAULT_BASE_DIR = os.path.join(tempfile.gettempdir(), 'aria-ctx')
 FABRIC_ENV_DEFAULTS = {
     'connection_attempts': 5,
     'timeout': 10,


[3/5] incubator-ariatosca git commit: ARIA-287 Add tox environment for docs

Posted by em...@apache.org.
ARIA-287 Add tox environment for docs

Also adds the environment to "make test". Involves fixing Sphinx to
properly exclude SSH documentation when Fabric is not installed.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/6c084242
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/6c084242
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/6c084242

Branch: refs/heads/ARIA-260-send-interface-inputs
Commit: 6c0842429bf2641f6cb74a355f9abebd0b8387f9
Parents: cc1a230
Author: Tal Liron <ta...@gmail.com>
Authored: Fri Jun 30 17:08:23 2017 -0500
Committer: Ran Ziv <ra...@gigaspaces.com>
Committed: Tue Jul 4 17:18:45 2017 +0300

----------------------------------------------------------------------
 Makefile     |  9 +++++++--
 docs/conf.py | 33 +++++++++++++++++++++++++++++----
 tox.ini      | 28 ++++++++++++++++++----------
 3 files changed, 54 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6c084242/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index 71a1968..a894747 100644
--- a/Makefile
+++ b/Makefile
@@ -47,11 +47,16 @@ install-virtual:
 docs:
 	pip install --requirement "$(DOCS)/requirements.txt"
 	rm -rf "$(HTML)"
-	sphinx-build -b html "$(DOCS)" "$(HTML)"
+	sphinx-build -W -T -b html "$(DOCS)" "$(HTML)"
 
 test:
 	pip install --upgrade "tox>=2.7.0"
-	tox -e pylint_code -e pylint_tests -e py$(PYTHON_VERSION) -e py$(PYTHON_VERSION)e2e -e py$(PYTHON_VERSION)ssh
+	tox -e pylint_code \
+	    -e pylint_tests \
+	    -e py$(PYTHON_VERSION) \
+	    -e py$(PYTHON_VERSION)e2e \
+	    -e py$(PYTHON_VERSION)ssh \
+	    -e docs
 
 dist: docs
 	python ./setup.py sdist bdist_wheel

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6c084242/docs/conf.py
----------------------------------------------------------------------
diff --git a/docs/conf.py b/docs/conf.py
index 6361621..fd1a066 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -390,8 +390,20 @@ NEVER_SKIP_MEMBERS = (
     '__evaluate__',
 )
 
-# 'autodoc-skip-member' event
-def on_skip_member(app, what, name, obj, skip, options):
+SKIP_DOCUMENTS = ()
+
+from sphinx import addnodes
+from sphinx.domains.python import PythonDomain
+
+try:
+    import fabric
+except:
+    # Note: "exclude_patterns" is not good enough for us, because we still have a TOC entry.
+    # Unfortunately, there is no way to conditionally exclude a TOC entry, and TOC entries without
+    # matching documents emit an error. So, we will have to manipulate the doctree directly!
+    SKIP_DOCUMENTS = ('aria.orchestrator.execution_plugin.ssh',)
+
+def on_autodoc_skip_member(app, what, name, obj, skip, options):
     if name in NEVER_SKIP_MEMBERS:
         return False
     if name in SKIP_MEMBERS: 
@@ -401,7 +413,18 @@ def on_skip_member(app, what, name, obj, skip, options):
             return True
     return skip
 
-from sphinx.domains.python import PythonDomain
+def on_source_read(app, docname, source):
+    # Empty out source
+    if docname in SKIP_DOCUMENTS:
+        source[0] = ''
+
+def on_doctree_read(app, doctree):
+    # Remove TOC entry (see: https://gist.github.com/kakawait/9215487)
+    for toctreenode in doctree.traverse(addnodes.toctree):
+        for e in toctreenode['entries']:
+            ref = str(e[1])
+            if ref in SKIP_DOCUMENTS:
+                toctreenode['entries'].remove(e)    
 
 class PatchedPythonDomain(PythonDomain):
     # See: https://github.com/sphinx-doc/sphinx/issues/3866
@@ -412,5 +435,7 @@ class PatchedPythonDomain(PythonDomain):
             env, fromdocname, builder, typ, target, node, contnode)
 
 def setup(app):
-    app.connect('autodoc-skip-member', on_skip_member)
+    app.connect('autodoc-skip-member', on_autodoc_skip_member)
+    app.connect('source-read', on_source_read)
+    app.connect('doctree-read', on_doctree_read)
     app.override_domain(PatchedPythonDomain)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6c084242/tox.ini
----------------------------------------------------------------------
diff --git a/tox.ini b/tox.ini
index 3e1fb3c..9849b5e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,18 +11,19 @@
 # limitations under the License.
 
 [tox]
-envlist=py27,py26,py27e2e,py26e2e,pywin,py27ssh,pylint_code,pylint_tests
+envlist=py27,py26,py27e2e,py26e2e,pywin,py27ssh,pylint_code,pylint_tests,docs
 
 [testenv]
-passenv =
-    TRAVIS
-    PYTHON
-    PYTHON_VERSION
-    PYTHON_ARCH
-deps =
-    -rrequirements.txt
-    -rtests/requirements.txt
-basepython =
+whitelist_externals=rm
+passenv=
+  TRAVIS
+  PYTHON
+  PYTHON_VERSION
+  PYTHON_ARCH
+deps=
+  -rrequirements.txt
+  -rtests/requirements.txt
+basepython=
   py26: python2.6
   py27: python2.7
   py26e2e: python2.6
@@ -32,6 +33,7 @@ basepython =
   pywin: {env:PYTHON:}\python.exe
   pylint_code: python2.7
   pylint_tests: python2.7
+  docs: python2.7
 
 [testenv:py27]
 commands=pytest tests --ignore=tests/end2end --ignore=tests/orchestrator/execution_plugin/test_ssh.py --cov-report term-missing --cov aria
@@ -61,3 +63,9 @@ commands=pylint --rcfile=aria/.pylintrc --disable=fixme,missing-docstring aria e
 
 [testenv:pylint_tests]
 commands=pylint --rcfile=tests/.pylintrc --disable=fixme,missing-docstring tests
+
+[testenv:docs]
+commands=
+  pip install --requirement docs/requirements.txt
+  rm --recursive --force docs/html
+  sphinx-build -W -T -b html docs docs/html


[4/5] incubator-ariatosca git commit: ARIA-260 Send interface inputs as arguments

Posted by em...@apache.org.
ARIA-260 Send interface inputs as arguments


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9039942e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9039942e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9039942e

Branch: refs/heads/ARIA-260-send-interface-inputs
Commit: 9039942e40f7a1e5cd5793f01d33da06e3cbf57d
Parents: 6c08424
Author: Tal Liron <ta...@gmail.com>
Authored: Fri Jun 2 13:35:21 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Jul 5 15:41:09 2017 -0500

----------------------------------------------------------------------
 aria/modeling/service_instance.py               |  20 +--
 aria/modeling/utils.py                          |   4 +
 tests/instantiation/__init__.py                 |  14 ++
 tests/instantiation/test_configuration.py       | 175 +++++++++++++++++++
 tests/parser/service_templates.py               |  12 ++
 .../node-cellar/node-cellar.yaml                |  22 ++-
 6 files changed, 233 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9039942e/aria/modeling/service_instance.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py
index 002a87c..0d43650 100644
--- a/aria/modeling/service_instance.py
+++ b/aria/modeling/service_instance.py
@@ -2012,19 +2012,19 @@ class OperationBase(InstanceModelMixin):
             # In the future plugins may be able to add their own "configure_operation" hook that
             # can validate the configuration and otherwise create specially derived arguments. For
             # now, we just send all configuration parameters as arguments without validation.
-            configurations_as_arguments = {}
-            for configuration in self.configurations.itervalues():
-                configurations_as_arguments[configuration.name] = configuration.as_argument()
+            utils.instantiate_dict(self, self.arguments,
+                                   utils.dict_as_arguments(self.configurations))
 
-            utils.instantiate_dict(self, self.arguments, configurations_as_arguments)
+        if self.interface is not None:
+            # Send all interface inputs as extra arguments
+            # ("interface" is None for workflow operations)
+            # Note that they will override existing arguments of the same names
+            utils.instantiate_dict(self, self.arguments,
+                                   utils.dict_as_arguments(self.interface.inputs))
 
         # Send all inputs as extra arguments
         # Note that they will override existing arguments of the same names
-        inputs_as_arguments = {}
-        for input in self.inputs.itervalues():
-            inputs_as_arguments[input.name] = input.as_argument()
-
-        utils.instantiate_dict(self, self.arguments, inputs_as_arguments)
+        utils.instantiate_dict(self, self.arguments, utils.dict_as_arguments(self.inputs))
 
         # Check for reserved arguments
         from ..orchestrator.decorators import OPERATION_DECORATOR_RESERVED_ARGUMENTS
@@ -2032,7 +2032,7 @@ class OperationBase(InstanceModelMixin):
             OPERATION_DECORATOR_RESERVED_ARGUMENTS.intersection(self.arguments.keys())
         if used_reserved_names:
             context = ConsumptionContext.get_thread_local()
-            context.validation.report('using reserved arguments in node "{0}": {1}'
+            context.validation.report('using reserved arguments in operation "{0}": {1}'
                                       .format(
                                           self.name,
                                           formatting.string_list_as_string(used_reserved_names)),

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9039942e/aria/modeling/utils.py
----------------------------------------------------------------------
diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py
index 5193cd9..64e7c74 100644
--- a/aria/modeling/utils.py
+++ b/aria/modeling/utils.py
@@ -211,6 +211,10 @@ def dump_interfaces(interfaces, name='Interfaces'):
             interface.dump()
 
 
+def dict_as_arguments(the_dict):
+    return OrderedDict((name, value.as_argument()) for name, value in the_dict.iteritems())
+
+
 class classproperty(object):                                                                        # pylint: disable=invalid-name
     def __init__(self, f):
         self._func = f

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9039942e/tests/instantiation/__init__.py
----------------------------------------------------------------------
diff --git a/tests/instantiation/__init__.py b/tests/instantiation/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/instantiation/__init__.py
@@ -0,0 +1,14 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9039942e/tests/instantiation/test_configuration.py
----------------------------------------------------------------------
diff --git a/tests/instantiation/test_configuration.py b/tests/instantiation/test_configuration.py
new file mode 100644
index 0000000..7629539
--- /dev/null
+++ b/tests/instantiation/test_configuration.py
@@ -0,0 +1,175 @@
+# 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 tests.parser.service_templates import consume_literal
+
+
+TEMPLATE = """
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+interface_types:
+  MyInterface:
+    derived_from: tosca.interfaces.Root   
+    inputs:
+      interface_string:
+        type: string
+        default: value1
+      interface_integer:
+        type: integer
+        default: 1
+    operation:
+      implementation: operation.sh
+      inputs:
+        operation_string:
+          type: string
+          default: value2
+        operation_integer:
+          type: integer
+          default: 2
+        interface_integer: # will override interface input
+          type: integer
+          default: 3
+
+node_types:
+  LocalNode:
+    derived_from: tosca.nodes.Root
+    interfaces:
+      MyInterface:
+        type: MyInterface
+
+  RemoteNode:
+    derived_from: tosca.nodes.Compute
+    interfaces:
+      MyInterface:
+        type: MyInterface
+
+topology_template:
+  node_templates:
+    local_node:
+      type: LocalNode
+
+    remote_node:
+      type: RemoteNode   
+"""
+
+
+BROKEN_TEMPLATE = """
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+interface_types:
+  MyInterface:
+    derived_from: tosca.interfaces.Root   
+    inputs:
+      ctx: # reserved name
+        type: string
+        default: value1
+      interface_integer:
+        type: integer
+        default: 1
+    operation:
+      implementation: operation.sh
+      inputs:
+        operation_string:
+          type: string
+          default: value2
+        toolbelt: # reserved name
+          type: integer
+          default: 2
+
+node_types:
+  LocalNode:
+    derived_from: tosca.nodes.Root
+    interfaces:
+      MyInterface:
+        type: MyInterface
+
+topology_template:
+  node_templates:
+    local_node:
+      type: LocalNode
+"""
+
+
+@pytest.fixture
+def service():
+    context, _ = consume_literal(TEMPLATE)
+    yield context.modeling.instance
+
+
+@pytest.fixture
+def broken_service_issues():
+    context, _ = consume_literal(BROKEN_TEMPLATE, no_issues=False)
+    yield context.validation.issues
+
+
+def _values(the_dict):
+    return dict((k, v.value) for k, v in the_dict.iteritems())
+
+
+def test_local(service):
+    interface = service.nodes['local_node_1'].interfaces['MyInterface']
+    operation = interface.operations['operation']
+    assert _values(interface.inputs) == {
+        'interface_string': 'value1',
+        'interface_integer': 1
+    }
+    assert _values(operation.inputs) == {
+        'operation_string': 'value2',
+        'operation_integer': 2,
+        'interface_integer': 3
+    }
+    assert _values(operation.arguments) == {
+        'process': {},
+        'script_path': 'operation.sh',
+        'interface_string': 'value1',
+        'interface_integer': 3,
+        'operation_string': 'value2',
+        'operation_integer': 2
+    }
+
+
+def test_remote(service):
+    interface = service.nodes['remote_node_1'].interfaces['MyInterface']
+    operation = interface.operations['operation']
+    assert _values(interface.inputs) == {
+        'interface_string': 'value1',
+        'interface_integer': 1
+    }
+    assert _values(operation.inputs) == {
+        'operation_string': 'value2',
+        'operation_integer': 2,
+        'interface_integer': 3
+    }
+    assert _values(operation.arguments) == {
+        'process': {},
+        'use_sudo': False,
+        'fabric_env': {'user': '', 'password': '', 'key': None, 'key_filename': None},
+        'script_path': 'operation.sh',
+        'hide_output': [],
+        'interface_string': 'value1',
+        'interface_integer': 3,
+        'operation_string': 'value2',
+        'operation_integer': 2
+    }
+
+
+def test_reserved_arguments(broken_service_issues):
+    assert len(broken_service_issues) == 1
+    message = broken_service_issues[0].message
+    assert message.startswith('using reserved arguments in operation "operation":')
+    assert '"ctx"' in message
+    assert '"toolbelt"' in message

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9039942e/tests/parser/service_templates.py
----------------------------------------------------------------------
diff --git a/tests/parser/service_templates.py b/tests/parser/service_templates.py
index 56f75ab..13712df 100644
--- a/tests/parser/service_templates.py
+++ b/tests/parser/service_templates.py
@@ -16,11 +16,23 @@
 import os
 
 from aria.utils.caching import cachedmethod
+from aria.parser.loading import LiteralLocation
 
 from .utils import (create_context, create_consumer)
 from ..helpers import (get_example_uri, get_service_template_uri)
 
 
+def consume_literal(literal, consumer_class_name='instance', cache=True, no_issues=True):
+    cachedmethod.ENABLED = cache
+    context = create_context(LiteralLocation(literal))
+    consumer, dumper = create_consumer(context, consumer_class_name)
+    consumer.consume()
+    if no_issues:
+        context.validation.dump_issues()
+        assert not context.validation.has_issues
+    return context, dumper
+
+
 def consume_use_case(use_case_name, consumer_class_name='instance', cache=True):
     cachedmethod.ENABLED = cache
     uri = get_example_uri('tosca-simple-1.0', 'use-cases', use_case_name,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9039942e/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 a34301c..a5df3e8 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
@@ -54,8 +54,20 @@ interface_types:
 
   Maintenance:
     derived_from: tosca.interfaces.Root
-    enable: {}
-    disable: {}
+    inputs:
+      mode:
+        type: string
+        default: immediate
+        constraints:
+          - valid_values: [ immediate, eventual ]
+        description: >-
+          The mode in which maintenance mode is enabled/disabled.
+    enable:
+      description: >-
+        Enable maintenance mode.
+    disable:
+      description: >-
+        Disable maintenance mode.
 
 node_types:
 
@@ -102,8 +114,10 @@ topology_template:
               #token: { token: [ 'zero.one|two-three', '.|-', 3 ] }
       interfaces:
         Maintenance:
-          enable: juju > charm.maintenance_on
-          disable: juju > charm.maintenance_off
+          inputs:
+            mode: eventual
+          enable: maintenance_node_cellar.sh
+          disable: maintenance_node_cellar.sh
         Standard:
           create:
             implementation:


[5/5] incubator-ariatosca git commit: PR fixes

Posted by em...@apache.org.
PR fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/2be2e526
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/2be2e526
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/2be2e526

Branch: refs/heads/ARIA-260-send-interface-inputs
Commit: 2be2e526f032397cc267432135e6f18327d458c6
Parents: 9039942
Author: Tal Liron <ta...@gmail.com>
Authored: Wed Jul 5 15:46:21 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Jul 5 15:46:21 2017 -0500

----------------------------------------------------------------------
 aria/modeling/utils.py                    |  4 ++++
 tests/instantiation/test_configuration.py | 17 +++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2be2e526/aria/modeling/utils.py
----------------------------------------------------------------------
diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py
index 64e7c74..e0fd11b 100644
--- a/aria/modeling/utils.py
+++ b/aria/modeling/utils.py
@@ -211,6 +211,10 @@ def dump_interfaces(interfaces, name='Interfaces'):
             interface.dump()
 
 
+def parameters_as_values(the_dict):
+    return dict((k, v.value) for k, v in the_dict.iteritems())
+
+
 def dict_as_arguments(the_dict):
     return OrderedDict((name, value.as_argument()) for name, value in the_dict.iteritems())
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/2be2e526/tests/instantiation/test_configuration.py
----------------------------------------------------------------------
diff --git a/tests/instantiation/test_configuration.py b/tests/instantiation/test_configuration.py
index 7629539..6ac0c9c 100644
--- a/tests/instantiation/test_configuration.py
+++ b/tests/instantiation/test_configuration.py
@@ -16,6 +16,7 @@
 import pytest
 
 from tests.parser.service_templates import consume_literal
+from aria.modeling.utils import parameters_as_values
 
 
 TEMPLATE = """
@@ -116,23 +117,19 @@ def broken_service_issues():
     yield context.validation.issues
 
 
-def _values(the_dict):
-    return dict((k, v.value) for k, v in the_dict.iteritems())
-
-
 def test_local(service):
     interface = service.nodes['local_node_1'].interfaces['MyInterface']
     operation = interface.operations['operation']
-    assert _values(interface.inputs) == {
+    assert parameters_as_values(interface.inputs) == {
         'interface_string': 'value1',
         'interface_integer': 1
     }
-    assert _values(operation.inputs) == {
+    assert parameters_as_values(operation.inputs) == {
         'operation_string': 'value2',
         'operation_integer': 2,
         'interface_integer': 3
     }
-    assert _values(operation.arguments) == {
+    assert parameters_as_values(operation.arguments) == {
         'process': {},
         'script_path': 'operation.sh',
         'interface_string': 'value1',
@@ -145,16 +142,16 @@ def test_local(service):
 def test_remote(service):
     interface = service.nodes['remote_node_1'].interfaces['MyInterface']
     operation = interface.operations['operation']
-    assert _values(interface.inputs) == {
+    assert parameters_as_values(interface.inputs) == {
         'interface_string': 'value1',
         'interface_integer': 1
     }
-    assert _values(operation.inputs) == {
+    assert parameters_as_values(operation.inputs) == {
         'operation_string': 'value2',
         'operation_integer': 2,
         'interface_integer': 3
     }
-    assert _values(operation.arguments) == {
+    assert parameters_as_values(operation.arguments) == {
         'process': {},
         'use_sudo': False,
         'fabric_env': {'user': '', 'password': '', 'key': None, 'key_filename': None},