diff --git a/rally-jobs/nova.yaml b/rally-jobs/nova.yaml index ffa449dc..bc46c83e 100755 --- a/rally-jobs/nova.yaml +++ b/rally-jobs/nova.yaml @@ -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: diff --git a/rally/plugins/openstack/scenarios/quotas/quotas.py b/rally/plugins/openstack/scenarios/quotas/quotas.py index 4c34d486..531ab37c 100644 --- a/rally/plugins/openstack/scenarios/quotas/quotas.py +++ b/rally/plugins/openstack/scenarios/quotas/quotas.py @@ -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) \ No newline at end of file + 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"]) diff --git a/rally/plugins/openstack/scenarios/quotas/utils.py b/rally/plugins/openstack/scenarios/quotas/utils.py index b35eaf28..5c687bdf 100644 --- a/rally/plugins/openstack/scenarios/quotas/utils.py +++ b/rally/plugins/openstack/scenarios/quotas/utils.py @@ -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) diff --git a/samples/tasks/scenarios/quotas/nova-get.json b/samples/tasks/scenarios/quotas/nova-get.json new file mode 100644 index 00000000..86d99fbd --- /dev/null +++ b/samples/tasks/scenarios/quotas/nova-get.json @@ -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 + } + } + + } + ] +} diff --git a/samples/tasks/scenarios/quotas/nova-get.yaml b/samples/tasks/scenarios/quotas/nova-get.yaml new file mode 100644 index 00000000..15602ba4 --- /dev/null +++ b/samples/tasks/scenarios/quotas/nova-get.yaml @@ -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 diff --git a/tests/unit/plugins/openstack/scenarios/quotas/test_quotas.py b/tests/unit/plugins/openstack/scenarios/quotas/test_quotas.py index 25ea0edc..c4dfef2c 100644 --- a/tests/unit/plugins/openstack/scenarios/quotas/test_quotas.py +++ b/tests/unit/plugins/openstack/scenarios/quotas/test_quotas.py @@ -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() diff --git a/tests/unit/plugins/openstack/scenarios/quotas/test_utils.py b/tests/unit/plugins/openstack/scenarios/quotas/test_utils.py index 47a88bef..bb165892 100644 --- a/tests/unit/plugins/openstack/scenarios/quotas/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/quotas/test_utils.py @@ -106,3 +106,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")