From d8b9b0635f1fc7c7086ca47a25cb69fe2d2fd4ab Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Wed, 4 Sep 2024 09:41:46 +0000 Subject: [PATCH] Test Neutron API restart time The new test added checks that the time spent to restart the Neutron API doesn't take more than one minute. Closes-Bug: #OSPRH-2460 Change-Id: I467f6c2124b8e3d6eb76bea399fd9cc5bd553b5c --- .../tests/scenario/test_api_server.py | 66 +++++++++++++++++++ zuul.d/master_jobs.yaml | 6 +- 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 whitebox_neutron_tempest_plugin/tests/scenario/test_api_server.py diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_api_server.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_api_server.py new file mode 100644 index 0000000..b9c590b --- /dev/null +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_api_server.py @@ -0,0 +1,66 @@ +# 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. + self.set_service_setting(file=wb_utils.get_ml2_conf_file(), + section='ovn', + param='fdb_age_threshold', + value=random.randint(10000, 90000)) + + # 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') diff --git a/zuul.d/master_jobs.yaml b/zuul.d/master_jobs.yaml index 95ef45e..b4cb695 100644 --- a/zuul.d/master_jobs.yaml +++ b/zuul.d/master_jobs.yaml @@ -35,7 +35,8 @@ (^whitebox_neutron_tempest_plugin.*test_previously_used_ip)|\ (^whitebox_neutron_tempest_plugin.tests.scenario.test_ovn_dbs.OvnDbsMonitoringTest.*)|\ (^whitebox_neutron_tempest_plugin.*ovn_controller_restart)|\ - (^whitebox_neutron_tempest_plugin.tests.scenario.test_ovn_fdb.*)" + (^whitebox_neutron_tempest_plugin.tests.scenario.test_ovn_fdb.*)|\ + (^whitebox_neutron_tempest_plugin.tests.scenario.test_api_server.*)" devstack_localrc: USE_PYTHON3: true NETWORK_API_EXTENSIONS: "{{ (network_api_extensions_common + network_api_extensions_tempest) | join(',') }}" @@ -446,7 +447,8 @@ (^whitebox_neutron_tempest_plugin.*test_previously_used_ip)|\ (^whitebox_neutron_tempest_plugin.tests.scenario.test_ovn_dbs.OvnDbsMonitoringTest.*)|\ (^whitebox_neutron_tempest_plugin.*ovn_controller_restart)|\ - (^whitebox_neutron_tempest_plugin.tests.scenario.test_ovn_fdb.*)" + (^whitebox_neutron_tempest_plugin.tests.scenario.test_ovn_fdb.*)|\ + (^whitebox_neutron_tempest_plugin.tests.scenario.test_api_server.*)" # NOTE(mblue): Enable metadata rate limiting tests # when OSPRH-9569 is resolved (feature code available in RHOSO). tempest_exclude_regex: "\