diff --git a/rally/plugins/openstack/services/storage/block.py b/rally/plugins/openstack/services/storage/block.py index a305b755..1a0ade1f 100644 --- a/rally/plugins/openstack/services/storage/block.py +++ b/rally/plugins/openstack/services/storage/block.py @@ -34,6 +34,7 @@ VolumeTransfer = collections.namedtuple("VolumeTransfer", ["id", "name", "auth_key"]) VolumeEncryptionType = collections.namedtuple("VolumeEncryptionType", ["id", "volume_type_id"]) +QoSSpecs = collections.namedtuple("QoSSpecs", ["id", "name"]) class BlockStorage(service.UnifiedOpenStackService): diff --git a/rally/plugins/openstack/services/storage/cinder_common.py b/rally/plugins/openstack/services/storage/cinder_common.py index a9c1d74a..cbd055af 100644 --- a/rally/plugins/openstack/services/storage/cinder_common.py +++ b/rally/plugins/openstack/services/storage/cinder_common.py @@ -418,6 +418,10 @@ class UnifiedCinderMixin(object): volume_id=transfer.volume_id, auth_key=auth_key) + @staticmethod + def _unify_qos(qos): + return block.QoSSpecs(id=qos.id, name=qos.name) + @staticmethod def _unify_encryption_type(encryption_type): return block.VolumeEncryptionType( @@ -487,7 +491,7 @@ class UnifiedCinderMixin(object): :param specs: A dict of key/value pairs to be set :rtype: :class:'QoSSpecs' """ - return self._impl.create_qos(specs) + return self._unify_qos(self._impl.create_qos(specs)) def list_qos(self, search_opts=None): """Get a list of all qos specs. @@ -495,7 +499,8 @@ class UnifiedCinderMixin(object): :param search_opts: search options :rtype: list of :class: 'QoSpecs' """ - return self._impl.list_qos(search_opts) + return [self._unify_qos(qos) + for qos in self._impl.list_qos(search_opts)] def get_qos(self, qos_id): """Get a specific qos specs. @@ -503,7 +508,7 @@ class UnifiedCinderMixin(object): :param qos_id: The ID of the :class: 'QoSSpecs' to get :rtype: :class: 'QoSSpecs' """ - return self._impl.get_qos(qos_id) + return self._unify_qos(self._impl.get_qos(qos_id)) def delete_snapshot(self, snapshot): """Delete the given backup. diff --git a/tests/unit/plugins/openstack/services/storage/test_cinder_common.py b/tests/unit/plugins/openstack/services/storage/test_cinder_common.py index e70f2ef7..ed307a47 100644 --- a/tests/unit/plugins/openstack/services/storage/test_cinder_common.py +++ b/tests/unit/plugins/openstack/services/storage/test_cinder_common.py @@ -439,6 +439,14 @@ class UnifiedCinderMixinTestCase(test.TestCase): self.assertEqual("volume", transfer.volume_id) self.assertEqual("st", transfer.status) + def test__unify_qos(self): + class Qos(object): + id = 1 + name = "transfer" + qos = self.service._unify_qos(Qos()) + self.assertEqual(1, qos.id) + self.assertEqual("transfer", qos.name) + def test__unify_encryption_type(self): class SomeEncryptionType(object): encryption_id = 1 @@ -487,24 +495,35 @@ class UnifiedCinderMixinTestCase(test.TestCase): specs = {"consumer": "both", "write_iops_sec": "10", "read_iops_sec": "1000"} + self.service._unify_qos = mock.MagicMock() self.assertEqual( - self.service._impl.create_qos.return_value, + self.service._unify_qos.return_value, self.service.create_qos(specs) ) self.service._impl.create_qos.assert_called_once_with(specs) + self.service._unify_qos.assert_called_once_with( + self.service._impl.create_qos.return_value + ) def test_list_qos(self): + self.service._unify_qos = mock.MagicMock() + self.service._impl.list_qos.return_value = ["qos"] self.assertEqual( - self.service._impl.list_qos.return_value, + [self.service._unify_qos.return_value], self.service.list_qos(True) ) self.service._impl.list_qos.assert_called_once_with(True) + self.service._unify_qos.assert_called_once_with("qos") def test_get_qos(self): + self.service._unify_qos = mock.MagicMock() self.assertEqual( - self.service._impl.get_qos.return_value, + self.service._unify_qos.return_value, self.service.get_qos("qos")) self.service._impl.get_qos.assert_called_once_with("qos") + self.service._unify_qos.assert_called_once_with( + self.service._impl.get_qos.return_value + ) def test_delete_snapshot(self): self.service.delete_snapshot("snapshot")