summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-10-01 07:44:36 +0000
committerGerrit Code Review <review@openstack.org>2012-10-01 07:44:36 +0000
commit522e122b13c8a33ce4c4436ccc35e3109acb90ec (patch)
tree6e2ca7b7ff42822a913ad039169d0d78777e6583
parent481d17079336f7ea5610e3cda46881db244a3681 (diff)
parent9d2dae37f2f092f126d1db3ef2b7248668cf8f78 (diff)
downloadnova-522e122b13c8a33ce4c4436ccc35e3109acb90ec.tar.gz
nova-522e122b13c8a33ce4c4436ccc35e3109acb90ec.tar.xz
nova-522e122b13c8a33ce4c4436ccc35e3109acb90ec.zip
Merge "Use self.flags() instead of manipulating FLAGS by hand"
-rw-r--r--nova/tests/compute/test_compute.py4
-rw-r--r--nova/tests/test_api.py4
-rw-r--r--nova/tests/test_netapp_nfs.py18
-rw-r--r--nova/tests/test_nfs.py26
4 files changed, 18 insertions, 34 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index d893d823a..3fb5fc230 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -2340,8 +2340,8 @@ class ComputeTestCase(BaseTestCase):
self.mox.StubOutWithMock(self.compute.driver, 'list_instances')
self.compute.driver.list_instances().AndReturn([instance['name']])
- FLAGS.running_deleted_instance_timeout = 3600
- FLAGS.running_deleted_instance_action = 'reap'
+ self.flags(running_deleted_instance_timeout=3600,
+ running_deleted_instance_action='reap')
self.mox.StubOutWithMock(self.compute.db, "instance_get_all_by_host")
self.compute.db.instance_get_all_by_host(admin_context,
diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py
index f176231d2..4a4260705 100644
--- a/nova/tests/test_api.py
+++ b/nova/tests/test_api.py
@@ -366,7 +366,7 @@ class ApiEc2TestCase(test.TestCase):
for test in test_raise:
self.expect_http()
self.mox.ReplayAll()
- FLAGS.ec2_strict_validation = test[0]
+ self.flags(ec2_strict_validation=test[0])
self.assertRaises(boto_exc.EC2ResponseError,
self.ec2.create_security_group,
test[1],
@@ -378,7 +378,7 @@ class ApiEc2TestCase(test.TestCase):
for test in test_accept:
self.expect_http()
self.mox.ReplayAll()
- FLAGS.ec2_strict_validation = test[0]
+ self.flags(ec2_strict_validation=test[0])
self.ec2.create_security_group(test[1], test[2])
self.expect_http()
self.mox.ReplayAll()
diff --git a/nova/tests/test_netapp_nfs.py b/nova/tests/test_netapp_nfs.py
index 49a93728d..1a8824386 100644
--- a/nova/tests/test_netapp_nfs.py
+++ b/nova/tests/test_netapp_nfs.py
@@ -77,21 +77,17 @@ class NetappNfsDriverTestCase(test.TestCase):
def test_check_for_setup_error(self):
mox = self.mox
drv = self._driver
- required_flags = [
- 'netapp_wsdl_url',
- 'netapp_login',
- 'netapp_password',
- 'netapp_server_hostname',
- 'netapp_server_port'
- ]
# check exception raises when flags are not set
self.assertRaises(exception.NovaException,
drv.check_for_setup_error)
# set required flags
- for flag in required_flags:
- setattr(netapp.FLAGS, flag, 'val')
+ self.flags(netapp_wsdl_url='val',
+ netapp_login='val',
+ netapp_password='val',
+ netapp_server_hostname='val',
+ netapp_server_port='val')
mox.StubOutWithMock(nfs.NfsDriver, 'check_for_setup_error')
nfs.NfsDriver.check_for_setup_error()
@@ -99,10 +95,6 @@ class NetappNfsDriverTestCase(test.TestCase):
drv.check_for_setup_error()
- # restore initial FLAGS
- for flag in required_flags:
- delattr(netapp.FLAGS, flag)
-
def test_do_setup(self):
mox = self.mox
drv = self._driver
diff --git a/nova/tests/test_nfs.py b/nova/tests/test_nfs.py
index ddfee2fd1..d0d235b1b 100644
--- a/nova/tests/test_nfs.py
+++ b/nova/tests/test_nfs.py
@@ -93,7 +93,7 @@ class NfsDriverTestCase(test.TestCase):
def test_local_path(self):
"""local_path common use case"""
- nfs.FLAGS.nfs_mount_point_base = self.TEST_MNT_POINT_BASE
+ self.flags(nfs_mount_point_base=self.TEST_MNT_POINT_BASE)
drv = self._driver
volume = DumbVolume()
@@ -201,7 +201,7 @@ class NfsDriverTestCase(test.TestCase):
"""_get_mount_point_for_share should calculate correct value"""
drv = self._driver
- nfs.FLAGS.nfs_mount_point_base = self.TEST_MNT_POINT_BASE
+ self.flags(nfs_mount_point_base=self.TEST_MNT_POINT_BASE)
self.assertEqual('/mnt/test/2f4f60214cf43c595666dd815f0360a4',
drv._get_mount_point_for_share(self.TEST_NFS_EXPORT1))
@@ -216,7 +216,7 @@ class NfsDriverTestCase(test.TestCase):
df_data = 'nfs-host:/export 2620544 996864 %d 41%% /mnt' % df_avail
df_output = df_head + df_data
- setattr(nfs.FLAGS, 'nfs_disk_util', 'df')
+ self.flags(nfs_disk_util='df')
mox.StubOutWithMock(drv, '_get_mount_point_for_share')
drv._get_mount_point_for_share(self.TEST_NFS_EXPORT1).\
@@ -231,14 +231,12 @@ class NfsDriverTestCase(test.TestCase):
self.assertEquals(df_avail,
drv._get_available_capacity(self.TEST_NFS_EXPORT1))
- delattr(nfs.FLAGS, 'nfs_disk_util')
-
def test_get_available_capacity_with_du(self):
"""_get_available_capacity should calculate correct value"""
mox = self.mox
drv = self._driver
- setattr(nfs.FLAGS, 'nfs_disk_util', 'du')
+ self.flags(nfs_disk_util='du')
df_total_size = 2620544
df_used_size = 996864
@@ -270,13 +268,11 @@ class NfsDriverTestCase(test.TestCase):
self.assertEquals(df_total_size - du_used,
drv._get_available_capacity(self.TEST_NFS_EXPORT1))
- delattr(nfs.FLAGS, 'nfs_disk_util')
-
def test_load_shares_config(self):
mox = self.mox
drv = self._driver
- nfs.FLAGS.nfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+ self.flags(nfs_shares_config=self.TEST_SHARES_CONFIG_FILE)
mox.StubOutWithMock(__builtin__, 'open')
config_data = []
@@ -343,7 +339,7 @@ class NfsDriverTestCase(test.TestCase):
"""do_setup should throw error if shares config is not configured """
drv = self._driver
- nfs.FLAGS.nfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+ self.flags(nfs_shares_config=self.TEST_SHARES_CONFIG_FILE)
self.assertRaises(exception.NfsException,
drv.do_setup, IsA(context.RequestContext))
@@ -353,7 +349,7 @@ class NfsDriverTestCase(test.TestCase):
mox = self.mox
drv = self._driver
- nfs.FLAGS.nfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+ self.flags(nfs_shares_config=self.TEST_SHARES_CONFIG_FILE)
mox.StubOutWithMock(os.path, 'exists')
os.path.exists(self.TEST_SHARES_CONFIG_FILE).AndReturn(True)
@@ -424,7 +420,7 @@ class NfsDriverTestCase(test.TestCase):
drv = self._driver
volume = self._simple_volume()
- setattr(nfs.FLAGS, 'nfs_sparsed_volumes', True)
+ self.flags(nfs_sparsed_volumes=True)
mox.StubOutWithMock(drv, '_create_sparsed_file')
mox.StubOutWithMock(drv, '_set_rw_permissions_for_all')
@@ -436,14 +432,12 @@ class NfsDriverTestCase(test.TestCase):
drv._do_create_volume(volume)
- delattr(nfs.FLAGS, 'nfs_sparsed_volumes')
-
def test_create_nonsparsed_volume(self):
mox = self.mox
drv = self._driver
volume = self._simple_volume()
- setattr(nfs.FLAGS, 'nfs_sparsed_volumes', False)
+ self.flags(nfs_sparsed_volumes=False)
mox.StubOutWithMock(drv, '_create_regular_file')
mox.StubOutWithMock(drv, '_set_rw_permissions_for_all')
@@ -455,8 +449,6 @@ class NfsDriverTestCase(test.TestCase):
drv._do_create_volume(volume)
- delattr(nfs.FLAGS, 'nfs_sparsed_volumes')
-
def test_create_volume_should_ensure_nfs_mounted(self):
"""create_volume should ensure shares provided in config are mounted"""
mox = self.mox