[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-07-06 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-ariatosca/pull/145


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-07-05 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r125753009
  
--- Diff: 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):
--- End diff --

Done. `aria.modeling.utils.parameters_as_values`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-07-05 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r125752870
  
--- Diff: 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:
--- End diff --

On second look, I disagree with your suggested test cases. The 
`instantiation` testing is supposed to test instantiation, and what you're 
suggesting is parsing. Especially when we introduce a real instantiation module 
soon, I think such tests would look very strange here.

We obviously need to test the things you mention, but they are part of 
parser testing, a huge undertaking which we have yet to begin...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-07-05 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r125752514
  
--- Diff: 
tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml 
---
@@ -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
--- End diff --

I always want to keep the Node Cellar test resource as "rich" as possible 
in all features we support, as a sanity check. If we break something, Node 
Cellar will almost always fail.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-07-05 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r125584770
  
--- Diff: 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:
--- End diff --

This seems like it covers the basic case, but there are many other 
scenarios which we might want to test as well, e.g.:
1) interface type input overridden by an operation input defined under a 
node type and not in the interface
2) interface type input overridden by an operation input in an interface 
type inheriting from this interface type
3) interface type input overridden by an operation input in an interface 
type overridden by an operation input under a node type overridden by an 
operation input under a node template
...



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-07-05 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r125582583
  
--- Diff: 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):
--- End diff --

we have this line in so many places nowadays, maybe you can find some 
common place to extract it to?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-07-05 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r125581712
  
--- Diff: 
tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml 
---
@@ -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
--- End diff --

why make this change?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-06-07 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r120597381
  
--- Diff: tests/instantiation/__init__.py ---
@@ -0,0 +1,14 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
--- End diff --

+1 for `instantiation` tests package -  even though we dont have an 
`instanitation` code package yet, this is where I too think the tests should 
reside


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-06-07 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r120597691
  
--- Diff: tests/instantiation/test_configuration.py ---
@@ -0,0 +1,48 @@
+# 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_node_cellar
--- End diff --

You should use a custom example here rather than the nodecellar one IMO.
For once, these tests shouldn't break when the nodecellar example gets 
updated for some reason.
Another reason is that it's simply not comprehensive enough - there are two 
unit tests in this module, but a lot more scenarios to cover, for example:
  1) interface input which gets overridden by an operation input
  2) interface input which gets overriden by both an operation input and a 
configuration input
  3) interface input with a default value in the `interface_types` section 
without an override in the node template's interface section for that input
...

Even if we don't cover all of them, we should cover most, and this is not 
something you want to have as part of a single main example, but rather lots of 
small yaml sections each intended for a single purpose test.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-06-06 Thread tliron
Github user tliron commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r120454702
  
--- Diff: tests/end2end/test_nodecellar.py ---
@@ -40,3 +40,21 @@ def _verify_deployed_service_in_storage(service_name, 
model_storage):
 assert service.name == service_name
 assert len(service.executions) == 0  # dry executions leave no traces
 assert len(service.nodes) == 10
+assert 
set(service.nodes['loadbalancer_host_1'].interfaces['Standard'].operations['create']
 \
--- End diff --

I created a new tests/instantiation package and put them there for now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-06-04 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/145#discussion_r120006635
  
--- Diff: tests/end2end/test_nodecellar.py ---
@@ -40,3 +40,21 @@ def _verify_deployed_service_in_storage(service_name, 
model_storage):
 assert service.name == service_name
 assert len(service.executions) == 0  # dry executions leave no traces
 assert len(service.nodes) == 10
+assert 
set(service.nodes['loadbalancer_host_1'].interfaces['Standard'].operations['create']
 \
--- End diff --

While these additions are fine, I think this JIRA really calls for unit 
tests which will check the various options for passing in arguments and verify 
everything overrides what it should and only that.
There are many such scenarios, and you don't want to test them all in e2e 
tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #145: ARIA-260 Send interface inputs as arg...

2017-06-02 Thread tliron
GitHub user tliron opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/145

ARIA-260 Send interface inputs as arguments



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-260-send-interface-inputs

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/145.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #145


commit a733be67b5c9770081d94c295c47803dbd7f3ef4
Author: Tal Liron 
Date:   2017-06-02T18:35:21Z

ARIA-260 Send interface inputs as arguments




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---