Convert ipv4 to use node_path 41/341/6
authorJuraj Sloboda <jsloboda@cisco.com>
Wed, 17 Feb 2016 15:59:09 +0000 (16:59 +0100)
committerStefan Kobza <skobza@cisco.com>
Fri, 19 Feb 2016 12:45:38 +0000 (12:45 +0000)
Change-Id: Ie5587d4de9accb852e8f7634c42b9ccd9292830b
Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
Signed-off-by: Stefan Kobza <skobza@cisco.com>
resources/libraries/python/IPv4Util.py
resources/libraries/robot/ipv4.robot
tests/suites/ipv4/ipv4_untagged.robot

index 30e185c..98c089f 100644 (file)
@@ -142,3 +142,35 @@ class IPv4Util(object):
         :return:
         """
         get_node(node).flush_ip_addresses(port)
+
+    @staticmethod
+    def get_link_address(link, nodes_addr):
+        """Get link IPv4 address.
+
+        :param link: Link name.
+        :param nodes_addr: Available nodes IPv4 adresses.
+        :type link: str
+        :type nodes_addr: dict
+        :return: Link IPv4 address.
+        :rtype: str
+        """
+        net = nodes_addr.get(link)
+        if net is None:
+            raise ValueError('Link "{0}" not found'.format(link))
+        return net.get('net_addr')
+
+    @staticmethod
+    def get_link_prefix(link, nodes_addr):
+        """Get link IPv4 address prefix.
+
+        :param link: Link name.
+        :param nodes_addr: Available nodes IPv4 adresses.
+        :type link: str
+        :type nodes_addr: dict
+        :return: Link IPv4 address prefix.
+        :rtype: int
+        """
+        net = nodes_addr.get(link)
+        if net is None:
+            raise ValueError('Link "{0}" not found'.format(link))
+        return net.get('prefix')
index c271de5..0cfb73b 100644 (file)
@@ -15,6 +15,8 @@
 | Resource | resources/libraries/robot/counters.robot
 | Library | resources.libraries.python.IPv4Util.IPv4Util
 | Library | resources.libraries.python.IPv4Setup.IPv4Setup
+| Library | resources.libraries.python.NodePath
+| Library | resources.libraries.python.Routing
 | Library | resources.libraries.python.TrafficScriptExecutor
 | Variables | resources/libraries/python/IPv4NodeAddress.py | ${nodes}
 
 | | VPP nodes setup ipv4 addresses | ${nodes} | ${nodes_addr}
 
 | Routes are set up for IPv4 testing
-| | ${gateway}= | Get IPv4 address of node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port3']['name']}" from "${nodes_ipv4_addr}"
-| | ${subnet} = | Get IPv4 subnet of node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port1']['name']}" from "${nodes_ipv4_addr}"
-| | ${prefix_length} = | Get IPv4 address prefix of node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port1']['name']}" from "${nodes_ipv4_addr}"
-| | Node "${nodes['DUT1']}" routes to IPv4 network "${subnet}" with prefix length "${prefix_length}" using interface "${nodes['DUT1']['interfaces']['port3']['name']}" via "${gateway}"
-| | ${gateway} = | Get IPv4 address of node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port3']['name']}" from "${nodes_ipv4_addr}"
-| | ${subnet} = | Get IPv4 subnet of node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port1']['name']}" from "${nodes_ipv4_addr}"
-| | ${prefix_length} = | Get IPv4 address prefix of node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port1']['name']}" from "${nodes_ipv4_addr}"
-| | Node "${nodes['DUT2']}" routes to IPv4 network "${subnet}" with prefix length "${prefix_length}" using interface "${nodes['DUT2']['interfaces']['port3']['name']}" via "${gateway}"
+| | [Documentation] | Setup routing on all VPP nodes required for IPv4 tests
+| | [Arguments] | ${nodes} | ${nodes_addr}
+| | Append Nodes | ${nodes['DUT1']} | ${nodes['DUT2']}
+| | Compute Path
+| | ${tg}= | Set Variable | ${nodes['TG']}
+| | ${dut1_if} | ${dut1}= | First Interface
+| | ${dut2_if} | ${dut2}= | Last Interface
+| | ${dut1_if_addr}= | Get IPv4 address of node "${dut1}" interface "${dut1_if}" from "${nodes_addr}"
+| | ${dut2_if_addr}= | Get IPv4 address of node "${dut2}" interface "${dut2_if}" from "${nodes_addr}"
+| | @{tg_dut1_links}= | Get active links connecting "${tg}" and "${dut1}"
+| | @{tg_dut2_links}= | Get active links connecting "${tg}" and "${dut2}"
+| | :FOR | ${link} | IN | @{tg_dut1_links}
+| | | ${net}= | Get Link Address | ${link} | ${nodes_addr}
+| | | ${prefix}= | Get Link Prefix | ${link} | ${nodes_addr}
+| | | Vpp Route Add | ${dut2} | ${net} | ${prefix} | ${dut1_if_addr} | ${dut2_if}
+| | :FOR | ${link} | IN | @{tg_dut2_links}
+| | | ${net}= | Get Link Address | ${link} | ${nodes_addr}
+| | | ${prefix}= | Get Link Prefix | ${link} | ${nodes_addr}
+| | | Vpp Route Add | ${dut1} | ${net} | ${prefix} | ${dut2_if_addr} | ${dut1_if}
 
 | Setup DUT nodes for IPv4 testing
-| | Interfaces needed for IPv4 testing are in "up" state
-| | Setup IPv4 adresses on all DUT nodes in topology | ${nodes} | ${nodes_ipv4_addr}
-| | Setup ARP on all DUTs | ${nodes}
-| | Routes are set up for IPv4 testing
-
-| Setup nodes for IPv4 testing
 | | Setup IPv4 adresses on all DUT nodes in topology | ${nodes} | ${nodes_ipv4_addr}
 | | Setup ARP on all DUTs | ${nodes} | ${nodes_ipv4_addr}
-| | Routes are set up for IPv4 testing
+| | Routes are set up for IPv4 testing | ${nodes} | ${nodes_ipv4_addr}
 | | Sleep | 10
 
 | TG interface "${tg_port}" can route to node "${node}" interface "${port}" "${hops}" hops away using IPv4
 | | Node "${nodes['TG']}" interface "${tg_port}" can route to node "${node}" interface "${port}" "${hops}" hops away using IPv4
 
-| Node "${from_node}" interface "${from_port}" can route to node "${to_node}" interface "${to_port}" "${hops}" hops away using IPv4
+| Node "${from_node}" interface "${from_port}" can route to node "${to_node}" interface "${to_port}" ${hops} hops away using IPv4
 | | ${src_ip}= | Get IPv4 address of node "${from_node}" interface "${from_port}" from "${nodes_ipv4_addr}"
 | | ${dst_ip}= | Get IPv4 address of node "${to_node}" interface "${to_port}" from "${nodes_ipv4_addr}"
 | | ${src_mac}= | Get interface mac | ${from_node} | ${from_port}
index ed95740..ccf1551 100644 (file)
 # limitations under the License.
 
 *** Settings ***
-| Documentation | TODO: rewrite with generic path keywords
 | Library | resources.libraries.python.topology.Topology
+| Library | resources.libraries.python.NodePath
 | Resource | resources/libraries/robot/default.robot
 | Resource | resources/libraries/robot/ipv4.robot
 | Suite Setup | Run Keywords | Setup all DUTs before test
 | ...         | AND          | Setup all TGs before traffic script
 | ...         | AND          | Update All Interface Data On All Nodes | ${nodes}
-| ...         | AND          | Setup nodes for IPv4 testing
+| ...         | AND          | Setup DUT nodes for IPv4 testing
 | Test Setup | Clear interface counters on all vpp nodes in topology | ${nodes}
 
 *** Test Cases ***
 
 | VPP replies to ICMPv4 echo request
-| | TG interface "${nodes['TG']['interfaces']['port3']['name']}" can route to node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port1']['name']}" "0" hops away using IPv4
-| | Vpp dump stats table | ${nodes['DUT1']}
-| | Check ipv4 interface counter | ${nodes['DUT1']} | ${nodes['DUT1']['interfaces']['port1']['name']} | ${1}
+| | Append Nodes | ${nodes['TG']} | ${nodes['DUT1']}
+| | Compute Path
+| | ${src_port} | ${src_node}= | First Interface
+| | ${dst_port} | ${dst_node}= | Last Interface
+| | ${hops}= | Set Variable | ${0}
+| | Node "${src_node}" interface "${src_port}" can route to node "${dst_node}" interface "${dst_port}" ${hops} hops away using IPv4
 
 | TG can route to DUT egress interface
-| | TG interface "${nodes['TG']['interfaces']['port3']['name']}" can route to node "${nodes['DUT1']}" interface "${nodes['DUT1']['interfaces']['port3']['name']}" "0" hops away using IPv4
-| | Vpp dump stats table | ${nodes['DUT1']}
-| | Check ipv4 interface counter | ${nodes['DUT1']} | ${nodes['DUT1']['interfaces']['port1']['name']} | ${1}
+| | Append Nodes | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['DUT2']}
+| | Compute Path
+| | ${src_port} | ${src_node}= | First Interface
+| | ${dst_port} | ${dst_node}= | Last Egress Interface
+| | ${hops}= | Set Variable | ${0}
+| | Node "${src_node}" interface "${src_port}" can route to node "${dst_node}" interface "${dst_port}" ${hops} hops away using IPv4
 
 | TG can route to DUT2 through DUT1
-| | TG interface "${nodes['TG']['interfaces']['port3']['name']}" can route to node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port3']['name']}" "1" hops away using IPv4
-| | Vpp dump stats table | ${nodes['DUT1']}
-| | Check ipv4 interface counter | ${nodes['DUT1']} | ${nodes['DUT1']['interfaces']['port1']['name']} | ${1}
-| | Check ipv4 interface counter | ${nodes['DUT1']} | ${nodes['DUT1']['interfaces']['port3']['name']} | ${1}
-| | Vpp dump stats table | ${nodes['DUT2']}
-| | Check ipv4 interface counter | ${nodes['DUT2']} | ${nodes['DUT2']['interfaces']['port3']['name']} | ${1}
+| | Append Nodes | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['DUT2']}
+| | Compute Path
+| | ${src_port} | ${src_node}= | First Interface
+| | ${dst_port} | ${dst_node}= | Last Interface
+| | ${hops}= | Set Variable | ${1}
+| | Node "${src_node}" interface "${src_port}" can route to node "${dst_node}" interface "${dst_port}" ${hops} hops away using IPv4
 
 | TG can route to DUT2 egress interface through DUT1
-| | TG interface "${nodes['TG']['interfaces']['port3']['name']}" can route to node "${nodes['DUT2']}" interface "${nodes['DUT2']['interfaces']['port1']['name']}" "1" hops away using IPv4
-| | Vpp dump stats table | ${nodes['DUT1']}
-| | Check ipv4 interface counter | ${nodes['DUT1']} | ${nodes['DUT1']['interfaces']['port1']['name']} | ${1}
-| | Check ipv4 interface counter | ${nodes['DUT1']} | ${nodes['DUT1']['interfaces']['port3']['name']} | ${1}
-| | Vpp dump stats table | ${nodes['DUT2']}
-| | Check ipv4 interface counter | ${nodes['DUT2']} | ${nodes['DUT2']['interfaces']['port3']['name']} | ${1}
+| | Append Nodes | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['DUT2']} | ${nodes['TG']}
+| | Compute Path
+| | ${src_port} | ${src_node}= | First Interface
+| | ${dst_port} | ${dst_node}= | Last Egress Interface
+| | ${hops}= | Set Variable | ${1}
+| | Node "${src_node}" interface "${src_port}" can route to node "${dst_node}" interface "${dst_port}" ${hops} hops away using IPv4
 
 | TG can route to TG through DUT1 and DUT2
-| | TG interface "${nodes['TG']['interfaces']['port3']['name']}" can route to node "${nodes['TG']}" interface "${nodes['TG']['interfaces']['port5']['name']}" "2" hops away using IPv4
-| | Vpp dump stats table | ${nodes['DUT1']}
-| | Check ipv4 interface counter | ${nodes['DUT1']} | ${nodes['DUT1']['interfaces']['port1']['name']} | ${1}
-| | Check ipv4 interface counter | ${nodes['DUT1']} | ${nodes['DUT1']['interfaces']['port3']['name']} | ${1}
-| | Vpp dump stats table | ${nodes['DUT2']}
-| | Check ipv4 interface counter | ${nodes['DUT2']} | ${nodes['DUT2']['interfaces']['port3']['name']} | ${1}
-| | Check ipv4 interface counter | ${nodes['DUT2']} | ${nodes['DUT2']['interfaces']['port1']['name']} | ${1}
+| | Append Nodes | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['DUT2']} | ${nodes['TG']}
+| | Compute Path
+| | ${src_port} | ${src_node}= | First Interface
+| | ${dst_port} | ${dst_node}= | Last Interface
+| | ${hops}= | Set Variable | ${2}
+| | Node "${src_node}" interface "${src_port}" can route to node "${dst_node}" interface "${dst_port}" ${hops} hops away using IPv4
+| | ${port} | ${node}= | Next Interface
+| | ${port} | ${node}= | Next Interface
+| | ${exp_counter_val}= | Set Variable | ${1}
+| | Vpp dump stats table | ${node}
+| | Check ipv4 interface counter | ${node} | ${port} | ${exp_counter_val}
+| | ${port} | ${node}= | Next Interface
+| | Check ipv4 interface counter | ${node} | ${port} | ${exp_counter_val}
+| | ${port} | ${node}= | Next Interface
+| | Vpp dump stats table | ${node}
+| | Check ipv4 interface counter | ${node} | ${port} | ${exp_counter_val}
+| | ${port} | ${node}= | Next Interface
+| | Check ipv4 interface counter | ${node} | ${port} | ${exp_counter_val}
 
 | VPP can process ICMP echo request from min to max packet size with 1B increment
 | | Ipv4 icmp echo sweep | ${nodes['TG']} | ${nodes['DUT1']}