Rodolfo Alonso Hernandez 8b160a4c6e `set_service_setting` accept multiple config changes
The method ``BaseTempestWhiteboxTestCase.set_service_setting`` accepts
multiple configuration parameters in one call. If the service
configuration changes, it will be needed to restart it only once.

Closes-Bug: #OSPRH-10514
Change-Id: I206f3ce73e9ab36d4fe1ba072735a0bd382c5621
2024-10-09 14:48:57 +00:00

67 lines
2.5 KiB
Python

# Copyright 2024 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import random
from oslo_log import log
from oslo_utils import timeutils
from tempest import config
from whitebox_neutron_tempest_plugin.common import utils as wb_utils
from whitebox_neutron_tempest_plugin.tests.scenario import base as wb_base
CONF = config.CONF
WB_CONF = CONF.whitebox_neutron_plugin_options
LOG = log.getLogger(__name__)
class NeutronAPIServerTest(wb_base.BaseTempestTestCaseOvn):
@classmethod
def resource_setup(cls):
super().resource_setup()
cls.discover_nodes()
def test_neutron_api_restart(self):
# 1) Checks the Neutron API is responding and init the timer.
wb_utils.wait_for_neutron_api(self.client)
t1 = timeutils.utcnow()
# 2) Do a trivial configuration change. In a "podified" environment,
# that will trigger the Neutron API restart. In a "devstack"
# environment, it will be needed to manually restart the Neutron API
# server.
_config = wb_base.ConfigOption('ovn', 'fdb_age_threshold',
random.randint(10000, 90000))
self.set_service_setting(file=wb_utils.get_ml2_conf_file(),
config_list=[_config])
# 3) Restart Neutron API on all controllers simultaneously.
if not WB_CONF.openstack_type == 'podified':
service_ptn = wb_utils.get_neutron_api_service_name()
for node in self.nodes:
if node['is_controller']:
# NOTE(mblue): if reset fails on multinode, consider
# wait_until_active=False for a more simultaneous reset
self.reset_node_service(service_ptn, node['client'])
wb_utils.wait_for_neutron_api(self.client)
t2 = timeutils.utcnow()
tdelta = t2 - t1
self.assertLess(tdelta.seconds, 120,
msg='The Neutron API took more than 120 seconds to '
'restart')