Fix unit test that break isolation
Unit test that require configuration should use the configuration fixture and set_default so that configuration changes stay isolated to the specific test. Tests in test_base_test break this rule and cause race conditions in other tests, fixing that. Change-Id: I1c0b62cb29268fb4d34ab769eaf35139c4204509
This commit is contained in:
parent
8871fca323
commit
5fdfc9bfe0
@ -13,10 +13,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
from tempest import clients
|
from tempest import clients
|
||||||
from tempest.common import credentials_factory as credentials
|
from tempest.common import credentials_factory as credentials
|
||||||
from tempest import config
|
|
||||||
from tempest.lib.common import fixed_network
|
from tempest.lib.common import fixed_network
|
||||||
from tempest import test
|
from tempest import test
|
||||||
from tempest.tests import base
|
from tempest.tests import base
|
||||||
@ -28,8 +28,9 @@ class TestBaseTestCase(base.TestCase):
|
|||||||
super(TestBaseTestCase, self).setUp()
|
super(TestBaseTestCase, self).setUp()
|
||||||
self.useFixture(fake_config.ConfigFixture())
|
self.useFixture(fake_config.ConfigFixture())
|
||||||
self.fixed_network_name = 'fixed-net'
|
self.fixed_network_name = 'fixed-net'
|
||||||
config.CONF.compute.fixed_network_name = self.fixed_network_name
|
cfg.CONF.set_default('fixed_network_name', self.fixed_network_name,
|
||||||
config.CONF.service_available.neutron = True
|
'compute')
|
||||||
|
cfg.CONF.set_default('neutron', True, 'service_available')
|
||||||
|
|
||||||
@mock.patch.object(test.BaseTestCase, 'get_client_manager')
|
@mock.patch.object(test.BaseTestCase, 'get_client_manager')
|
||||||
@mock.patch.object(test.BaseTestCase, '_get_credentials_provider')
|
@mock.patch.object(test.BaseTestCase, '_get_credentials_provider')
|
||||||
@ -56,7 +57,7 @@ class TestBaseTestCase(base.TestCase):
|
|||||||
def test_get_tenant_network_with_nova_net(self, mock_man, mock_iaa,
|
def test_get_tenant_network_with_nova_net(self, mock_man, mock_iaa,
|
||||||
mock_giv, mock_gtn, mock_gcp,
|
mock_giv, mock_gtn, mock_gcp,
|
||||||
mock_gcm):
|
mock_gcm):
|
||||||
config.CONF.service_available.neutron = False
|
cfg.CONF.set_default('neutron', False, 'service_available')
|
||||||
mock_prov = mock.Mock()
|
mock_prov = mock.Mock()
|
||||||
mock_admin_man = mock.Mock()
|
mock_admin_man = mock.Mock()
|
||||||
mock_iaa.return_value = True
|
mock_iaa.return_value = True
|
||||||
|
Loading…
Reference in New Issue
Block a user