ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxmrlv <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #77: ARIA-120-Builtin-workflows-relationshi...
Date Mon, 27 Mar 2017 14:16:11 GMT
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/77#discussion_r108177973
  
    --- Diff: tests/orchestrator/workflows/builtin/__init__.py ---
    @@ -13,18 +13,65 @@
     # See the License for the specific language governing permissions and
     # limitations under the License.
     
    -from tests import mock
    +from aria.orchestrator.workflows.builtin import workflows
     
     
    -def assert_node_install_operations(operations, with_relationships=False):
    -    all_operations = mock.operations.OPERATIONS_INSTALL if with_relationships else \
    -                     mock.operations.NODE_OPERATIONS_INSTALL
    -    for i, operation in enumerate(operations):
    -        assert operation.name.startswith(all_operations[i] + '.')
    +def _assert_relationships(operations, expected_op_full_name, relationships=0):
    +    """
     
    +    :param operations: and iterable of operations
    +    :param expected_op_full_name: Note that source/target doesn't really matter since
they are
    +    dropped
    +    :param relationships: the number of relationships
    +    :return:
    +    """
    +    expected_op_name = expected_op_full_name.rsplit('_', 1)[0]
    +    for _ in xrange(relationships):
    +        # Since the target and source operations start of the same way, we only need
to retrieve the
    +        # suffix once
    +        operation = next(operations)
    +        relationship_id_1 = operation.actor.id
    +        edge1 = operation.runs_on
    +        _assert_cfg_interface_op(operation, expected_op_name)
     
    -def assert_node_uninstall_operations(operations, with_relationships=False):
    -    all_operations = mock.operations.OPERATIONS_UNINSTALL if with_relationships else
\
    -                     mock.operations.NODE_OPERATIONS_UNINSTALL
    -    for i, operation in enumerate(operations):
    -        assert operation.name.startswith(all_operations[i] + '.')
    +        operation = next(operations)
    +        relationship_id_2 = operation.actor.id
    +        edge2 = operation.runs_on
    +        _assert_cfg_interface_op(operation, expected_op_name)
    +
    +        assert relationship_id_1 == relationship_id_2
    +        print '++++' + edge1, edge2
    +        assert edge1 != edge2
    +
    +
    +def assert_node_install_operations(operations, relationships=0):
    +    operations = iter(operations)
    +
    +    _assert_std_interface_op(next(operations), workflows.NORMATIVE_CREATE)
    +    _assert_relationships(operations, workflows.NORMATIVE_PRE_CONFIGURE_SOURCE, relationships)
    +    _assert_std_interface_op(next(operations), workflows.NORMATIVE_CONFIGURE)
    +    _assert_relationships(operations, workflows.NORMATIVE_POST_CONFIGURE_SOURCE, relationships)
    +    _assert_std_interface_op(next(operations), workflows.NORMATIVE_START)
    +    _assert_relationships(operations, workflows.NORMATIVE_ADD_SOURCE, relationships)
    +
    +
    +def assert_node_uninstall_operations(operations, relationships=0):
    +    operations = iter(operations)
    +
    +    _assert_std_interface_op(next(operations), workflows.NORMATIVE_STOP)
    +    _assert_relationships(operations, workflows.NORMATIVE_REMOVE_SOURCE, relationships)
    +    _assert_std_interface_op(next(operations), workflows.NORMATIVE_DELETE)
    +
    +
    +def _assert_cfg_interface_op(op, operation_name):
    +    op = op.name.split('@', 1)[0].rsplit('_', 1)[0].lower()
    +    predicted_name = \
    +        '{0}:{1}'.format(workflows.NORMATIVE_CONFIGURE_INTERFACE, operation_name).lower()
    +    assert op == predicted_name
    +
    +
    +def _assert_std_interface_op(op, operation_name):
    --- End diff --
    
    save interface_name and operation_name onto the ApiTask


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message