Fix testcase config option imports

Fixes some testcases where config options were used before they
were guaranteed to be imported. This was causing intermittent
failures of tests such as test_shelve_offload.

Closes-Bug: 1256210

Change-Id: Id0204d67f35cb098a4ddfb670f5968e76b327705
This commit is contained in:
Chris Yeoh
2013-11-29 19:38:19 +10:30
parent b432f21a42
commit c7367823fd
3 changed files with 7 additions and 2 deletions

View File

@@ -25,11 +25,12 @@ from nova.tests.image import fake as fake_image
from nova import utils
CONF = cfg.CONF
CONF.import_opt('shelved_offload_time', 'nova.compute.manager')
class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
def _shelve_instance(self, shelved_offload_time):
CONF.shelved_offload_time = shelved_offload_time
CONF.set_override('shelved_offload_time', shelved_offload_time)
db_instance = jsonutils.to_primitive(self._create_fake_instance())
self.compute.run_instance(self.context, db_instance, {}, {}, [], None,
None, True, None, False)

View File

@@ -70,6 +70,9 @@ from nova.volume import cinder
CONF = cfg.CONF
CONF.import_opt('allow_resize_to_same_host', 'nova.compute.api')
CONF.import_opt('shelved_offload_time', 'nova.compute.manager')
CONF.import_opt('enable_network_quota',
'nova.api.openstack.compute.contrib.os_tenant_networks')
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
CONF.import_opt('vpn_image_id', 'nova.cloudpipe.pipelib')
@@ -1244,7 +1247,7 @@ class ShelveJsonTest(ServersSampleBase):
def setUp(self):
super(ShelveJsonTest, self).setUp()
# Don't offload instance, so we can test the offload call.
CONF.shelved_offload_time = -1
CONF.set_override('shelved_offload_time', -1)
def _test_server_action(self, uuid, action):
response = self._do_post('servers/%s/action' % uuid,

View File

@@ -19,6 +19,7 @@ from oslo.config import cfg
from nova.tests.integrated.v3 import test_servers
CONF = cfg.CONF
CONF.import_opt('shelved_offload_time', 'nova.compute.manager')
class ShelveJsonTest(test_servers.ServersSampleBase):