Add 100k tunnels ipsec policy mode with fastpath enabled test suite
[csit.git] / resources / libraries / python / VPPUtil.py
index e343d38..0c60361 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2021 Cisco and/or its affiliates.
+# Copyright (c) 2023 Cisco 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:
@@ -18,6 +18,9 @@ from robot.api import logger
 from resources.libraries.python.Constants import Constants
 from resources.libraries.python.DUTSetup import DUTSetup
 from resources.libraries.python.PapiExecutor import PapiSocketExecutor
+from resources.libraries.python.model.ExportResult import (
+    export_dut_type_and_version
+)
 from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd
 from resources.libraries.python.topology import Topology, SocketType, NodeType
 
@@ -69,6 +72,8 @@ class VPPUtil:
         PapiSocketExecutor.disconnect_all_sockets_by_node(node)
         DUTSetup.restart_service(node, Constants.VPP_UNIT)
         if node_key:
+            Topology.add_new_socket(
+                node, SocketType.CLI, node_key, Constants.SOCKCLI_PATH)
             Topology.add_new_socket(
                 node, SocketType.PAPI, node_key, Constants.SOCKSVR_PATH)
             Topology.add_new_socket(
@@ -197,6 +202,7 @@ class VPPUtil:
         """Run "show_version" PAPI command.
 
         Socket is configurable, so VPP inside container can be accessed.
+        The result is exported to JSON UTI output as "dut-version".
 
         :param node: Node to run command on.
         :param remote_vpp_socket: Path to remote socket to target VPP.
@@ -214,7 +220,9 @@ class VPPUtil:
             reply = papi_exec.add(cmd).get_reply()
         if log:
             logger.info(f"VPP version: {reply[u'version']}\n")
-        return f"{reply[u'version']}"
+        version = f"{reply[u'version']}"
+        export_dut_type_and_version(u"VPP", version)
+        return version
 
     @staticmethod
     def show_vpp_version_on_all_duts(nodes):
@@ -402,3 +410,20 @@ class VPPUtil:
             reply = papi_exec.add(cmd, **args).get_reply()
 
         return reply[u"next_index"]
+
+    @staticmethod
+    def vpp_set_neighbor_limit_on_all_duts(nodes, count):
+        """VPP set neighbor count limit on all DUTs in the given topology.
+
+        :param nodes: Nodes in the topology.
+        :param count: Neighbor count need to set.
+        :type nodes: dict
+        :type count: int
+        """
+        for node in nodes.values():
+            if node[u"type"] == NodeType.DUT:
+                cmd = f"set ip neighbor-config ip4 limit {count}"
+                PapiSocketExecutor.run_cli_cmd(node, cmd)
+
+                cmd = f"set ip neighbor-config ip6 limit {count}"
+                PapiSocketExecutor.run_cli_cmd(node, cmd)