Merge "Moving of Quotas scenarios into separate classes"

This commit is contained in:
Jenkins 2016-08-31 14:39:39 +00:00 committed by Gerrit Code Review
commit 9ad9dfa186
2 changed files with 56 additions and 49 deletions

View File

@ -18,65 +18,73 @@ from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.quotas import utils
from rally.task import validation
"""Benchmark scenarios for quotas."""
class Quotas(utils.QuotasScenario):
"""Benchmark scenarios for quotas."""
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["nova.quotas"]})
def nova_update(self, max_quota=1024):
"""Update quotas for Nova.
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["nova.quotas"]},
name="Quotas.nova_update")
class NovaUpdate(utils.QuotasScenario):
"""Update quotas for Nova."""
:param max_quota: Max value to be updated for quota.
"""
def run(self, max_quota=1024):
""":param max_quota: Max value to be updated for quota."""
self._update_quotas("nova", self.context["tenant"]["id"],
max_quota)
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["nova.quotas"]})
def nova_update_and_delete(self, max_quota=1024):
"""Update and delete quotas for Nova.
:param max_quota: Max value to be updated for quota.
"""
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["nova.quotas"]},
name="Quotas.nova_update_and_delete")
class NovaUpdateAndDelete(utils.QuotasScenario):
"""Update and delete quotas for Nova."""
def run(self, max_quota=1024):
""":param max_quota: Max value to be updated for quota."""
self._update_quotas("nova", self.context["tenant"]["id"],
max_quota)
self._delete_quotas("nova", self.context["tenant"]["id"])
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["cinder.quotas"]})
def cinder_update(self, max_quota=1024):
"""Update quotas for Cinder.
:param max_quota: Max value to be updated for quota.
"""
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["cinder.quotas"]},
name="Quotas.cinder_update")
class CinderUpdate(utils.QuotasScenario):
"""Update quotas for Cinder."""
def run(self, max_quota=1024):
""":param max_quota: Max value to be updated for quota."""
self._update_quotas("cinder", self.context["tenant"]["id"],
max_quota)
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["cinder.quotas"]})
def cinder_update_and_delete(self, max_quota=1024):
"""Update and Delete quotas for Cinder.
:param max_quota: Max value to be updated for quota.
"""
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["cinder.quotas"]},
name="Quotas.cinder_update_and_delete")
class CinderUpdateAndDelete(utils.QuotasScenario):
"""Update and Delete quotas for Cinder."""
def run(self, max_quota=1024):
""":param max_quota: Max value to be updated for quota."""
self._update_quotas("cinder", self.context["tenant"]["id"],
max_quota)
self._delete_quotas("cinder", self.context["tenant"]["id"])
@validation.required_services(consts.Service.NEUTRON)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["neutron.quota"]})
def neutron_update(self, max_quota=1024):
"""Update quotas for neutron.
:param max_quota: Max value to be updated for quota.
"""
@validation.required_services(consts.Service.NEUTRON)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["neutron.quota"]},
name="Quotas.neutron_update")
class NeutronUpdate(utils.QuotasScenario):
"""Update quotas for neutron."""
def run(self, max_quota=1024):
""":param max_quota: Max value to be updated for quota."""
quota_update_fn = self.admin_clients("neutron").update_quota
self._update_quotas("neutron", self.context["tenant"]["id"],
max_quota, quota_update_fn)
max_quota, quota_update_fn)

View File

@ -32,39 +32,38 @@ class QuotasTestCase(test.ScenarioTestCase):
})
def test_nova_update(self):
scenario = quotas.Quotas(self.context)
scenario = quotas.NovaUpdate(self.context)
scenario._update_quotas = mock.MagicMock()
scenario.nova_update(max_quota=1024)
scenario.run(max_quota=1024)
scenario._update_quotas.assert_called_once_with("nova", "fake", 1024)
def test_nova_update_and_delete(self):
scenario = quotas.Quotas(self.context)
scenario = quotas.NovaUpdateAndDelete(self.context)
scenario._update_quotas = mock.MagicMock()
scenario._delete_quotas = mock.MagicMock()
scenario.nova_update_and_delete(max_quota=1024)
scenario.run(max_quota=1024)
scenario._update_quotas.assert_called_once_with("nova", "fake", 1024)
scenario._delete_quotas.assert_called_once_with("nova", "fake")
def test_cinder_update(self):
scenario = quotas.Quotas(self.context)
scenario = quotas.CinderUpdate(self.context)
scenario._update_quotas = mock.MagicMock()
scenario.cinder_update(max_quota=1024)
scenario.run(max_quota=1024)
scenario._update_quotas.assert_called_once_with("cinder", "fake", 1024)
def test_cinder_update_and_delete(self):
scenario = quotas.Quotas(self.context)
scenario = quotas.CinderUpdateAndDelete(self.context)
scenario._update_quotas = mock.MagicMock()
scenario._delete_quotas = mock.MagicMock()
scenario.cinder_update_and_delete(max_quota=1024)
scenario.run(max_quota=1024)
scenario._update_quotas.assert_called_once_with("cinder", "fake", 1024)
scenario._delete_quotas.assert_called_once_with("cinder", "fake")
def test_neutron_update(self):
scenario = quotas.Quotas(self.context)
scenario = quotas.NeutronUpdate(self.context)
scenario._update_quotas = mock.MagicMock()
mock_quota_update_fn = self.admin_clients("neutron").update_quota
scenario.neutron_update(max_quota=1024)
scenario.run(max_quota=1024)
scenario._update_quotas.assert_called_once_with("neutron", "fake",
1024,
mock_quota_update_fn)