diff --git a/rally-jobs/nova.yaml b/rally-jobs/nova.yaml index 0d9a0cc5..cc7a61dc 100755 --- a/rally-jobs/nova.yaml +++ b/rally-jobs/nova.yaml @@ -662,6 +662,20 @@ failure_rate: max: 0 + NovaHypervisors.statistics_hypervisors: + - + args: {} + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 NovaHypervisors.list_and_get_hypervisors: - diff --git a/rally/plugins/openstack/scenarios/nova/hypervisors.py b/rally/plugins/openstack/scenarios/nova/hypervisors.py index ff22749a..2691bef6 100644 --- a/rally/plugins/openstack/scenarios/nova/hypervisors.py +++ b/rally/plugins/openstack/scenarios/nova/hypervisors.py @@ -62,6 +62,19 @@ class ListAndGetHypervisors(utils.NovaScenario): self._get_hypervisor(hypervisor) +@validation.required_services(consts.Service.NOVA) +@validation.required_openstack(admin=True) +@scenario.configure(name="NovaHypervisors.statistics_hypervisors") +class StatisticsHypervisors(utils.NovaScenario): + + def run(self): + """Get hypervisor statistics over all compute nodes. + + Measure the "nova hypervisor-stats" command performance. + """ + self._statistics_hypervisors() + + @validation.required_services(consts.Service.NOVA) @validation.required_openstack(admin=True) @scenario.configure(name="NovaHypervisors.list_and_get_uptime_hypervisors") diff --git a/rally/plugins/openstack/scenarios/nova/utils.py b/rally/plugins/openstack/scenarios/nova/utils.py index a51575fc..5f0b7dbc 100755 --- a/rally/plugins/openstack/scenarios/nova/utils.py +++ b/rally/plugins/openstack/scenarios/nova/utils.py @@ -863,6 +863,14 @@ class NovaScenario(scenario.OpenStackScenario): """List hypervisors.""" return self.admin_clients("nova").hypervisors.list(detailed) + @atomic.action_timer("nova.statistics_hypervisors") + def _statistics_hypervisors(self): + """Get hypervisor statistics over all compute nodes. + + :returns: Hypervisor statistics + """ + return self.admin_clients("nova").hypervisors.statistics() + @atomic.optional_action_timer("nova.get_hypervisor") def _get_hypervisor(self, hypervisor): """Get a specific hypervisor. diff --git a/samples/tasks/scenarios/nova/statistics-hypervisors.json b/samples/tasks/scenarios/nova/statistics-hypervisors.json new file mode 100644 index 00000000..f04dad62 --- /dev/null +++ b/samples/tasks/scenarios/nova/statistics-hypervisors.json @@ -0,0 +1,23 @@ +{ + "NovaHypervisors.statistics_hypervisors": [ + { + "args": {}, + "runner": { + "type": "constant", + "concurrency": 2, + "times": 2 + }, + "context": { + "users": { + "tenants": 3, + "users_per_tenant": 2 + } + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/nova/statistics-hypervisors.yaml b/samples/tasks/scenarios/nova/statistics-hypervisors.yaml new file mode 100644 index 00000000..e3939a81 --- /dev/null +++ b/samples/tasks/scenarios/nova/statistics-hypervisors.yaml @@ -0,0 +1,15 @@ +--- + NovaHypervisors.statistics_hypervisors: + - + args: {} + runner: + type: "constant" + times: 2 + concurrency: 2 + context: + users: + tenants: 3 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_hypervisors.py b/tests/unit/plugins/openstack/scenarios/nova/test_hypervisors.py index 53aef0d7..45c793d4 100644 --- a/tests/unit/plugins/openstack/scenarios/nova/test_hypervisors.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_hypervisors.py @@ -38,6 +38,12 @@ class NovaHypervisorsTestCase(test.ScenarioTestCase): self._test_atomic_action_timer(scenario.atomic_actions(), "nova.get_hypervisor") + def test_statistics_hypervisors(self): + scenario = hypervisors.StatisticsHypervisors(self.context) + scenario._statistics_hypervisors = mock.Mock() + scenario.run() + scenario._statistics_hypervisors.assert_called_once_with() + def test_list_and_get_uptime_hypervisors(self): scenario = hypervisors.ListAndGetUptimeHypervisors(self.context) scenario._list_hypervisors = mock.MagicMock(detailed=False) diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py index aaf02a4c..62adba4d 100755 --- a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py @@ -841,6 +841,17 @@ class NovaScenarioTestCase(test.ScenarioTestCase): self._test_atomic_action_timer(nova_scenario.atomic_actions(), "nova.list_hypervisors") + def test__statistics_hypervisors(self): + nova_scenario = utils.NovaScenario() + result = nova_scenario._statistics_hypervisors() + self.assertEqual( + self.admin_clients("nova").hypervisors.statistics.return_value, + result) + (self.admin_clients("nova").hypervisors.statistics. + assert_called_once_with()) + self._test_atomic_action_timer(nova_scenario.atomic_actions(), + "nova.statistics_hypervisors") + def test__get_hypervisor(self): hypervisor = mock.Mock() nova_scenario = utils.NovaScenario()