diff --git a/cinder/tests/unit/volume/drivers/test_rbd.py b/cinder/tests/unit/volume/drivers/test_rbd.py index 42eb1ca2b90..43a58573fbb 100644 --- a/cinder/tests/unit/volume/drivers/test_rbd.py +++ b/cinder/tests/unit/volume/drivers/test_rbd.py @@ -134,6 +134,14 @@ CEPH_MON_DUMP = """dumped monmap epoch 1 """ +def mock_driver_configuration(value): + if value == 'max_over_subscription_ratio': + return 1.0 + if value == 'reserved_percentage': + return 0 + return 'RBD' + + @ddt.ddt class RBDTestCase(test.TestCase): @@ -820,8 +828,9 @@ class RBDTestCase(test.TestCase): '"bytes_used":1546440971,"max_avail":28987613184,"objects":412}},' '{"name":"volumes","id":3,"stats":{"kb_used":0,"bytes_used":0,' '"max_avail":28987613184,"objects":0}}]}\n', '') - self.driver.configuration.safe_get = mock.Mock() - self.driver.configuration.safe_get.return_value = 'RBD' + + self.mock_object(self.driver.configuration, 'safe_get', + mock_driver_configuration) expected = dict( volume_backend_name='RBD', @@ -830,10 +839,10 @@ class RBDTestCase(test.TestCase): storage_protocol='ceph', total_capacity_gb=28.44, free_capacity_gb=27.0, - reserved_percentage='RBD', + reserved_percentage=0, thin_provisioning_support=True, provisioned_capacity_gb=0.0, - max_over_subscription_ratio='RBD', + max_over_subscription_ratio=1.0, multiattach=False) actual = self.driver.get_volume_stats(True) @@ -850,8 +859,8 @@ class RBDTestCase(test.TestCase): client.cluster.mon_command = mock.Mock() client.cluster.mon_command.return_value = (22, '', '') - self.driver.configuration.safe_get = mock.Mock() - self.driver.configuration.safe_get.return_value = 'RBD' + self.mock_object(self.driver.configuration, 'safe_get', + mock_driver_configuration) expected = dict(volume_backend_name='RBD', vendor_name='Open Source', @@ -859,10 +868,10 @@ class RBDTestCase(test.TestCase): storage_protocol='ceph', total_capacity_gb='unknown', free_capacity_gb='unknown', - reserved_percentage='RBD', + reserved_percentage=0, multiattach=False, provisioned_capacity_gb=0.0, - max_over_subscription_ratio='RBD', + max_over_subscription_ratio=1.0, thin_provisioning_support=True) actual = self.driver.get_volume_stats(True)