[UT][ovn] Access config options after they are registered

It is a follow up of [1]. There were still some tests
which were accessing config optons before they were registered
and failing when tested manually just those tests, this
patch fixes it.

[1] https://review.opendev.org/c/openstack/neutron/+/842068

Related-Bug: #1968606
Change-Id: I9aec0ba1f5c723e6f5a9146e9af41707e8014db2
This commit is contained in:
yatinkarel 2022-05-26 18:46:25 +05:30
parent 7fc509aa9a
commit 384ff4485f
2 changed files with 5 additions and 1 deletions
neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver

@ -165,6 +165,7 @@ class TestOvnDbNotifyHandler(base.BaseTestCase):
class TestOvnConnection(base.BaseTestCase):
def setUp(self):
ovn_conf.register_opts()
super(TestOvnConnection, self).setUp()
@mock.patch.object(idlutils, 'get_schema_helper')

@ -158,6 +158,9 @@ class TestOVNMechanismDriverBase(MechDriverSetupBase,
group='ovn')
ovn_conf.cfg.CONF.set_override('dns_servers', ['8.8.8.8'],
group='ovn')
# Need to register here for 'vlan_transparent' config before
# setting up test_plugin
config.register_common_config_options()
cfg.CONF.set_override('vlan_transparent', True)
cfg.CONF.set_override('ovsdb_connection_timeout', 30, group='ovn')
mock.patch.object(impl_idl_ovn.Backend, 'schema_helper').start()
@ -2453,7 +2456,6 @@ class OVNMechanismDriverTestCase(MechDriverSetupBase,
def setUp(self):
ovn_conf.register_opts()
cfg.CONF.set_override('global_physnet_mtu', 1550)
cfg.CONF.set_override('tenant_network_types',
['geneve'],
group='ml2')
@ -2466,6 +2468,7 @@ class OVNMechanismDriverTestCase(MechDriverSetupBase,
ovn_conf.cfg.CONF.set_override('dns_servers', ['8.8.8.8'], group='ovn')
mock.patch.object(impl_idl_ovn.Backend, 'schema_helper').start()
super(OVNMechanismDriverTestCase, self).setUp()
cfg.CONF.set_override('global_physnet_mtu', 1550)
# Make sure the node and target_node for the hash ring in the
# mechanism driver matches
node_uuid = uuidutils.generate_uuid()