]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Update tests to use CONF.set_override
authorAlex Meade <mr.alex.meade@gmail.com>
Mon, 24 Feb 2014 20:28:23 +0000 (15:28 -0500)
committerAlex Meade <mr.alex.meade@gmail.com>
Fri, 21 Mar 2014 14:14:52 +0000 (10:14 -0400)
This patch updates some tests that were overriding configuration
values by means other than CONF.set_override. It also removes any
left over references to the glusterfs_disk_util config option.

Closes-bug: 1284293
Closes-bug: 1284300

Change-Id: Id2d14cc3ff77322d017033f3558aed9cd637589b

cinder/tests/test_backup.py
cinder/tests/test_glusterfs.py
cinder/tests/test_nfs.py

index 94a2d29c50e42571c15306503902850455f29d17..19618c14b0364481750f8c279497bf224caffec0 100644 (file)
@@ -416,14 +416,11 @@ class BackupTestCase(test.TestCase):
 
     def test_backup_manager_driver_name(self):
         """"Test mapping between backup services and backup drivers."""
-
-        old_setting = CONF.backup_driver
-        setattr(cfg.CONF, 'backup_driver', "cinder.backup.services.swift")
+        cfg.CONF.set_override('backup_driver', "cinder.backup.services.swift")
         backup_mgr = \
             importutils.import_object(CONF.backup_manager)
         self.assertEqual('cinder.backup.drivers.swift',
                          backup_mgr.driver_name)
-        setattr(cfg.CONF, 'backup_driver', old_setting)
 
     def test_export_record_with_bad_service(self):
         """Test error handling when attempting an export of a backup
index 94dbd8b1b363d9a0dc153819853d09959548fd29..88456b0a5797e1a29d1b30d2182aa9672207c82b 100644 (file)
@@ -22,6 +22,7 @@ import mox as mox_lib
 from mox import IgnoreArg
 from mox import IsA
 from mox import stubout
+from oslo.config import cfg
 
 from cinder import brick
 from cinder import context
@@ -38,6 +39,9 @@ from cinder.volume import driver as base_driver
 from cinder.volume.drivers import glusterfs
 
 
+CONF = cfg.CONF
+
+
 class DumbVolume(object):
     fields = {}
 
@@ -84,7 +88,6 @@ class GlusterFsDriverTestCase(test.TestCase):
             self.TEST_SHARES_CONFIG_FILE
         self._configuration.glusterfs_mount_point_base = \
             self.TEST_MNT_POINT_BASE
-        self._configuration.glusterfs_disk_util = 'df'
         self._configuration.glusterfs_sparsed_volumes = True
         self._configuration.glusterfs_qcow2_volumes = False
 
@@ -123,7 +126,8 @@ class GlusterFsDriverTestCase(test.TestCase):
 
     def test_local_path(self):
         """local_path common use case."""
-        glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
+        CONF.set_override("glusterfs_mount_point_base",
+                          self.TEST_MNT_POINT_BASE)
         drv = self._driver
 
         volume = DumbVolume()
@@ -229,7 +233,8 @@ class GlusterFsDriverTestCase(test.TestCase):
         mox.StubOutWithMock(brick.remotefs.remotefs.RemoteFsClient,
                             'get_mount_point')
 
-        glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
+        CONF.set_override("glusterfs_mount_point_base",
+                          self.TEST_MNT_POINT_BASE)
 
         brick.remotefs.remotefs.RemoteFsClient.\
             get_mount_point(self.TEST_EXPORT1).AndReturn(hashed_path)
@@ -250,8 +255,6 @@ class GlusterFsDriverTestCase(test.TestCase):
                   (df_total_size, df_avail)
         df_output = df_head + df_data
 
-        setattr(glusterfs.CONF, 'glusterfs_disk_util', 'df')
-
         mox.StubOutWithMock(drv, '_get_mount_point_for_share')
         drv._get_mount_point_for_share(self.TEST_EXPORT1).\
             AndReturn(self.TEST_MNT_POINT)
@@ -268,8 +271,6 @@ class GlusterFsDriverTestCase(test.TestCase):
 
         mox.VerifyAll()
 
-        delattr(glusterfs.CONF, 'glusterfs_disk_util')
-
     def test_load_shares_config(self):
         mox = self._mox
         drv = self._driver
@@ -381,7 +382,8 @@ class GlusterFsDriverTestCase(test.TestCase):
         """do_setup should throw error if shares config is not configured."""
         drv = self._driver
 
-        glusterfs.CONF.glusterfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+        CONF.set_override("glusterfs_shares_config",
+                          self.TEST_SHARES_CONFIG_FILE)
 
         self.assertRaises(exception.GlusterfsException,
                           drv.do_setup, IsA(context.RequestContext))
@@ -391,7 +393,8 @@ class GlusterFsDriverTestCase(test.TestCase):
         mox = self._mox
         drv = self._driver
 
-        glusterfs.CONF.glusterfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+        CONF.set_override("glusterfs_shares_config",
+                          self.TEST_SHARES_CONFIG_FILE)
 
         mox.StubOutWithMock(os.path, 'exists')
         os.path.exists(self.TEST_SHARES_CONFIG_FILE).AndReturn(True)
@@ -416,7 +419,8 @@ class GlusterFsDriverTestCase(test.TestCase):
         mox = self._mox
         drv = self._driver
 
-        glusterfs.CONF.glusterfs_shares_config = self.TEST_SHARES_CONFIG_FILE
+        CONF.set_override("glusterfs_shares_config",
+                          self.TEST_SHARES_CONFIG_FILE)
 
         self.stubs.Set(drv, '_load_shares_config',
                        self._fake_load_shares_config)
@@ -523,7 +527,7 @@ class GlusterFsDriverTestCase(test.TestCase):
         drv = self._driver
         volume = self._simple_volume()
 
-        setattr(glusterfs.CONF, 'glusterfs_sparsed_volumes', True)
+        CONF.set_override('glusterfs_sparsed_volumes', True)
 
         mox.StubOutWithMock(drv, '_create_sparsed_file')
         mox.StubOutWithMock(drv, '_set_rw_permissions_for_all')
@@ -537,8 +541,6 @@ class GlusterFsDriverTestCase(test.TestCase):
 
         mox.VerifyAll()
 
-        delattr(glusterfs.CONF, 'glusterfs_sparsed_volumes')
-
     def test_create_nonsparsed_volume(self):
         mox = self._mox
         drv = self._driver
@@ -1506,7 +1508,8 @@ class GlusterFsDriverTestCase(test.TestCase):
     def test_get_backing_chain_for_path(self):
         (mox, drv) = self._mox, self._driver
 
-        glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
+        CONF.set_override('glusterfs_mount_point_base',
+                          self.TEST_MNT_POINT_BASE)
 
         volume = self._simple_volume()
         vol_filename = volume['name']
index 27b38fc1cde7e48ad34f0ecb0d6255d43ea43eed..719ac88dadc4019a3ab53cd8dee0309c8d01e85b 100644 (file)
@@ -465,7 +465,7 @@ class NfsDriverTestCase(test.TestCase):
         drv = self._driver
         volume = self._simple_volume()
 
-        setattr(cfg.CONF, 'nfs_sparsed_volumes', True)
+        cfg.CONF.set_override('nfs_sparsed_volumes', True)
 
         mox.StubOutWithMock(drv, '_create_sparsed_file')
         mox.StubOutWithMock(drv, '_set_rw_permissions_for_all')
@@ -479,15 +479,13 @@ class NfsDriverTestCase(test.TestCase):
 
         mox.VerifyAll()
 
-        delattr(cfg.CONF, 'nfs_sparsed_volumes')
-
     def test_create_nonsparsed_volume(self):
         mox = self._mox
         drv = self._driver
         self.configuration.nfs_sparsed_volumes = False
         volume = self._simple_volume()
 
-        setattr(cfg.CONF, 'nfs_sparsed_volumes', False)
+        cfg.CONF.set_override('nfs_sparsed_volumes', False)
 
         mox.StubOutWithMock(drv, '_create_regular_file')
         mox.StubOutWithMock(drv, '_set_rw_permissions_for_all')
@@ -501,8 +499,6 @@ class NfsDriverTestCase(test.TestCase):
 
         mox.VerifyAll()
 
-        delattr(cfg.CONF, 'nfs_sparsed_volumes')
-
     def test_create_volume_should_ensure_nfs_mounted(self):
         """create_volume ensures shares provided in config are mounted."""
         mox = self._mox