Merge "Increase timeouts for OVSDB in functional tests" into stable/stein

This commit is contained in:
Zuul 2019-09-17 03:50:47 +00:00 committed by Gerrit Code Review
commit e54a3f47ac
3 changed files with 80 additions and 0 deletions

View File

@ -16,10 +16,12 @@
import os
import warnings
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
@ -29,6 +31,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()
@ -66,6 +76,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):
@ -75,3 +86,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()

View File

@ -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)