feat(infra): Remove system.d dependency 01/38601/38
authorpmikus <peter.mikus@protonmail.ch>
Fri, 31 Mar 2023 13:53:02 +0000 (13:53 +0000)
committerPeter Mikus <peter.mikus@protonmail.ch>
Wed, 10 May 2023 05:32:00 +0000 (05:32 +0000)
Signed-off-by: pmikus <peter.mikus@protonmail.ch>
Change-Id: Icb7b6124dcba7bb57c18ceb91120284f6fe02c2e

resources/libraries/python/DUTSetup.py
resources/libraries/python/VPPUtil.py
resources/libraries/python/VppConfigGenerator.py
resources/libraries/robot/shared/default.robot
tests/vpp/device/__init__.robot
tests/vpp/perf/__init__.robot

index 363bb72..2485fbb 100644 (file)
@@ -646,63 +646,6 @@ class DUTSetup:
 
         exec_cmd_no_error(node, command, timeout=30, sudo=True, message=message)
 
-    @staticmethod
-    def install_vpp_on_all_duts(nodes, vpp_pkg_dir):
-        """Install VPP on all DUT nodes. Start the VPP service in case of
-        systemd is not available or does not support autostart.
-
-        :param nodes: Nodes in the topology.
-        :param vpp_pkg_dir: Path to directory where VPP packages are stored.
-        :type nodes: dict
-        :type vpp_pkg_dir: str
-        :raises RuntimeError: If failed to remove or install VPP.
-        """
-        for node in nodes.values():
-            message = f"Failed to install VPP on host {node[u'host']}!"
-            if node[u"type"] == NodeType.DUT:
-                command = "mkdir -p /var/log/vpp/"
-                exec_cmd(node, command, sudo=True)
-
-                command = u"ln -s /dev/null /etc/sysctl.d/80-vpp.conf || true"
-                exec_cmd_no_error(node, command, sudo=True)
-
-                command = u". /etc/lsb-release; echo \"${DISTRIB_ID}\""
-                stdout, _ = exec_cmd_no_error(node, command)
-
-                if stdout.strip() == u"Ubuntu":
-                    exec_cmd_no_error(
-                        node, u"apt-get purge -y '*vpp*' || true",
-                        timeout=120, sudo=True
-                    )
-                    # workaround to avoid installation of vpp-api-python
-                    exec_cmd_no_error(
-                        node, f"rm -f {vpp_pkg_dir}vpp-api-python.deb",
-                        timeout=120, sudo=True
-                    )
-                    exec_cmd_no_error(
-                        node, f"dpkg -i --force-all {vpp_pkg_dir}*.deb",
-                        timeout=120, sudo=True, message=message
-                    )
-                    exec_cmd_no_error(node, u"dpkg -l | grep vpp", sudo=True)
-                    if DUTSetup.running_in_container(node):
-                        DUTSetup.restart_service(node, Constants.VPP_UNIT)
-                else:
-                    exec_cmd_no_error(
-                        node, u"yum -y remove '*vpp*' || true",
-                        timeout=120, sudo=True
-                    )
-                    # workaround to avoid installation of vpp-api-python
-                    exec_cmd_no_error(
-                        node, f"rm -f {vpp_pkg_dir}vpp-api-python.rpm",
-                        timeout=120, sudo=True
-                    )
-                    exec_cmd_no_error(
-                        node, f"rpm -ivh {vpp_pkg_dir}*.rpm",
-                        timeout=120, sudo=True, message=message
-                    )
-                    exec_cmd_no_error(node, u"rpm -qai '*vpp*'", sudo=True)
-                    DUTSetup.restart_service(node, Constants.VPP_UNIT)
-
     @staticmethod
     def running_in_container(node):
         """This method tests if topology node is running inside container.
index 26c2109..0e69ec7 100644 (file)
@@ -41,7 +41,14 @@ class VPPUtil:
         """
         # Containers have a separate lifecycle, but better be safe.
         PapiSocketExecutor.disconnect_all_sockets_by_node(node)
-        DUTSetup.restart_service(node, Constants.VPP_UNIT)
+
+        VPPUtil.stop_vpp_service(node)
+        command = "/usr/bin/vpp -c /etc/vpp/startup.conf"
+        message = f"Node {node[u'host']} failed to start VPP!"
+        exec_cmd_no_error(
+            node, command, timeout=180, sudo=True, message=message
+        )
+
         if node_key:
             Topology.add_new_socket(
                 node, SocketType.CLI, node_key, Constants.SOCKCLI_PATH)
@@ -72,12 +79,19 @@ class VPPUtil:
         :type node: dict
         :type node_key: str
         """
-        # Containers have a separate lifecycle, but better be safe.
         PapiSocketExecutor.disconnect_all_sockets_by_node(node)
-        DUTSetup.stop_service(node, Constants.VPP_UNIT)
+        command = "pkill vpp"
+        exec_cmd(node, command, timeout=180, sudo=True)
+        command = (
+            "/bin/rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api"
+        )
+        exec_cmd(node, command, timeout=180, sudo=True)
+
         if node_key:
-            Topology.del_node_socket_id(node, SocketType.PAPI, node_key)
-            Topology.del_node_socket_id(node, SocketType.STATS, node_key)
+            if Topology.get_node_sockets(node, socket_type=SocketType.PAPI):
+                Topology.del_node_socket_id(node, SocketType.PAPI, node_key)
+            if Topology.get_node_sockets(node, socket_type=SocketType.STATS):
+                Topology.del_node_socket_id(node, SocketType.STATS, node_key)
 
     @staticmethod
     def stop_vpp_service_on_all_duts(nodes):
@@ -90,6 +104,39 @@ class VPPUtil:
             if node[u"type"] == NodeType.DUT:
                 VPPUtil.stop_vpp_service(node, node_key)
 
+    @staticmethod
+    def install_vpp_on_all_duts(nodes, vpp_pkg_dir):
+        """Install VPP on all DUT nodes.
+
+        :param nodes: Nodes in the topology.
+        :param vpp_pkg_dir: Path to directory where VPP packages are stored.
+        :type nodes: dict
+        :type vpp_pkg_dir: str
+        """
+        VPPUtil.stop_vpp_service_on_all_duts(nodes)
+        for node in nodes.values():
+            message = f"Failed to install VPP on host {node['host']}!"
+            if node["type"] == NodeType.DUT:
+                command = "mkdir -p /var/log/vpp/"
+                exec_cmd(node, command, sudo=True)
+
+                command = "ln -s /dev/null /etc/systemd/system/vpp.service"
+                exec_cmd(node, command, sudo=True)
+
+                command = "ln -s /dev/null /etc/sysctl.d/80-vpp.conf"
+                exec_cmd(node, command, sudo=True)
+
+                command = "apt-get purge -y '*vpp*' || true"
+                exec_cmd_no_error(node, command, timeout=120, sudo=True)
+
+                command = f"dpkg -i --force-all {vpp_pkg_dir}*.deb"
+                exec_cmd_no_error(
+                    node, command, timeout=120, sudo=True, message=message
+                )
+
+                command = "dpkg -l | grep vpp"
+                exec_cmd_no_error(node, command, sudo=True)
+
     @staticmethod
     def verify_vpp_installed(node):
         """Verify that VPP is installed on the specified topology node.
index 9a11762..a57d24c 100644 (file)
@@ -21,7 +21,7 @@ from resources.libraries.python.topology import NodeType
 from resources.libraries.python.topology import Topology
 from resources.libraries.python.VPPUtil import VPPUtil
 
-__all__ = [u"VppConfigGenerator"]
+__all__ = ["VppConfigGenerator", "VppInitConfig"]
 
 
 def pci_dev_check(pci_dev):
@@ -704,3 +704,40 @@ class VppConfigGenerator:
         VPPUtil.restart_vpp_service(self._node, self._node_key)
         if verify_vpp:
             VPPUtil.verify_vpp(self._node)
+
+
+class VppInitConfig:
+    """VPP Initial Configuration."""
+    @staticmethod
+    def init_vpp_startup_configuration_on_all_duts(nodes):
+        """Apply initial VPP startup configuration on all DUTs.
+
+        :param nodes: Nodes in the topology.
+        :type nodes: dict
+        """
+        huge_size = Constants.DEFAULT_HUGEPAGE_SIZE
+        for node in nodes.values():
+            if node[u"type"] == NodeType.DUT:
+                vpp_config = VppConfigGenerator()
+                vpp_config.set_node(node)
+                vpp_config.add_unix_log()
+                vpp_config.add_unix_cli_listen()
+                vpp_config.add_unix_cli_no_pager()
+                vpp_config.add_unix_gid()
+                vpp_config.add_unix_coredump()
+                vpp_config.add_socksvr(socket=Constants.SOCKSVR_PATH)
+                vpp_config.add_main_heap_size("2G")
+                vpp_config.add_main_heap_page_size(huge_size)
+                vpp_config.add_default_hugepage_size(huge_size)
+                vpp_config.add_statseg_size("2G")
+                vpp_config.add_statseg_page_size(huge_size)
+                vpp_config.add_statseg_per_node_counters("on")
+                vpp_config.add_plugin("disable", "default")
+                vpp_config.add_plugin("enable", "dpdk_plugin.so")
+                vpp_config.add_dpdk_dev(
+                    *[node["interfaces"][interface].get("pci_address") \
+                        for interface in node[u"interfaces"]]
+                )
+                vpp_config.add_ip6_hash_buckets(2000000)
+                vpp_config.add_ip6_heap_size("4G")
+                vpp_config.apply_config()
\ No newline at end of file
index c28fc4f..ad1cabb 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2022 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:
@@ -43,6 +43,7 @@
 | Library | resources.libraries.python.topology.Topology
 | Library | resources.libraries.python.Trace
 | Library | resources.libraries.python.VhostUser.VirtioFeatureMask
+| Library | resources.libraries.python.VppConfigGenerator.VppInitConfig
 | Library | resources.libraries.python.VppCounters
 | Library | resources.libraries.python.VPPUtil
 |
@@ -84,8 +85,6 @@
 | | ... | If it exists (and not None), call the resetter (as a Python callable).
 | | ... | This is usually used to reset any state on DUT before next trial.
 | |
-| | ... | TODO: Move to a more specific library if needed.
-| |
 | | ... | *Example:*
 | |
 | | ... | \| Call Resetter \|
 | | | Run Keyword | ${dut}.Add Unix Log
 | | | Run Keyword | ${dut}.Add Unix CLI Listen
 | | | Run Keyword | ${dut}.Add Unix CLI No Pager
-| | | Run Keyword | ${dut}.Add Unix Nodaemon
+| | | Run Keyword | ${dut}.Add Unix GID
 | | | Run Keyword | ${dut}.Add Unix Coredump
 | | | Run Keyword | ${dut}.Add Socksvr | ${SOCKSVR_PATH}
 | | | Run Keyword | ${dut}.Add Main Heap Size | ${${heap_size_mult}*${2}}G
index 9453da3..e8cbd1a 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2022 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:
@@ -25,7 +25,8 @@
 | ... | AND | Setup Framework | ${nodes}
 | ... | AND | Setup Corekeeper on All Nodes | ${nodes}
 | ... | AND | Install Vpp on All Duts | ${nodes} | ${packages_dir}
-| ... | AND | Verify Vpp on All Duts | ${nodes}
+| ... | AND | Init Vpp Startup Configuration on All Duts | ${nodes}
+| ... | AND | Show Vpp Version on All Duts | ${nodes}
 | ... | AND | Get CPU Info from All Nodes | ${nodes}
 | ... | AND | Update All Interface Data on All Nodes | ${nodes}
 | ... | AND | Finalize Suite Setup Export
index d13ada5..04b47f9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2022 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:
 | Library | resources.libraries.python.PapiExecutor.Disconnector
 | Library | resources.libraries.python.SetupFramework
 | Library | resources.libraries.python.SetupFramework.CleanupFramework
-| Library | resources.libraries.python.CpuUtils
 |
 | Suite Setup | Run Keywords | Start Suite Setup Export
 | ... | AND | Setup Global Variables
 | ... | AND | Setup Framework | ${nodes}
 | ... | AND | Setup Corekeeper on All Nodes | ${nodes}
 | ... | AND | Install Vpp on All Duts | ${nodes} | ${packages_dir}
-| ... | AND | Verify Vpp on All Duts | ${nodes}
-| ... | AND | Verify UIO Driver on all DUTs | ${nodes}
+| ... | AND | Init Vpp Startup Configuration on All Duts | ${nodes}
 | ... | AND | Show Vpp Version on All Duts | ${nodes}
 | ... | AND | Get CPU Info from All Nodes | ${nodes}
 | ... | AND | Update All Interface Data on All Nodes | ${nodes}