yatinkarel 0bbc254c72 Wait for config rollout to complete in test_api_server
test_api_server was not waiting for rollout to finish
and that was causing issues in follow up tests randomly.
This patch adds an option to wait for rollout to finish
when setting service config.
It can be used in other tests wherever needed.

Resolves: https://issues.redhat.com/browse/OSPRH-14166
Change-Id: Iabafe97934ed2b5ed40f1c529d6f2ffddeac2797
2025-03-20 18:59:22 +05:30

68 lines
2.6 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],
wait_res='deploy/neutron')
# 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')