summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2025-02-17 14:06:53 +0200
committerGitHub <noreply@github.com>2025-02-17 14:06:53 +0200
commit2c61b18f2033d7ec5a5cc817da335bb11c5b2504 (patch)
tree6d7130f8a316e3757b03cdc4ae8685f05e222249
parent6dae0f206d67e0ef8678305c279505e3a5da6208 (diff)
parent81626fb5da73af302ef8444c12679edc13bef1f5 (diff)
downloadvyos-1x-2c61b18f2033d7ec5a5cc817da335bb11c5b2504.tar.gz
vyos-1x-2c61b18f2033d7ec5a5cc817da335bb11c5b2504.zip
Merge pull request #12 from natali-rs1985/T7067
T7067: VPP CPU corelist-workers should be calculated and verified
-rwxr-xr-xsmoketest/scripts/cli/test_vpp.py42
-rwxr-xr-xsrc/conf_mode/vpp.py11
2 files changed, 53 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_vpp.py b/smoketest/scripts/cli/test_vpp.py
index 03ee68beb..86b00da44 100755
--- a/smoketest/scripts/cli/test_vpp.py
+++ b/smoketest/scripts/cli/test_vpp.py
@@ -1022,6 +1022,48 @@ class TestVPP(VyOSUnitTestSHIM.TestCase):
for config_entry in config_entries:
self.assertIn(config_entry, config)
+ def test_12_vpp_cpu_corelist_workers(self):
+ main_core = '0'
+ corelist_workers = ['1', '2-3']
+
+ for worker in corelist_workers:
+ self.cli_set(base_path + ['settings', 'cpu', 'corelist-workers', worker])
+
+ # "cpu corelist-workers" reqiures main-core to be set
+ # expect raise ConfigError
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+
+ self.cli_set(base_path + ['settings', 'cpu', 'main-core', main_core])
+
+ # corelist-workers and workers cannot be used at the same time
+ # expect raise ConfigError
+ self.cli_set(base_path + ['settings', 'cpu', 'workers', '2'])
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+ self.cli_delete(base_path + ['settings', 'cpu', 'workers'])
+
+ # verify corelist-workers are set not correctly
+ # expect raise ConfigError
+ self.cli_set(base_path + ['settings', 'cpu', 'corelist-workers', '99-101'])
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+
+ self.cli_delete(base_path + ['settings', 'cpu', 'corelist-workers', '99-101'])
+
+ self.cli_commit()
+
+ config_entries = (
+ f'main-core {main_core}',
+ f'corelist-workers {",".join(corelist_workers)}',
+ 'dev 0000:00:00.0',
+ )
+
+ # Check configured options
+ config = read_file(VPP_CONF)
+ for config_entry in config_entries:
+ self.assertIn(config_entry, config)
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py
index 5126b7c79..fe6436c15 100755
--- a/src/conf_mode/vpp.py
+++ b/src/conf_mode/vpp.py
@@ -382,6 +382,14 @@ def verify(config):
) and 'main_core' not in config['settings']['cpu']:
raise ConfigError('"cpu main-core" is required but not set!')
+ if (
+ 'corelist_workers' in config['settings']['cpu']
+ and 'workers' in config['settings']['cpu']
+ ):
+ raise ConfigError(
+ '"cpu corelist-workers" and "cpu workers" cannot be used at the same time!'
+ )
+
cpus = int(get_core_count())
skip_cores = 0
@@ -436,6 +444,9 @@ def verify(config):
f'"cpu main-core {main_core}" must not be included in the corelist-workers!'
)
+ if not all(el in cpus_available for el in all_core_numbers):
+ raise ConfigError('"cpu corelist-workers" is not correct')
+
verify_memory(config['settings'])
# Check if deleted interfaces are not xconnect memebrs