Fix passing section argument into the set_service_setting

`_set_rate_limiting_config` was attempting to pass `section` value
by position but its position was off and the `service` argument
was getting passed instead. This caused bad formatting in the
crudini command and subsequent .conf file. This can be see in the
tempest log [1]

To prevent this from happening in the future. I am passing arguments
by their names.
I also put the  metada_rate_limiting string literal into a constant
to keep the code DRY.

[1] https://paste.opendev.org/show/btVjyzKuNaiI8UC1NC9M/

Related: https://issues.redhat.com/browse/OSPRH-9569

Change-Id: Ic73def44d03fb28b5975c1d96a471e0463d01740
This commit is contained in:
Miro Tomaska 2024-10-04 14:13:38 -04:00 committed by Chris Buggy
parent a46b9ca6a3
commit 6c381d8e20

View File

@ -27,6 +27,7 @@ from whitebox_neutron_tempest_plugin.tests.scenario import base as wb_base
CONF = config.CONF CONF = config.CONF
WB_CONF = CONF.whitebox_neutron_plugin_options WB_CONF = CONF.whitebox_neutron_plugin_options
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
METADATA_RATE_LIMITING_SECTION = 'metadata_rate_limiting'
class TestMetadataRateLimiting(wb_base.BaseTempestWhiteboxTestCase): class TestMetadataRateLimiting(wb_base.BaseTempestWhiteboxTestCase):
@ -93,14 +94,15 @@ class TestMetadataRateLimiting(wb_base.BaseTempestWhiteboxTestCase):
LOG.debug( LOG.debug(
'Setting metadata rate limiting configuration:\n' 'Setting metadata rate limiting configuration:\n'
f'File - {cls.metadata_conf_file}\n' f'File - {cls.metadata_conf_file}\n'
'Section - metadata_rate_limiting\n' f'Section - {METADATA_RATE_LIMITING_SECTION}\n'
f'Parameter - {key}\n' f'Parameter - {key}\n'
f'Value - {value}\n') f'Value - {value}\n')
cls.set_service_setting( cls.set_service_setting(
'compute', node_type='compute',
cls.metadata_conf_file, file=cls.metadata_conf_file,
'metadata_rate_limiting', section=METADATA_RATE_LIMITING_SECTION,
key, value) param=key,
value=value)
cls._restart_metadata_agent() cls._restart_metadata_agent()
def tearDown(self): def tearDown(self):
@ -121,7 +123,7 @@ class TestMetadataRateLimiting(wb_base.BaseTempestWhiteboxTestCase):
cls.run_group_cmd( cls.run_group_cmd(
'sudo crudini --del {} {} && sudo sync'.format( 'sudo crudini --del {} {} && sudo sync'.format(
cls.metadata_conf_file, cls.metadata_conf_file,
'metadata_rate_limiting'), METADATA_RATE_LIMITING_SECTION),
'compute') 'compute')
@classmethod @classmethod