Merge "Add Quotas.nova_get The scenario list the quotas for nova"

This commit is contained in:
Jenkins 2016-11-01 14:54:31 +00:00 committed by Gerrit Code Review
commit 454ba1d4a2
7 changed files with 90 additions and 1 deletions

View File

@ -35,6 +35,20 @@
failure_rate:
max: 0
Quotas.nova_get:
-
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
Quotas.nova_update:
-
args:

View File

@ -101,4 +101,16 @@ class NeutronUpdate(utils.QuotasScenario):
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)
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True, users=True)
@scenario.configure(context={"admin_cleanup": ["nova.quotas"]},
name="Quotas.nova_get")
class NovaGet(utils.QuotasScenario):
def run(self):
"""Get quotas for nova."""
self._get_quotas("nova", self.context["tenant"]["id"])

View File

@ -77,3 +77,13 @@ class QuotasScenario(scenario.OpenStackScenario):
quota[key] = random.randint(-1, max_quota)
quotas = {"body": {"quota": quota}}
return quotas
@atomic.action_timer("quotas.get_quotas")
def _get_quotas(self, component, tenant_id):
"""Get quotas for a project.
:param component: Openstack component for the quotas.
:param tenant_id: The project_id for the quotas to show.
:return: Get quotas for a project.
"""
return self.admin_clients(component).quotas.get(tenant_id)

View File

@ -0,0 +1,23 @@
{
"Quotas.nova_get": [
{
"runner": {
"type": "constant",
"times": 10,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,14 @@
---
Quotas.nova_get:
-
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -31,6 +31,12 @@ class QuotasTestCase(test.ScenarioTestCase):
"tenant": {"id": "fake"}
})
def test_nova_get(self):
scenario = quotas.NovaGet(self.context)
scenario._get_quotas = mock.MagicMock()
scenario.run()
scenario._get_quotas.assert_called_once_with("nova", "fake")
def test_nova_update(self):
scenario = quotas.NovaUpdate(self.context)
scenario._update_quotas = mock.MagicMock()

View File

@ -105,3 +105,13 @@ class QuotasScenarioTestCase(test.ScenarioTestCase):
tenant_id)
self._test_atomic_action_timer(scenario.atomic_actions(),
"quotas.delete_quotas")
def test__get_quotas(self):
tenant_id = "fake_tenant"
scenario = utils.QuotasScenario(self.context)
scenario._get_quotas("nova", tenant_id)
self.admin_clients("nova").quotas.get.assert_called_once_with(
tenant_id)
self._test_atomic_action_timer(scenario.atomic_actions(),
"quotas.get_quotas")