Skip to content

Commit

Permalink
Merge pull request #5 from natali-rs1985/T7066
Browse files Browse the repository at this point in the history
T7066: VPP CPU workers verification
  • Loading branch information
sever-sever authored Feb 3, 2025
2 parents 71875be + e5c5d67 commit a649b1a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
26 changes: 26 additions & 0 deletions smoketest/scripts/cli/test_vpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,32 @@ def test_09_vpp_xconnect(self):
for required_string in required_str_list:
self.assertNotIn(required_string, out)

def test_11_vpp_cpu_settings(self):
main_core = '0'
workers = '2'

self.cli_set(base_path + ['settings', 'cpu', 'workers', workers])

# "cpu 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])

self.cli_commit()

config_entries = (
f'main-core {main_core}',
f'workers {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)
17 changes: 15 additions & 2 deletions src/conf_mode/vpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,22 @@ def verify(config):
if 'cpu' in config['settings']:
if (
'corelist_workers' in config['settings']['cpu']
and 'main_core' not in config['settings']['cpu']
):
or 'workers' in config['settings']['cpu']
) and 'main_core' not in config['settings']['cpu']:
raise ConfigError('"cpu main-core" is required but not set!')

cpus = int(get_core_count())
if 'workers' in config['settings']['cpu']:
# number of worker threads must be not more than
# available CPUs in the system - 2 (1 for main thread and at least 1 for system processes)
workers = int(config['settings']['cpu']['workers'])
available_workers = cpus - 2
if workers > available_workers:
raise ConfigError(
f'The system does not have enough CPUs for {workers} VPP workers '
f'(reduce to {available_workers} or less)'
)

verify_memory(config['settings'])

# Check if deleted interfaces are not xconnect memebrs
Expand Down Expand Up @@ -428,6 +440,7 @@ def generate(config):


def apply(config):

# Open persistent config
# It is required for operations with interfaces
persist_config = JSONStorage('vpp_conf')
Expand Down

0 comments on commit a649b1a

Please sign in to comment.