HC2VPP-331: Fix Honeycomb fails to assign VRF to interface 20/13120/4
authorMichal Cmarada <michal.cmarada@pantheon.tech>
Thu, 21 Jun 2018 07:53:08 +0000 (09:53 +0200)
committerJan Gelety <jgelety@cisco.com>
Thu, 21 Jun 2018 11:33:11 +0000 (11:33 +0000)
- add configuration for FIB table management to test suite
- fix routing test suite HC2VPP-331 bugs
- fix intip4-intip6 test suite HC2VPP-331 bugs

Change-Id: I0b1e9ed787d9fb68e76a6d61c1eea2519a36a6c4
Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>
resources/libraries/python/honeycomb/FIB.py [new file with mode: 0644]
resources/libraries/robot/honeycomb/fib.robot [new file with mode: 0644]
resources/templates/honeycomb/config_fib_table.url [new file with mode: 0644]
resources/templates/honeycomb/oper_fib_table.url [new file with mode: 0644]
tests/honeycomb/func/mgmt-cfg-intip4-intip6-apihc-apivat-func.robot
tests/honeycomb/func/mgmt-cfg-routing-apihc-apivat-func.robot

diff --git a/resources/libraries/python/honeycomb/FIB.py b/resources/libraries/python/honeycomb/FIB.py
new file mode 100644 (file)
index 0000000..a5e8ba9
--- /dev/null
@@ -0,0 +1,139 @@
+# Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+# Licensed 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.
+
+"""This module implements keywords to manipulate FIB tables using
+Honeycomb REST API."""
+
+from robot.api import logger
+
+from resources.libraries.python.HTTPRequest import HTTPCodes
+from resources.libraries.python.honeycomb.HoneycombSetup import HoneycombError
+from resources.libraries.python.honeycomb.HoneycombUtil \
+    import DataRepresentation
+from resources.libraries.python.honeycomb.HoneycombUtil \
+    import HoneycombUtil as HcUtil
+
+
+class FibKeywords(object):
+    """Implementation of keywords which make it possible to:
+    - add/remove FIB tables,
+    - add/remove FIB table entries
+    - get operational data about FIB tables,
+    """
+
+    def __init__(self):
+        pass
+
+    @staticmethod
+    def _set_fib_table_properties(node, path, data=None):
+        """Set FIB table properties and check the return code.
+
+        :param node: Honeycomb node.
+        :param path: Path which is added to the base path to identify the data.
+        :param data: The new data to be set. If None, the item will be removed.
+        :type node: dict
+        :type path: str
+        :type data: dict
+        :returns: Content of response.
+        :rtype: bytearray
+        :raises HoneycombError: If the status code in response is not
+        200 = OK.
+        """
+
+        if data:
+            status_code, resp = HcUtil. \
+                put_honeycomb_data(node, "config_fib_table", data, path,
+                                   data_representation=DataRepresentation.JSON)
+        else:
+            status_code, resp = HcUtil. \
+                delete_honeycomb_data(node, "config_fib_table", path)
+
+        if status_code not in (HTTPCodes.OK, HTTPCodes.ACCEPTED):
+            if data is None and '"error-tag":"data-missing"' in resp:
+                logger.debug("data does not exist in path.")
+            else:
+                raise HoneycombError(
+                    "The configuration of FIB table was not successful. "
+                    "Status code: {0}.".format(status_code))
+        return resp
+
+    @staticmethod
+    def configure_fib_table(node, ip_version, vrf=1):
+        """Configure a FIB table according to the data provided.
+
+        :param node: Honeycomb node.
+        :param ip_version: IP protocol version, ipv4 or ipv6.
+        :param vrf: vrf-id to attach configuration to.
+        :type node: dict
+        :type ip_version: str
+        :type vrf: int
+        :returns: Content of response.
+        :rtype: bytearray
+        """
+        full_data = {
+            "vpp-fib-table-management:table": [
+                {
+                    "table-id": vrf,
+                    "address-family": "vpp-fib-table-management:{0}"
+                    .format(ip_version),
+                    "name": "{0}-VRF:{1}".format(ip_version, vrf)
+                }
+            ]
+        }
+        path = "/table/{0}/vpp-fib-table-management:{1}".format(vrf, ip_version)
+        return FibKeywords._set_fib_table_properties(node, path, full_data)
+
+    @staticmethod
+    def delete_fib_table(node, ip_version, vrf=1):
+        """Delete the specified FIB table from configuration data.
+
+        :param node: Honeycomb node.
+        :param ip_version: IP protocol version, ipv4 or ipv6.
+        :param vrf: vrf-id to attach configuration to.
+        :type node: dict
+        :type ip_version: str
+        :type vrf: int
+        :returns: Content of response.
+        :rtype: bytearray
+        """
+
+        path = "/table/{0}/vpp-fib-table-management:{1}".format(vrf, ip_version)
+        return FibKeywords._set_fib_table_properties(node, path)
+
+    @staticmethod
+    def get_fib_table_oper(node, ip_version, vrf=1):
+        """Retrieve operational data about the specified FIB table.
+
+        :param node: Honeycomb node.
+        :param ip_version: IP protocol version, ipv4 or ipv6.
+        :param vrf: vrf-id to attach configuration to.
+        :type node: dict
+        :type ip_version: str
+        :type vrf: int
+        :returns: FIB table operational data.
+        :rtype: list
+        :raises HoneycombError: If the operation fails.
+        """
+
+        path = "/table/{0}/vpp-fib-table-management:{1}".format(vrf, ip_version)
+        status_code, resp = HcUtil. \
+            get_honeycomb_data(node, "oper_fib_table", path)
+
+        if status_code != HTTPCodes.OK:
+            raise HoneycombError(
+                "Not possible to get operational information about the "
+                "FIB tables. Status code: {0}.".format(status_code))
+
+        data = resp['vpp-fib-table-management:table'][0]
+
+        return data
diff --git a/resources/libraries/robot/honeycomb/fib.robot b/resources/libraries/robot/honeycomb/fib.robot
new file mode 100644 (file)
index 0000000..8209db7
--- /dev/null
@@ -0,0 +1,67 @@
+# Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+# Licensed 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.
+
+*** Settings ***
+| Library | resources.libraries.python.honeycomb.FIB.FibKeywords
+| Documentation | Keywords used to test Honeycomb FIB tables.
+
+*** Keywords ***
+| Honeycomb configures FIB table
+| | [Documentation] | Uses Honeycomb API to configure a FIB table.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type:string
+| | ... | - vrf - vrf-id the new table will belong to. Type: integer
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Honeycomb configures FIB table \| ${nodes['DUT1']} \
+| | ... | \| ipv4 \| ${vrf} \|
+| | [Arguments] | ${node} | ${ip_version} | ${vrf}
+| | Configure FIB table | ${node} | ${ip_version} | ${vrf}
+
+| FIB table data from Honeycomb should contain
+| | [Documentation] | Uses Honeycomb API to retrieve operational data about\
+| | ... | a FIB table, and compares with the data provided.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type:string
+| | ... | - vrf - vrf-id the new table will belong to. Type: integer
+| | ... | - expected_data - Data to compare against. Type: dictionary
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| FIB table data from Honeycomb should contain \| ${nodes['DUT1']} \
+| | ... | \| ipv4 \| ${data} \|
+| | [Arguments] | ${node} | ${ip_version} | ${vrf} | ${expected_data}
+| | ${data}= | Get FIB Table Oper | ${node} | ${ip_version} | ${vrf}
+| | Should Contain | ${data} | ${expected_data}
+
+| Honeycomb removes FIB configuration
+| | [Documentation] | Uses Honeycomb API to remove Honeycomb-created\
+| | ... | FIB configuration from the node. Entries configured automatically\
+| | ... | by VPP will not be removed.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - information about a DUT node. Type: dictionary
+| | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type:string
+| | ... | - vrf - vrf-id the new table will belong to. Type: integer
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Honeycomb removes FIB configuration \| ${nodes['DUT1']} \
+| | ... | \| ${ip_version} \| ${vrf} \|
+| | [Arguments] | ${node} | ${ip_version} | ${vrf}
+| | Delete FIB table | ${node} | ${ip_version} | ${vrf}
diff --git a/resources/templates/honeycomb/config_fib_table.url b/resources/templates/honeycomb/config_fib_table.url
new file mode 100644 (file)
index 0000000..5b9175f
--- /dev/null
@@ -0,0 +1 @@
+/restconf/config{odl_url_part}/vpp-fib-table-management:fib-table-management/vpp-fib-table-management:fib-tables
\ No newline at end of file
diff --git a/resources/templates/honeycomb/oper_fib_table.url b/resources/templates/honeycomb/oper_fib_table.url
new file mode 100644 (file)
index 0000000..19760c9
--- /dev/null
@@ -0,0 +1 @@
+/restconf/operational{odl_url_part}/vpp-fib-table-management:fib-table-management/vpp-fib-table-management:fib-tables
\ No newline at end of file
index c8f072b..b532b50 100644 (file)
@@ -20,6 +20,7 @@
 | Resource | resources/libraries/robot/shared/default.robot
 | Resource | resources/libraries/robot/honeycomb/interfaces.robot
 | Resource | resources/libraries/robot/honeycomb/honeycomb.robot
+| Resource | resources/libraries/robot/honeycomb/fib.robot
 | Resource | resources/libraries/robot/shared/testing_path.robot
 | Resource | resources/libraries/robot/ip/ip6.robot
 | Variables | resources/test_data/honeycomb/interface_ip.py
 | | [Documentation] | Check if Honeycomb API can configure interface\
 | | ... | vrf ID.
 | | ...
-# HC2VPP-331: Honeycomb fails to assign VRF to interface
-| | [Tags] | EXPECTED_FAILING
-| | ...
-| | [Teardown] | Honeycomb sets interface VRF ID
-| | ... | ${node} | ${interface} | ${0} | ipv4
+| | [Teardown] | Honeycomb interface VRF Test Teardown | ${node} | ${interface}
 | | ...
+| | Honeycomb configures FIB table | ${node} | ipv4 | ${1}
 | | When Honeycomb sets interface VRF ID
 | | ... | ${node} | ${interface} | ${1} | ipv4
 | | Then Interface VRF ID from Honeycomb should be
 | | Honeycomb removes interface IPv4 addresses | ${node} | ${interface}
 | | Honeycomb removes interface IPv6 addresses | ${node} | ${interface}
 | | Honeycomb clears all interface IPv4 neighbors | ${node} | ${interface}
-| | Honeycomb clears all interface IPv6 neighbors | ${node} | ${interface}
\ No newline at end of file
+| | Honeycomb clears all interface IPv6 neighbors | ${node} | ${interface}
+
+| Honeycomb interface VRF Test Teardown
+| | [Arguments] | ${node} | ${interface}
+| | Honeycomb sets interface VRF ID | ${node} | ${interface} | ${0} | ipv4
+| | Honeycomb removes FIB configuration | ${node} | ipv4 | ${1}
index 24688b9..b690c04 100644 (file)
@@ -14,6 +14,7 @@
 *** Settings ***
 | Library | resources.libraries.python.honeycomb.Routing.RoutingKeywords
 | Library | resources.libraries.python.Trace
+| Library | resources.libraries.python.InterfaceUtil
 | Resource | resources/libraries/robot/shared/default.robot
 | Resource | resources/libraries/robot/shared/testing_path.robot
 | Resource | resources/libraries/robot/ip/ip4.robot
@@ -21,6 +22,7 @@
 | Resource | resources/libraries/robot/honeycomb/honeycomb.robot
 | Resource | resources/libraries/robot/honeycomb/interfaces.robot
 | Resource | resources/libraries/robot/honeycomb/routing.robot
+| Resource | resources/libraries/robot/honeycomb/fib.robot
 | ...
 | Test Setup | Clear Packet Trace on All DUTs | ${nodes}
 | ...
@@ -44,9 +46,6 @@
 | | ... | [Ver] Send ICMP packet from first TG interface to configured route
 | | ... | destination. Receive packet on the second TG interface.
 | | ...
-# HC2VPP-331: Honeycomb fails to assign VRF to interface
-| | [Tags] | EXPECTED_FAILING
-| | ...
 | | ${table}= | Set Variable | table1
 | | Given Setup interfaces and neighbors for IPv4 routing test
 | | When Honeycomb configures routing table
@@ -69,9 +68,6 @@
 | | ... | verify that each destination MAC was used by exactly 50 packets.
 | | ... | Receive packet on the second TG interface.
 | | ...
-# HC2VPP-331: Honeycomb fails to assign VRF to interface
-| | [Tags] | EXPECTED_FAILING
-| | ...
 | | ${table}= | Set Variable | table2
 | | Given Setup interfaces and neighbors for IPv4 routing test
 | | And Honeycomb adds interface IPv4 neighbor | ${dut_node} | ${dut_to_tg_if2}
@@ -79,9 +75,6 @@
 | | And Honeycomb adds interface IPv4 neighbor | ${dut_node} | ${dut_to_tg_if2}
 | | ... | ${next_hop2} | ${next_hop_mac2}
 | | ...
-# HC2VPP-331: Honeycomb fails to assign VRF to interface
-| | [Tags] | EXPECTED_FAILING
-| | ...
 | | When Honeycomb configures routing table
 | | ... | ${node} | table2 | ipv4 | ${table2} | ${1}
 | | Then Routing data from Honeycomb should contain
 | | ... | destination. Make sure no packet is received on the second TG\
 | | ... | interface.
 | | ...
-# HC2VPP-331: Honeycomb fails to assign VRF to interface
-| | [Tags] | EXPECTED_FAILING
-| | ...
 | | ${table}= | Set Variable | table3
 | | Given Setup interfaces and neighbors for IPv4 routing test
 | | When Honeycomb configures routing table
 | | ... | [Ver] Send ICMP packet from first TG interface to configured route
 | | ... | destination. Receive packet on the second TG interface.
 | | ...
-# HC2VPP-331: Honeycomb fails to assign VRF to interface
-| | [Tags] | EXPECTED_FAILING
-| | ...
 | | ${table}= | Set Variable | table4
 | | Given Setup interfaces and neighbors for IPv6 routing test
 | | When Honeycomb configures routing table
 | | ... | verify that each destination MAC was used by exactly 50 packets.
 | | ... | Receive packet on the second TG interface.
 | | ...
-# HC2VPP-331: Honeycomb fails to assign VRF to interface
-| | [Tags] | EXPECTED_FAILING
-| | ...
 | | ${table}= | Set Variable | table5
 | | Given Setup interfaces and neighbors for IPv6 routing test
 | | And Honeycomb adds interface IPv6 neighbor | ${dut_node} | ${dut_to_tg_if2}
 | | ... | destination. Make sure no packet is received on the second TG\
 | | ... | interface.
 | | ...
-# HC2VPP-254 Operational data for Blackhole IPv6 route is incorrect
-| | [Tags] | EXPECTED_FAILING
 | | ${table}= | Set Variable | table6
 | | Given Setup interfaces and neighbors for IPv6 routing test
 | | When Honeycomb configures routing table
 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
 | | Import Variables | resources/test_data/honeycomb/routing.py
 | | ... | ${nodes['DUT1']} | ipv4 | ${dut_to_tg_if2}
+| | Setup vrf FIBs | ${dut_node} | ${1}
 | | Setup vrf IDs | ${dut_node} | ${dut_to_tg_if1} | ${1}
 | | Setup vrf IDs | ${dut_node} | ${dut_to_tg_if2} | ${1}
 | | Honeycomb configures interface state | ${dut_node} | ${dut_to_tg_if1} | up
 | | Honeycomb configures interface state | ${dut_node} | ${dut_to_tg_if2} | up
+| | Vpp Node Interfaces Ready Wait | ${dut_node}
 | | Honeycomb sets interface IPv4 address with prefix | ${dut_node}
 | | ... | ${dut_to_tg_if1} | ${dut_to_tg_if1_ip} | ${prefix_len}
 | | Honeycomb sets interface IPv4 address with prefix | ${dut_node}
 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
 | | Import Variables | resources/test_data/honeycomb/routing.py
 | | ... | ${nodes['DUT1']} | ipv6 | ${dut_to_tg_if2}
-| | Honeycomb sets interface VRF ID
-| | ... | ${dut_node} | ${dut_to_tg_if1} | ${1} | ipv6
-| | Honeycomb sets interface VRF ID
-| | ... | ${dut_node} | ${dut_to_tg_if2} | ${1} | ipv6
+| | Setup vrf FIBs | ${dut_node} | ${1}
+| | Setup vrf IDs | ${dut_node} | ${dut_to_tg_if1} | ${1}
+| | Setup vrf IDs | ${dut_node} | ${dut_to_tg_if2} | ${1}
 | | Honeycomb configures interface state | ${dut_node} | ${dut_to_tg_if1} | up
 | | Honeycomb configures interface state | ${dut_node} | ${dut_to_tg_if2} | up
+| | Vpp Node Interfaces Ready Wait | ${dut_node}
 | | Honeycomb sets interface IPv6 address | ${dut_node}
 | | ... | ${dut_to_tg_if1} | ${dut_to_tg_if1_ip} | ${prefix_len}
 | | Honeycomb sets interface IPv6 address | ${dut_node}
 | | Show Packet Trace on All DUTs | ${nodes}
 | | Log routing configuration from VAT | ${node}
 | | Honeycomb removes routing configuration | ${node} | ${routing_table}
+| | Remove vrf FIBs | ${node} | ${1}
 
 | Setup vrf IDs
 | | ...
 | | Honeycomb sets interface VRF ID
 | | ... | ${node} | ${interface} | ${vrf} | ipv4
 | | Honeycomb sets interface VRF ID
-| | ... | ${node} | ${interface} | ${vrf} | ipv6
\ No newline at end of file
+| | ... | ${node} | ${interface} | ${vrf} | ipv6
+
+| Setup vrf FIBs
+| | ...
+| | [Arguments] | ${node} | ${vrf}
+| | ...
+| | Honeycomb configures FIB table | ${node} | ipv4 | ${vrf}
+| | Honeycomb configures FIB table | ${node} | ipv6 | ${vrf}
+
+| Remove vrf FIBs
+| | ...
+| | [Arguments] | ${node} | ${vrf}
+| | ...
+| | Honeycomb removes FIB configuration | ${node} | ipv4 | ${vrf}
+| | Honeycomb removes FIB configuration | ${node} | ipv6 | ${vrf}

©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.