summaryrefslogtreecommitdiff
path: root/smoketest/scripts
diff options
context:
space:
mode:
authorkhramshinr <khramshinr@gmail.com>2025-02-20 14:08:54 +0700
committerkhramshinr <khramshinr@gmail.com>2025-02-21 17:24:12 +0700
commit4abb970491dfc83234b817808d18ae6bfeeeffe8 (patch)
treedeb6f8f74428592ab59e7755767edbaa40394cec /smoketest/scripts
parent752b400aaf5520c29726dadfc94127a06e0ad5a9 (diff)
downloadvyos-1x-4abb970491dfc83234b817808d18ae6bfeeeffe8.tar.gz
vyos-1x-4abb970491dfc83234b817808d18ae6bfeeeffe8.zip
T7073: Verify VPP buffers page size
T7077: Verify VPP memory default-hugepage-size T7079: Verify VPP memory main-heap-page-size T7080: Verify VPP statseg page-size get available hugepage sizes align memory main-heap-size by page size validate host_resources max_map_count
Diffstat (limited to 'smoketest/scripts')
-rwxr-xr-xsmoketest/scripts/cli/test_vpp.py76
1 files changed, 70 insertions, 6 deletions
diff --git a/smoketest/scripts/cli/test_vpp.py b/smoketest/scripts/cli/test_vpp.py
index 86b00da44..9f28c970f 100755
--- a/smoketest/scripts/cli/test_vpp.py
+++ b/smoketest/scripts/cli/test_vpp.py
@@ -19,7 +19,9 @@
import os
import re
+import sys
import unittest
+from collections import defaultdict
from json import loads
@@ -30,6 +32,9 @@ from vyos.utils.process import process_named_running
from vyos.utils.file import read_file
from vyos.utils.process import rc_cmd
+sys.path.append(os.getenv('vyos_completion_dir'))
+from list_mem_page_size import list_mem_page_size
+
PROCESS_NAME = 'vpp_main'
VPP_CONF = '/run/vpp/vpp.conf'
base_path = ['vpp']
@@ -37,6 +42,38 @@ driver = 'dpdk'
interface = 'eth1'
+def get_vpp_config():
+ config = defaultdict(dict)
+ current_section = None
+
+ with open(VPP_CONF, 'r') as f:
+ for line in f:
+ line = line.strip()
+
+ if not line or line.startswith('#'): # Ignore empty lines and comments
+ continue
+
+ section_match = re.match(r'([a-zA-Z0-9_-]+)\s*{', line)
+ if section_match:
+ current_section = section_match.group(1)
+ config[current_section] = {}
+ continue
+
+ if line == '}': # End of section
+ current_section = None
+ continue
+
+ key_value_match = re.match(r'([a-zA-Z0-9_-]+)\s+(.+)', line)
+ if key_value_match:
+ key, value = key_value_match.groups()
+ if current_section:
+ config[current_section][key] = value
+ else:
+ config[key] = value
+
+ return config
+
+
def get_address(interface):
rc, data = rc_cmd(f'ip --json address show dev {interface}')
if rc == 0:
@@ -60,12 +97,13 @@ class TestVPP(VyOSUnitTestSHIM.TestCase):
self.cli_set(base_path + ['settings', 'unix', 'poll-sleep-usec', '10'])
def tearDown(self):
- # Check for running process
- self.assertTrue(process_named_running(PROCESS_NAME))
-
- # delete test config
- self.cli_delete(base_path)
- self.cli_commit()
+ try:
+ # Check for running process
+ self.assertTrue(process_named_running(PROCESS_NAME))
+ finally:
+ # Ensure these cleanup operations always run
+ self.cli_delete(base_path)
+ self.cli_commit()
self.assertFalse(os.path.exists(VPP_CONF))
self.assertFalse(process_named_running(PROCESS_NAME))
@@ -1064,6 +1102,32 @@ class TestVPP(VyOSUnitTestSHIM.TestCase):
for config_entry in config_entries:
self.assertIn(config_entry, config)
+ def test_13_mem_page_size(self):
+ sizes = ['default', 'default-hugepage'] + list_mem_page_size()
+ for size in sizes:
+ self.cli_set(base_path + ['settings', 'buffers', 'page-size', size])
+ self.cli_set(base_path + ['settings', 'statseg', 'page-size', size])
+ self.cli_set(
+ base_path + ['settings', 'memory', 'main-heap-page-size', size]
+ )
+ self.cli_commit()
+
+ conf = get_vpp_config()
+ self.assertEqual(conf['buffers']['page-size'], size)
+ self.assertEqual(conf['statseg']['page-size'], size)
+ self.assertEqual(conf['memory']['main-heap-page-size'], size)
+
+ def test_14_mem_default_hugepage(self):
+ sizes = list_mem_page_size(hugepage_only=True)
+ for size in sizes:
+ self.cli_set(
+ base_path + ['settings', 'memory', 'default-hugepage-size', size]
+ )
+ self.cli_commit()
+
+ conf = get_vpp_config()
+ self.assertEqual(conf['memory']['default-hugepage-size'], size)
+
if __name__ == '__main__':
unittest.main(verbosity=2)