diff --git a/rally-jobs/nova.yaml b/rally-jobs/nova.yaml index ffa449dc79..6c409aa9ea 100755 --- a/rally-jobs/nova.yaml +++ b/rally-jobs/nova.yaml @@ -709,6 +709,22 @@ failure_rate: max: 0 + NovaHypervisors.list_and_search_hypervisors: + - + args: + detailed: True + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + NovaImages.list_images: - args: diff --git a/rally/plugins/openstack/scenarios/nova/hypervisors.py b/rally/plugins/openstack/scenarios/nova/hypervisors.py index 2691bef621..883c7d0ffb 100644 --- a/rally/plugins/openstack/scenarios/nova/hypervisors.py +++ b/rally/plugins/openstack/scenarios/nova/hypervisors.py @@ -59,7 +59,7 @@ class ListAndGetHypervisors(utils.NovaScenario): with atomic.ActionTimer(self, "nova.get_hypervisor"): for hypervisor in hypervisors: - self._get_hypervisor(hypervisor) + self._get_hypervisor(hypervisor, atomic_action=False) @validation.required_services(consts.Service.NOVA) @@ -95,3 +95,28 @@ class ListAndGetUptimeHypervisors(utils.NovaScenario): with atomic.ActionTimer(self, "nova.uptime_hypervisor"): for hypervisor in hypervisors: self._uptime_hypervisor(hypervisor, atomic_action=False) + + +@validation.required_services(consts.Service.NOVA) +@validation.required_openstack(admin=True) +@scenario.configure(name="NovaHypervisors.list_and_search_hypervisors") +class ListAndSearchHypervisors(utils.NovaScenario): + def run(self, detailed=True): + """List all servers belonging to specific hypervisor. + + The scenario first list all hypervisors,then find its hostname, + then list all servers belonging to the hypervisor + + Measure the "nova hypervisor-servers " command performance. + + :param detailed: True if the hypervisor listing should contain + detailed information about all of them + """ + hypervisors = self._list_hypervisors(detailed) + + with atomic.ActionTimer(self, + "nova.search_%s_hypervisors" % len(hypervisors) + ): + for hypervisor in hypervisors: + self._search_hypervisors(hypervisor.hypervisor_hostname, + atomic_action=False) diff --git a/rally/plugins/openstack/scenarios/nova/utils.py b/rally/plugins/openstack/scenarios/nova/utils.py index 35610b91e0..8e18ca30e2 100755 --- a/rally/plugins/openstack/scenarios/nova/utils.py +++ b/rally/plugins/openstack/scenarios/nova/utils.py @@ -898,6 +898,20 @@ class NovaScenario(scenario.OpenStackScenario): """ return self.admin_clients("nova").hypervisors.get(hypervisor) + @atomic.optional_action_timer("nova.search_hypervisors") + def _search_hypervisors(self, hypervisor_match, servers=False): + """List all servers belonging to specific hypervisor. + + :param hypervisor_match: Hypervisor's host name. + :param servers: If True, server information is also retrieved. + :param atomic_action: True if this is atomic action. added and + handled by the optional_action_timer() + decorator. + :returns: Hypervisor object + """ + return self.admin_clients("nova").hypervisors.search(hypervisor_match, + servers=servers) + @atomic.action_timer("nova.lock_server") def _lock_server(self, server): """Lock the given server. diff --git a/samples/tasks/scenarios/nova/list-and-search-hypervisor.json b/samples/tasks/scenarios/nova/list-and-search-hypervisor.json new file mode 100644 index 0000000000..17e2f26386 --- /dev/null +++ b/samples/tasks/scenarios/nova/list-and-search-hypervisor.json @@ -0,0 +1,25 @@ +{ + "NovaHypervisors.list_and_search_hypervisors": [ + { + "args": { + "detailed": true + }, + "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/list-and-search-hypervisor.yaml b/samples/tasks/scenarios/nova/list-and-search-hypervisor.yaml new file mode 100644 index 0000000000..d4fdb45f0f --- /dev/null +++ b/samples/tasks/scenarios/nova/list-and-search-hypervisor.yaml @@ -0,0 +1,16 @@ +--- + NovaHypervisors.list_and_search_hypervisors: + - + args: + detailed: True + 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 45c793d457..ad99999132 100644 --- a/tests/unit/plugins/openstack/scenarios/nova/test_hypervisors.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_hypervisors.py @@ -55,3 +55,17 @@ class NovaHypervisorsTestCase(test.ScenarioTestCase): scenario._uptime_hypervisor.assert_called_once_with(hypervisor) self._test_atomic_action_timer(scenario.atomic_actions(), "nova.uptime_hypervisor") + + def test_list_and_search_hypervisors(self): + fake_hypervisors = [mock.Mock(hypervisor_hostname="fake_hostname")] + scenario = hypervisors.ListAndSearchHypervisors(self.context) + scenario._list_hypervisors = mock.MagicMock( + return_value=fake_hypervisors) + scenario._search_hypervisors = mock.MagicMock() + scenario.run(detailed=False) + + scenario._list_hypervisors.assert_called_once_with(False) + scenario._search_hypervisors.assert_called_once_with( + "fake_hostname", atomic_action=False) + self._test_atomic_action_timer(scenario.atomic_actions(), + "nova.search_1_hypervisors") diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py index 96d76c9282..1010f32f18 100755 --- a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py @@ -880,6 +880,15 @@ class NovaScenarioTestCase(test.ScenarioTestCase): self._test_atomic_action_timer(nova_scenario.atomic_actions(), "nova.get_hypervisor") + def test__search_hypervisors(self): + nova_scenario = utils.NovaScenario() + nova_scenario._search_hypervisors("fake_hostname", servers=False) + + self.admin_clients("nova").hypervisors.search.assert_called_once_with( + "fake_hostname", servers=False) + self._test_atomic_action_timer(nova_scenario.atomic_actions(), + "nova.search_hypervisors") + def test__list_images(self): nova_scenario = utils.NovaScenario() result = nova_scenario._list_images(detailed=False, fakearg="fakearg")