CSIT-423: HC Test: delete VxLAN interface 55/3655/5
authorselias <samelias@cisco.com>
Tue, 4 Oct 2016 12:41:16 +0000 (14:41 +0200)
committerPeter Mikus <pmikus@cisco.com>
Tue, 8 Nov 2016 09:19:27 +0000 (09:19 +0000)
Modify VxLAN test cases to account for changes in Honeycomb.

Change-Id: If2db55548b5472350d128bdfbb5bdd5289e1deef
Signed-off-by: selias <samelias@cisco.com>
resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
resources/libraries/python/honeycomb/HoneycombSetup.py
resources/libraries/robot/honeycomb/interfaces.robot
resources/templates/honeycomb/oper_disabled_interfaces.url [new file with mode: 0644]
tests/func/honeycomb/030_vxlan.robot

index 559f64e..035016c 100644 (file)
@@ -164,6 +164,33 @@ class InterfaceKeywords(object):
         except (KeyError, TypeError):
             return []
 
+    @staticmethod
+    def get_disabled_interfaces_oper_data(node):
+        """Get operational data about all disabled interfaces from Honeycomb.
+
+        :param node: Honeycomb node.
+        :type node: dict
+        :return: Operational data about disabled interfaces.
+        :rtype: list
+        :raises HoneycombError: If it is not possible to get operational data.
+        """
+
+        status_code, resp = HcUtil. \
+            get_honeycomb_data(node, "oper_disabled_interfaces")
+        if status_code == HTTPCodes.NOT_FOUND:
+            raise HoneycombError(
+                "No disabled interfaces present on node."
+            )
+        if status_code != HTTPCodes.OK:
+            raise HoneycombError(
+                "Not possible to get operational information about the "
+                "interfaces. Status code: {0}.".format(status_code))
+        try:
+            return resp["disabled-interfaces"]["disabled-interface-index"]
+
+        except (KeyError, TypeError):
+            return []
+
     @staticmethod
     def get_interface_oper_data(node, interface):
         """Get operational data about the given interface from Honeycomb.
@@ -1532,3 +1559,27 @@ class InterfaceKeywords(object):
 
         interface = "{0}.{1}".format(intf, sub_if_id)
         return InterfaceKeywords.get_interface_oper_data(node, interface)
+
+    @staticmethod
+    def check_disabled_interface(node, interface):
+        """Retrieves list of disabled interface indices from Honeycomb,
+        and matches with the provided interface by index.
+
+        :param node: Honeycomb node.
+        :param interface: Index number of an interface on the node.
+        :type node: dict
+        :type interface: int
+        :return: True if the interface exists in disabled interfaces.
+        :rtype: bool
+        :raises HoneycombError: If the interface is not present
+         in retrieved list of disabled interfaces.
+         """
+        data = InterfaceKeywords.get_disabled_interfaces_oper_data(node)
+        # decrement by one = conversion from HC if-index to VPP sw_if_index
+        interface -= 1
+
+        for item in data:
+            if item["index"] == interface:
+                return True
+        raise HoneycombError("Interface index {0} not present in list"
+                             " of disabled interfaces.".format(interface))
index b8c47fa..8a05ad7 100644 (file)
@@ -265,7 +265,7 @@ class HoneycombSetup(object):
         """
 
         cmds = ("netstat -anp | grep java",
-                "ps -ef | grep karaf")
+                "ps -ef | grep [h]oneycomb")
 
         logger.info("Checking node {} ...".format(node['host']))
         for cmd in cmds:
index 706da54..a3c8a13 100644 (file)
 | | ${sw_if_index}= | EVALUATE | ${vat_data['sw_if_index']} + 1
 | | Should be equal as strings
 | | ... | ${api_data['if-index']} | ${sw_if_index}
+
+| Get Interface index from oper data
+| | [Documentation] | Retrieves interface operational data and returns\
+| | ... | if-index of the specified interface.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - interface - name of the interface. Type: string
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Get Interface index from oper data \| ${nodes['DUT1']} \| local0 \|
+| | [Arguments] | ${node} | ${interface}
+| | ${data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
+| | Return from keyword | ${data['if-index']}
+
+| Honeycomb should show disabled interface in oper data
+| | [Documentation] | Retrieves list of disabled interfaces\
+| | ... | and verifies that there is at least one.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - index - index of the interface to be checked. Type: string
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Honeycomb should show disabled interface in oper data \
+| | ... | \|${nodes['DUT1']} \| ${vx_interface} \|
+| | [Arguments] | ${node} | ${index}
+| | interfaceAPI.check disabled interface | ${node} | ${index}
+
+| Honeycomb should not show disabled interface in oper data
+| | [Documentation] | Retrieves list of disabled interfaces\
+| | ... | and expects to fail with a 404 - not found.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - index - index of the interface to be checked. Type: string
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Honeycomb should not show disabled interface in oper data \
+| | ... | \|${nodes['DUT1']} \| ${vx_interface} \|
+| | [Arguments] | ${node} | ${index}
+| | Run keyword and expect error | *
+| | ... | Honeycomb should show disabled interface in oper data
+| | ... | ${node} | ${index}
diff --git a/resources/templates/honeycomb/oper_disabled_interfaces.url b/resources/templates/honeycomb/oper_disabled_interfaces.url
new file mode 100644 (file)
index 0000000..d885c20
--- /dev/null
@@ -0,0 +1 @@
+/restconf/operational/v3po-context:disabled-interfaces
\ No newline at end of file
index 7aa77f3..a44628a 100644 (file)
 | | ... | ${node} | ${vx_interface} | ${vxlan_settings}
 | | And VxLAN configuration from VAT should be
 | | ... | ${node} | ${vxlan_settings}
+| | ${vxlan_index}= | Get Interface index from oper data
+| | ... | ${node} | ${vx_interface}
+| | Set Suite Variable | ${vxlan_index}
 
 | Honeycomb disables VxLAN tunnel
 | | [Documentation] | Check if Honeycomb API can reset VxLAN configuration.
 | | Given VxLAN configuration from Honeycomb should be
 | | ... | ${node} | ${vx_interface} | ${vxlan_settings}
+| | And Honeycomb should not show disabled interface in oper data
+| | ... | ${node} | ${vxlan_index}
 | | And VxLAN configuration from VAT should be
 | | ... | ${node} | ${vxlan_settings}
 | | When Honeycomb removes VxLAN tunnel settings | ${node} | ${vx_interface}
 | | Then VxLAN configuration from Honeycomb should be empty
 | | ... | ${node} | ${vx_interface}
+| | And Honeycomb should show disabled interface in oper data
+| | ... | ${node} | ${vxlan_index}
 | | And VxLAN configuration from VAT should be empty | ${node}
 
-Honeycomb can configure VXLAN tunnel after one has been disabled
+Honeycomb can configure VXLAN tunnel after one has been disabled
 | | [Documentation] | Check if Honeycomb API can configure VxLAN settings again\
 | | ... | after previous settings have been removed.
 | | [Teardown] | Honeycomb removes VxLAN tunnel settings
 | | ... | ${node} | ${vx_interface}
 | | Given VxLAN configuration from Honeycomb should be empty
 | | ... | ${node} | ${vx_interface}
+| | And Honeycomb should show disabled interface in oper data
+| | ... | ${node} | ${vxlan_index}
 | | And VxLAN configuration from VAT should be empty | ${node}
 | | When Honeycomb sets interface VxLAN configuration
 | | ... | ${node} | ${vx_interface} | ${vxlan_settings2}
 | | Then VxLAN configuration from Honeycomb should be
 | | ... | ${node} | ${vx_interface} | ${vxlan_settings2}
+| | And Honeycomb should not show disabled interface in oper data
+| | ... | ${node} | ${vxlan_index}
 | | And VxLAN configuration from VAT should be
 | | ... | ${node} | ${vxlan_settings2}
 

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.