[RFC,v1,06/10] dts: add traffic generator node

Message ID 20220824162454.394285-7-juraj.linkes@pantheon.tech (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series dts: add hello world testcase |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Juraj Linkeš Aug. 24, 2022, 4:24 p.m. UTC
  The Traffic Generator node is responsible for configuring and running
traffic generators. For HelloWorld, we don't need any traffic, so this
is just a barebones implementation demonstrating the two nodes in use
in DTS.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 dts/framework/tg_node.py | 78 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 dts/framework/tg_node.py
  

Patch

diff --git a/dts/framework/tg_node.py b/dts/framework/tg_node.py
new file mode 100644
index 0000000000..109019e740
--- /dev/null
+++ b/dts/framework/tg_node.py
@@ -0,0 +1,78 @@ 
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2010-2014 Intel Corporation
+# Copyright(c) 2022 PANTHEON.tech s.r.o.
+#
+
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2010-2019 Intel Corporation
+# Copyright(c) 2022 PANTHEON.tech s.r.o.
+#
+
+"""
+Interface for bulk traffic generators.
+"""
+
+from framework.config import NodeConfiguration
+
+from .node import Node
+
+
+class TrafficGeneratorNode(Node):
+    """
+    A class for managing connections to the node running the Traffic generator,
+    providing methods that retrieve the necessary information about the node
+    (such as cpu, memory and NIC details), configure it and configure and
+    manage the Traffic generator.
+    """
+
+    def __init__(self, node_config: NodeConfiguration):
+        super(TrafficGeneratorNode, self).__init__(node_config)
+        # check the python version of TG
+        self.sut_nodes = []
+        self.re_run_time = 0
+
+    def prerequisites(self):
+        """
+        Setup hugepages and kernel modules on TG.
+        """
+        self.kill_all()
+
+        if not self.skip_setup:
+            total_huge_pages = self.get_total_huge_pages()
+            hugepages_size = self.send_expect(
+                "awk '/Hugepagesize/ {print $2}' /proc/meminfo", "# "
+            )
+            if total_huge_pages == 0:
+                self.mount_huge_pages()
+                if hugepages_size == "524288":
+                    self.set_huge_pages(8)
+                else:
+                    self.set_huge_pages(1024)
+
+        self.send_expect("modprobe uio", "# ")
+
+        self.tg_prerequisites()
+
+    def tg_prerequisites(self):
+        """
+        Prerequest function should be called before execute any test case.
+        Will call function to scan all lcore's information which on TG.
+        """
+
+        self.init_core_list()
+
+        self.disable_lldp()
+
+    def set_re_run(self, re_run_time):
+        """
+        set failed case re-run time
+        """
+        self.re_run_time = int(re_run_time)
+
+    def disable_lldp(self):
+        """
+        Disable TG ports LLDP.
+        """
+        result = self.send_expect("lldpad -d", "# ")
+        if result:
+            self.logger.error(result.strip())