Merge "Add cinder.CreateAndGetQos scenario"

This commit is contained in:
Jenkins 2017-04-20 13:26:41 +00:00 committed by Gerrit Code Review
commit 2348710bab
9 changed files with 142 additions and 1 deletions

View File

@ -1006,3 +1006,22 @@
sla:
failure_rate:
max: 0
CinderQos.create_and_get_qos:
-
args:
specs:
consumer: "both"
write_iops_sec: "10"
read_iops_sec: "1000"
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -39,3 +39,18 @@ class CreateAndListQos(cinder_utils.CinderBasic):
"created qos:{}\n"
"Pool of qos:{}").format(qos, pool_list)
self.assertIn(qos, pool_list, err_msg=msg)
@validation.restricted_parameters("name")
@validation.required_services(consts.Service.CINDER)
@validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderQos.create_and_get_qos")
class CreateAndGetQos(cinder_utils.CinderBasic):
def run(self, specs):
"""Create a qos, then get details of the qos.
:param specs: A dict of key/value pairs to create qos
"""
qos = self.admin_cinder.create_qos(specs)
self.admin_cinder.get_qos(qos.id)

View File

@ -207,6 +207,15 @@ class BlockStorage(service.UnifiedOpenStackService):
"""
return self._impl.list_qos(search_opts)
@service.should_be_overridden
def get_qos(self, qos_id):
"""Get a specific qos specs.
:param qos_id: The ID of the :class:`QoSSpecs` to get.
:rtype: :class:`QoSSpecs`
"""
return self._impl.get_qos(qos_id)
@service.should_be_overridden
def create_snapshot(self, volume_id, force=False,
name=None, description=None, metadata=None):

View File

@ -225,6 +225,16 @@ class CinderMixin(object):
with atomic.ActionTimer(self, aname):
return self._get_client().qos_specs.list(search_opts)
def get_qos(self, qos_id):
"""Get a specific qos specs.
:param qos_id: The ID of the :class: 'QoSSpecs' to get
:rtype: :class: 'QoSSpecs'
"""
aname = "cinder_v%s.get_qos" % self.version
with atomic.ActionTimer(self, aname):
return self._get_client().qos_specs.get(qos_id)
def delete_snapshot(self, snapshot):
"""Delete the given snapshot.
@ -487,6 +497,14 @@ class UnifiedCinderMixin(object):
"""
return self._impl.list_qos(search_opts)
def get_qos(self, qos_id):
"""Get a specific qos specs.
:param qos_id: The ID of the :class: 'QoSSpecs' to get
:rtype: :class: 'QoSSpecs'
"""
return self._impl.get_qos(qos_id)
def delete_snapshot(self, snapshot):
"""Delete the given backup.

View File

@ -0,0 +1,29 @@
{
"CinderQos.create_and_get_qos": [
{
"args": {
"specs": {
"consumer": "both",
"write_iops_sec": "10",
"read_iops_sec": "1000"
}
},
"runner": {
"type": "constant",
"times": 5,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,19 @@
---
CinderQos.create_and_get_qos:
-
args:
specs:
consumer: "both"
write_iops_sec: "10"
read_iops_sec: "1000"
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -43,7 +43,6 @@ class CinderQosTestCase(test.ScenarioTestCase):
def test_create_and_list_qos(self):
mock_service = self.mock_cinder.return_value
qos = mock.MagicMock()
qos = mock.MagicMock()
list_qos = [mock.MagicMock(),
mock.MagicMock(),
qos]
@ -78,3 +77,17 @@ class CinderQosTestCase(test.ScenarioTestCase):
scenario.run, specs)
mock_service.create_qos.assert_called_once_with(specs)
mock_service.list_qos.assert_called_once_with()
def test_create_and_get_qos(self):
mock_service = self.mock_cinder.return_value
qos = mock.MagicMock()
specs = {"consumer": "both",
"write_iops_sec": "10",
"read_iops_sec": "1000"}
scenario = qos_specs.CreateAndGetQos(self._get_context())
mock_service.create_qos.return_value = qos
scenario.run(specs)
mock_service.create_qos.assert_called_once_with(specs)
mock_service.get_qos.assert_called_once_with(qos.id)

View File

@ -131,6 +131,12 @@ class BlockTestCase(test.TestCase):
)
self.service._impl.list_qos.assert_called_once_with(True)
def test_get_qos(self):
self.assertEqual(
self.service._impl.get_qos.return_value,
self.service.get_qos("qos"))
self.service._impl.get_qos.assert_called_once_with("qos")
def test_create_snapshot(self):
self.assertEqual(
self.service._impl.create_snapshot.return_value,

View File

@ -251,6 +251,13 @@ class CinderMixinTestCase(test.ScenarioTestCase):
)
self.cinder.qos_specs.list.assert_called_once_with(True)
def test_get_qos(self):
result = self.service.get_qos("qos")
self.assertEqual(
self.cinder.qos_specs.get.return_value,
result)
self.cinder.qos_specs.get.assert_called_once_with("qos")
def test_delete_snapshot(self):
snapshot = mock.Mock()
self.service.delete_snapshot(snapshot)
@ -493,6 +500,12 @@ class UnifiedCinderMixinTestCase(test.TestCase):
)
self.service._impl.list_qos.assert_called_once_with(True)
def test_get_qos(self):
self.assertEqual(
self.service._impl.get_qos.return_value,
self.service.get_qos("qos"))
self.service._impl.get_qos.assert_called_once_with("qos")
def test_delete_snapshot(self):
self.service.delete_snapshot("snapshot")
self.service._impl.delete_snapshot.assert_called_once_with("snapshot")