diff options
author | Viliam Luc <vluc@cisco.com> | 2021-08-02 14:25:26 +0200 |
---|---|---|
committer | Viliam Luc <vluc@cisco.com> | 2021-09-10 10:26:24 +0200 |
commit | ec467277744783015a2da6713298b35d13d92e6f (patch) | |
tree | 57b1bb084f5ae9c6346be5a92f8fe5fac38f1cd4 /resources/libraries/python/NodePath.py | |
parent | 9cceefae3248e9a1e9e5586391c9263cf114a753 (diff) |
back-to-back tests: add TG tests
Change-Id: I9d028294deb1e31b6d185deb1c7523e0226a0ada
Signed-off-by: Viliam Luc <vluc@cisco.com>
Diffstat (limited to 'resources/libraries/python/NodePath.py')
-rw-r--r-- | resources/libraries/python/NodePath.py | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/resources/libraries/python/NodePath.py b/resources/libraries/python/NodePath.py index cc91c4a2f5..d1f974aafe 100644 --- a/resources/libraries/python/NodePath.py +++ b/resources/libraries/python/NodePath.py @@ -92,7 +92,7 @@ class NodePath: self._path = [] self._path_iter = [] - def compute_path(self, always_same_link=True): + def compute_path(self, always_same_link=True, topo_has_dut=True): """Compute path for added nodes. .. note:: First add at least two nodes to the topology. @@ -100,19 +100,26 @@ class NodePath: :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_dut: If False we want to test back to back test on TG. :type always_same_link: bool + :type topo_has_dut: bool :raises RuntimeError: If not enough nodes for path. """ nodes = self._nodes - if len(nodes) < 2: + if len(nodes) < 2 and topo_has_dut: raise RuntimeError(u"Not enough nodes to compute path") for idx in range(0, len(nodes) - 1): topo = Topology() node1 = nodes[idx] - node2 = nodes[idx + 1] n1_list = self._nodes_filter[idx] - n2_list = self._nodes_filter[idx + 1] + if topo_has_dut: + node2 = nodes[idx + 1] + n2_list = self._nodes_filter[idx + 1] + else: + node2 = node1 + n2_list = n1_list + links = topo.get_active_connecting_links( node1, node2, filter_list_node1=n1_list, filter_list_node2=n2_list @@ -139,8 +146,11 @@ class NodePath: link = l_set[0] self._links.append(link) + + use_subsequent = not topo_has_dut interface1 = topo.get_interface_by_link_name(node1, link) - interface2 = topo.get_interface_by_link_name(node2, link) + interface2 = topo.get_interface_by_link_name(node2, link, + use_subsequent) self._path.append((interface1, node1)) self._path.append((interface2, node2)) @@ -208,7 +218,7 @@ class NodePath: return self._path[-2] def compute_circular_topology(self, nodes, filter_list=None, nic_pfs=1, - always_same_link=False, topo_has_tg=True): + always_same_link=False, topo_has_tg=True, topo_has_dut=True): """Return computed circular path. :param nodes: Nodes to append to the path. @@ -219,29 +229,34 @@ class NodePath: 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. + :param topo_has_dut: If True, the topology has a DUT node(s). If False, + the topology consists entirely of TG nodes. :type nodes: dict :type filter_list: list of strings :type nic_pfs: int :type always_same_link: bool :type topo_has_tg: bool + :type topo_has_dut: 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] - t_dict[u"duts"] = duts - t_dict[u"duts_count"] = len(duts) - t_dict[u"int"] = u"pf" + if topo_has_dut: + duts = [key for key in nodes if u"DUT" in key] + t_dict[u"duts"] = duts + t_dict[u"duts_count"] = len(duts) + t_dict[u"int"] = u"pf" 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) + if topo_has_dut: + for dut in duts: + self.append_node(nodes[dut], filter_list=filter_list) if topo_has_tg: self.append_node(nodes[u"TG"]) - self.compute_path(always_same_link) + self.compute_path(always_same_link, topo_has_dut) n_idx = 0 # node index t_idx = 1 # TG interface index @@ -257,7 +272,7 @@ class NodePath: i_pfx = f"if{t_idx}" # [backwards compatible] interface prefix n_idx = 0 t_idx = t_idx + 1 - elif topo_has_tg: + elif topo_has_tg and topo_has_dut: # Each node has 2 interfaces, starting with 1 # Calculate prefixes appropriately for current # path topology nomenclature: |