From 42d9106ee5ba10b0cc6c5f970255688a9484ad78 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 12 Mar 2019 10:59:18 +0000 Subject: [PATCH] Increase timeouts for OVSDB in functional tests Increased timeouts for OVSDB connection: - ovsdb_timeout = 30 This patch will mitigate the intermittent timeouts the CI is experiencing while running the functional tests. Change-Id: I97a1d170926bb8a69dc6f7bb78a785bdea80936a Closes-Bug: #1815142 (cherry picked from commit 30e901242f71f783fe06f775b20afa01da41d72f) --- neutron/tests/functional/base.py | 21 +++++++ .../tests/unit/tests/functional/__init__.py | 0 .../tests/unit/tests/functional/test_base.py | 59 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 neutron/tests/unit/tests/functional/__init__.py create mode 100644 neutron/tests/unit/tests/functional/test_base.py diff --git a/neutron/tests/functional/base.py b/neutron/tests/functional/base.py index 76a9fe24da4..4cdf4f027d5 100644 --- a/neutron/tests/functional/base.py +++ b/neutron/tests/functional/base.py @@ -15,10 +15,12 @@ import os +import mock from oslo_config import cfg from neutron.agent.linux import utils from neutron.conf.agent import common as config +from neutron.conf.agent import ovs_conf from neutron.tests import base from neutron.tests.common import base as common_base from neutron.tests.common import helpers @@ -28,6 +30,14 @@ DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(), 'dsvm-functional-logs') +def config_decorator(method_to_decorate, config_tuples): + def wrapper(*args, **kwargs): + method_to_decorate(*args, **kwargs) + for config_tuple in config_tuples: + cfg.CONF.set_override(*config_tuple) + return wrapper + + class BaseLoggingTestCase(base.BaseTestCase): def setUp(self): super(BaseLoggingTestCase, self).setUp() @@ -62,6 +72,7 @@ class BaseSudoTestCase(BaseLoggingTestCase): self.skipTest('Testing with sudo is not enabled') self.setup_rootwrap() config.setup_privsep() + self._override_default_config() @common_base.no_skip_on_missing_deps def check_command(self, cmd, error_text, skip_msg, run_as_root=False): @@ -71,3 +82,13 @@ class BaseSudoTestCase(BaseLoggingTestCase): if error_text in str(e): self.skipTest(skip_msg) raise + + @staticmethod + def _override_default_config(): + # NOTE(ralonsoh): once https://review.openstack.org/#/c/641681/ is + # merged, we should increase the default value of those new parameters. + ovs_agent_opts = [('ovsdb_timeout', 30, 'OVS')] + ovs_agent_decorator = config_decorator( + ovs_conf.register_ovs_agent_opts, ovs_agent_opts) + mock.patch.object(ovs_conf, 'register_ovs_agent_opts', + new=ovs_agent_decorator).start() diff --git a/neutron/tests/unit/tests/functional/__init__.py b/neutron/tests/unit/tests/functional/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/neutron/tests/unit/tests/functional/test_base.py b/neutron/tests/unit/tests/functional/test_base.py new file mode 100644 index 00000000000..d900a41a800 --- /dev/null +++ b/neutron/tests/unit/tests/functional/test_base.py @@ -0,0 +1,59 @@ +# Copyright 2019 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 mock +from oslo_config import cfg + +from neutron.tests import base +from neutron.tests.functional import base as functional_base + + +NEW_CONFIG_GROUP = cfg.OptGroup('testgroup', + title='Test wrapping cfg register') +SOME_OPTIONS = [ + cfg.StrOpt('str_opt', default='default_value'), + cfg.StrOpt('int_opt', default=1), + cfg.BoolOpt('bool_opt', default=True) +] + + +def register_some_options(cfg=cfg.CONF): + cfg.register_opts(SOME_OPTIONS, 'testgroup') + + +class ConfigDecoratorTestCase(base.BaseTestCase): + + def setUp(self): + super(ConfigDecoratorTestCase, self).setUp() + cfg.CONF.register_group(NEW_CONFIG_GROUP) + + def test_no_config_decorator(self): + register_some_options() + self.assertEqual('default_value', cfg.CONF.testgroup.str_opt) + self.assertEqual('1', cfg.CONF.testgroup.int_opt) + self.assertTrue(cfg.CONF.testgroup.bool_opt) + + def test_override_variables(self): + opts = [('str_opt', 'another_value', 'testgroup'), + ('int_opt', 123, 'testgroup'), + ('bool_opt', False, 'testgroup')] + cfg_decorator = functional_base.config_decorator(register_some_options, + opts) + mock.patch('neutron.tests.unit.tests.functional.test_base.' + 'register_some_options', new=cfg_decorator).start() + register_some_options() + self.assertEqual('another_value', cfg.CONF.testgroup.str_opt) + self.assertEqual('123', cfg.CONF.testgroup.int_opt) + self.assertFalse(cfg.CONF.testgroup.bool_opt)