perf: refactor 'setup suite topology interfaces' 52/26652/13
authorDave Wallace <dwallacelf@gmail.com>
Thu, 23 Apr 2020 01:00:39 +0000 (01:00 +0000)
committerPeter Mikus <pmikus@cisco.com>
Thu, 7 May 2020 16:52:22 +0000 (16:52 +0000)
- and 'setup suite topology interfaces no tg' to
  use a common keyword to create suite variables
  using the required topology information.

Change-Id: I46894948bc86eb7ce72d036e5b84f09c5c1385db
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
resources/libraries/python/NodePath.py
resources/libraries/robot/shared/suite_setup.robot
tests/vpp/perf/hoststack/10ge2p1x710-eth-ip4tcpbase-ldpreload-iperf3-bps.robot
tests/vpp/perf/hoststack/10ge2p1x710-eth-ip4tcpbase-nsim-ldpreload-iperf3-bps.robot
tests/vpp/perf/hoststack/10ge2p1x710-eth-ip4tcpscale1cl10s-ldpreload-iperf3-bps.robot
tests/vpp/perf/hoststack/10ge2p1x710-eth-ip4tcpscale1cl10s-nsim-ldpreload-iperf3-bps.robot
tests/vpp/perf/hoststack/10ge2p1x710-eth-ip4udpquicbase-vppecho-bps.robot
tests/vpp/perf/hoststack/10ge2p1x710-eth-ip4udpquicscale10cl10s-vppecho-bps.robot
tests/vpp/perf/hoststack/10ge2p1x710-eth-ip4udpquicscale10cl1s-vppecho-bps.robot
tests/vpp/perf/hoststack/10ge2p1x710-eth-ip4udpquicscale1cl10s-vppecho-bps.robot

index 8ee5066..7f24b0e 100644 (file)
@@ -13,7 +13,7 @@
 
 """Path utilities library for nodes in the topology."""
 
-from resources.libraries.python.topology import Topology, NodeType
+from resources.libraries.python.topology import Topology
 
 
 class NodePath:
@@ -207,17 +207,26 @@ class NodePath:
             raise RuntimeError(u"No path for topology")
         return self._path[-2]
 
-    def compute_circular_topology(self, nodes, filter_list=None, nic_pfs=1):
+    def compute_circular_topology(self, nodes, filter_list=None, nic_pfs=1,
+                                  always_same_link=False, topo_has_tg=True):
         """Return computed circular path.
 
         :param nodes: Nodes to append to the path.
         :param filter_list: Filter criteria list.
         :param nic_pfs: Number of PF of NIC.
+        :param always_same_link: If True use always same link between two nodes
+            in path. If False use different link (if available)
+            between two nodes if one link was used before.
+        :param topo_has_tg: If True, the topology has a TG node. If False,
+            the topology consists entirely of DUT nodes.
         :type nodes: dict
         :type filter_list: list of strings
-        :type path_count: int
+        :type nic_pfs: int
+        :type always_same_link: bool
+        :type topo_has_tg: bool
         :returns: Topology information dictionary.
         :rtype: dict
+        :raises RuntimeError: If unsupported combination of parameters.
         """
         t_dict = dict()
         duts = [key for key in nodes if u"DUT" in key]
@@ -225,32 +234,54 @@ class NodePath:
         t_dict[u"duts_count"] = len(duts)
         t_dict[u"int"] = u"pf"
 
-        for idx in range(0, nic_pfs // 2):
-            self.append_node(nodes[u"TG"])
+        for _ in range(0, nic_pfs // 2):
+            if topo_has_tg:
+                self.append_node(nodes[u"TG"])
             for dut in duts:
                 self.append_node(nodes[dut], filter_list=filter_list)
-        self.append_node(nodes[u"TG"])
-        self.compute_path(always_same_link=False)
+        if topo_has_tg:
+            self.append_node(nodes[u"TG"])
+        self.compute_path(always_same_link)
 
-        n_idx = 0
-        t_idx = 1
-        d_idx = 0
+        n_idx = 0 # node index
+        t_idx = 1 # TG interface index
+        d_idx = 0 # DUT interface index
+        prev_host = None
         while True:
             interface, node = self.next_interface()
             if not interface:
                 break
-            if node[u"type"] == u"TG":
-                n_pfx = f"TG"
-                p_pfx = f"pf{t_idx}"
-                i_pfx = f"if{t_idx}"
+            if topo_has_tg and node.get(u"type") == u"TG":
+                n_pfx = f"TG" # node prefix
+                p_pfx = f"pf{t_idx}" # physical interface prefix
+                i_pfx = f"if{t_idx}" # [backwards compatible] interface prefix
                 n_idx = 0
                 t_idx = t_idx + 1
-            else:
+            elif topo_has_tg:
+                # Each node has 2 interfaces, starting with 1
+                # Calculate prefixes appropriately for current
+                # path topology nomenclature:
+                #   tg1_if1 -> dut1_if1 -> dut1_if2 ->
+                #        [dut2_if1 -> dut2_if2 ...] -> tg1_if2
                 n_pfx = f"DUT{n_idx // 2 + 1}"
                 p_pfx = f"pf{d_idx % 2 + t_idx - 1}"
                 i_pfx = f"if{d_idx % 2 + t_idx - 1}"
                 n_idx = n_idx + 1
                 d_idx = d_idx + 1
+            elif not topo_has_tg and always_same_link:
+                this_host = node.get(u"host")
+                if prev_host != this_host:
+                    # When moving to a new host in the path,
+                    # increment the node index (n_idx) and
+                    # reset DUT interface index (d_idx) to 1.
+                    n_idx = n_idx + 1
+                    d_idx = 1
+                n_pfx = f"DUT{n_idx}"
+                p_pfx = f"pf{d_idx}"
+                i_pfx = f"if{d_idx}"
+                d_idx = d_idx + 1
+            else:
+                raise RuntimeError(u"Unsupported combination of paramters")
 
             t_dict[f"{n_pfx}"] = node
             t_dict[f"{n_pfx}_{p_pfx}"] = [interface]
index 0b1c0ca..05e8fe8 100644 (file)
 | Resource | resources/libraries/robot/wrk/wrk_utils.robot
 |
 | Documentation | Suite setup keywords.
-
 *** Keywords ***
-| Setup suite topology interfaces
+| Create suite topology variables
 | | [Documentation]
-| | ... | Common suite setup for one to multiple link tests.
-| | ... |
-| | ... | Compute path for testing on given topology nodes in circular topology
-| | ... | based on interface model provided as an argument and set
-| | ... | corresponding suite variables.
+| | ... | Create suite topology variables
 | |
 | | ... | _NOTE:_ This KW sets various suite variables based on filtered
 | | ... | topology. All variables are set with also backward compatibility
 | | ... | Type: list
 | |
 | | ... | *Arguments:*
-| | ... | - ${actions} - Additional setup action. Type: list
+| | ... | - @{actions} - Additional setup action. Type: list
 | |
 | | [Arguments] | @{actions}
 | |
-| | ${nic_model_list}= | Create list | ${nic_name}
-| | &{info}= | Compute Circular Topology
-| | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
-| | ${variables}= | Get Dictionary Keys | ${info}
+| | ${variables}= | Get Dictionary Keys | ${topology_info}
 | | FOR | ${variable} | IN | @{variables}
-| | | ${value}= | Get From Dictionary | ${info} | ${variable}
+| | | ${value}= | Get From Dictionary | ${topology_info} | ${variable}
 | | | Set Suite Variable | ${${variable}} | ${value}
 | | END
 | | FOR | ${action} | IN | @{actions}
 | | | Run Keyword | Additional Suite setup Action For ${action}
 | | END
 
-| Setup suite single link no tg
+| Setup suite topology interfaces
 | | [Documentation]
-| | ... | Common suite setup for single link tests.
+| | ... | Common suite setup for one to multiple link tests.
 | | ... |
-| | ... | Compute path for testing on two given nodes in circular topology
+| | ... | Compute path for testing on given topology nodes in circular topology
 | | ... | based on interface model provided as an argument and set
 | | ... | corresponding suite variables.
 | |
-| | ... | _NOTE:_ This KW sets following suite variables:
-| | ... | - duts - List of DUT nodes
-| | ... | - duts_count - Number of DUT nodes.
-| | ... | - dut{n} - DUTx node
-| | ... | - dut{n}_if1 - 1st DUT interface.
-| | ... | - dut{n}_if1_mac - 1st DUT interface MAC address.
-| | ... | - dut{n}_if2 - 2nd DUT interface.
-| | ... | - dut{n}_if2_mac - 2nd DUT interface MAC address.
+| | ... | *Arguments:*
+| | ... | - ${actions} - Additional setup action. Type: list
+| |
+| | [Arguments] | @{actions}
+| |
+| | ${nic_model_list}= | Create list | ${nic_name}
+| | &{info}= | Compute Circular Topology
+| | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
+| | ... | always_same_link=${False} | topo_has_tg=${True}
+| | Set suite variable | &{topology_info} | &{info}
+| | Create suite topology variables | @{actions}
+
+| Setup suite topology interfaces with no TG
+| | [Documentation]
+| | ... | Common suite setup for single link tests with no traffic generator
+| | ... | node.
+| | ... |
+| | ... | Compute path for testing on given topology nodes in circular topology
+| | ... | based on interface model provided as an argument and set
+| | ... | corresponding suite variables.
 | |
 | | ... | *Arguments:*
 | | ... | - ${actions} - Additional setup action. Type: list
 | | [Arguments] | @{actions}
 | |
 | | ${nic_model_list}= | Create list | ${nic_name}
-| | ${duts}= | Get Matches | ${nodes} | DUT*
-| | FOR | ${dut} | IN | @{duts}
-| | | Append Node | ${nodes['${dut}']} | filter_list=${nic_model_list}
-| | END
-| | Append Node | ${nodes['@{duts}[0]']} | filter_list=${nic_model_list}
-| | Compute Path | always_same_link=${TRUE}
-| | FOR | ${i} | IN RANGE | 1 | ${DATAPATH_INTERFACES_MAX}
-| | | ${dutx_if} | ${dutx}= | Next Interface
-| | | Run Keyword If | '${dutx_if}' == 'None' | EXIT FOR LOOP
-| | | ${dutx_if_mac}= | Get Interface MAC | ${dutx} | ${dutx_if}
-| | | ${dutx_if_ip4_addr}= | Get Interface Ip4 | ${dutx} | ${dutx_if}
-| | | ${dutx_if_ip4_prefix_length}= | Get Interface Ip4 Prefix Length
-| | | ... | ${dutx} | ${dutx_if}
-| | | ${dut_str}= | Get Keyname For DUT | ${dutx} | ${duts}
-| | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
-| | | ... | Variable Should Exist | ${${dut_str}_if1}
-| | | ${if_name}= | Set Variable If | '${if1_status}' == 'PASS'
-| | | ... | if2 | if1
-| | | Set Suite Variable | ${${dut_str}} | ${dutx}
-| | | Set Suite Variable | ${${dut_str}_${if_name}} | ${dutx_if}
-| | | Set Suite Variable | ${${dut_str}_${if_name}_mac} | ${dutx_if_mac}
-| | | Set Suite Variable | ${${dut_str}_${if_name}_ip4_addr}
-| | | ... | ${dutx_if_ip4_addr}
-| | | Set Suite Variable | ${${dut_str}_${if_name}_ip4_prefix}
-| | | ... | ${dutx_if_ip4_prefix_length}
-| | END
-| | Run Keyword If | ${i}>${DATAPATH_INTERFACES_MAX}
-| | ... | Fatal Error | Datapath length exceeded
-| | ${duts_count}= | Get Length | ${duts}
-| | Set Suite Variable | ${duts}
-| | Set Suite Variable | ${duts_count}
-| | FOR | ${action} | IN | @{actions}
-| | | Run Keyword | Additional Suite setup Action For ${action}
-| | END
+| | &{info}= | Compute Circular Topology
+| | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
+| | ... | always_same_link=${True} | topo_has_tg=${False}
+| | Set suite variable | &{topology_info} | &{info}
+| | Create suite topology variables | @{actions}
 
 | Additional Suite Setup Action For scapy
 | | [Documentation]
index 356b9a0..4fb1ca4 100644 (file)
 | Resource | resources/libraries/robot/hoststack/hoststack.robot
 |
 | Force Tags | 3_NODE_SINGLE_LINK_TOPO | PERFTEST | HW_ENV
-
 | ... | TCP | NIC_Intel-X710 | DRV_VFIO_PCI
 | ... | RXQ_SIZE_0 | TXQ_SIZE_0 | HOSTSTACK
 | ... | LDPRELOAD | IPERF3 | 1CLIENT | 1STREAM | 1460B
 | ... | eth-ip4tcpbase-ldpreload-iperf3
 |
-| Suite Setup | Setup suite topology interfaces no tg
+| Suite Setup | Setup suite topology interfaces with no TG
 | Suite Teardown | Tear down suite | hoststack
 | Test Setup | Setup test
 | Test Teardown | Tear down test
index bdff59b..4fc23d1 100644 (file)
@@ -22,7 +22,7 @@
 | ... | NSIM | LDPRELOAD | IPERF3 | 1CLIENT | 1STREAM | 1460B
 | ... | eth-ip4tcpbase-nsim-ldpreload-iperf3
 |
-| Suite Setup | Setup suite topology interfaces no tg
+| Suite Setup | Setup suite topology interfaces with no TG
 | Suite Teardown | Tear down suite
 | Test Setup | Setup test
 | Test Teardown | Tear down test
index 84fda55..2889f23 100644 (file)
@@ -22,7 +22,7 @@
 | ... | LDPRELOAD | IPERF3 | 1CLIENT | 10STREAM | 1460B
 | ... | eth-ip4tcpscale1cl10s-ldpreload-iperf3
 |
-| Suite Setup | Setup suite topology interfaces no tg
+| Suite Setup | Setup suite topology interfaces with no TG
 | Suite Teardown | Tear down suite | hoststack
 | Test Setup | Setup test
 | Test Teardown | Tear down test
index f1c4df3..f2218d2 100644 (file)
@@ -22,7 +22,7 @@
 | ... | NSIM | LDPRELOAD | IPERF3 | 1CLIENT | 10STREAM | 1460B
 | ... | eth-ip4tcpscale1cl10s-nsim-ldpreload-iperf3
 |
-| Suite Setup | Setup suite topology interfaces no tg
+| Suite Setup | Setup suite topology interfaces with no TG
 | Suite Teardown | Tear down suite
 | Test Setup | Setup test
 | Test Teardown | Tear down test
index 63fb583..e9e66d0 100644 (file)
@@ -21,7 +21,7 @@
 | ... | RXQ_SIZE_0 | TXQ_SIZE_0 | UDP | QUIC | VPPECHO
 | ... | 1CLIENT | 1STREAM | HOSTSTACK | 1280B | eth-ip4udpquicbase-vppecho
 |
-| Suite Setup | Setup suite topology interfaces no tg
+| Suite Setup | Setup suite topology interfaces with no TG
 | Suite Teardown | Tear down suite
 | Test Setup | Setup test
 | Test Teardown | Tear down test
index 1b2318e..2d6ccef 100644 (file)
@@ -22,7 +22,7 @@
 | ... | HOSTSTACK | 10CLIENT | 10STREAM | 1280B
 | ... | eth-ip4udpquicscale10cl10s-vppecho
 |
-| Suite Setup | Setup suite topology interfaces no tg
+| Suite Setup | Setup suite topology interfaces with no TG
 | Suite Teardown | Tear down suite
 | Test Setup | Setup test
 | Test Teardown | Tear down test
index 9ce3ea3..3210ebc 100644 (file)
@@ -22,7 +22,7 @@
 | ... | HOSTSTACK | 10CLIENT | 1STREAM | 1280B
 | ... | eth-ip4udpquicscale10cl1s-vppecho
 |
-| Suite Setup | Setup suite topology interfaces no tg
+| Suite Setup | Setup suite topology interfaces with no TG
 | Suite Teardown | Tear down suite
 | Test Setup | Setup test
 | Test Teardown | Tear down test
index f9f4ee7..d91cea6 100644 (file)
@@ -22,7 +22,7 @@
 | ... | HOSTSTACK | 1CLIENT | 10STREAM | 1280B
 | ... | eth-ip4udpquicscale1cl10s-vppecho
 |
-| Suite Setup | Setup suite topology interfaces no tg
+| Suite Setup | Setup suite topology interfaces with no TG
 | Suite Teardown | Tear down suite
 | Test Setup | Setup test
 | Test Teardown | Tear down test