From 691e1215109af9d2a09a8ff9dabba7aaf0e8e593 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 29 Apr 2015 14:03:09 -0500 Subject: [PATCH] Add Nova scenario to list hypervisors Benchmarks the 'nova list-hypervisors' command. Change-Id: I64243de369ac02afb7dcf246b3d8e28d7c43d172 --- rally-jobs/rally.yaml | 12 ++++++ rally/benchmark/scenarios/nova/hypervisors.py | 40 +++++++++++++++++++ rally/benchmark/scenarios/nova/utils.py | 5 +++ .../scenarios/nova/list-hypervisors.json | 14 +++++++ .../scenarios/nova/list-hypervisors.yaml | 9 +++++ .../scenarios/nova/test_hypervisors.py | 31 ++++++++++++++ .../benchmark/scenarios/nova/test_utils.py | 8 ++++ 7 files changed, 119 insertions(+) create mode 100644 rally/benchmark/scenarios/nova/hypervisors.py create mode 100644 samples/tasks/scenarios/nova/list-hypervisors.json create mode 100644 samples/tasks/scenarios/nova/list-hypervisors.yaml create mode 100644 tests/unit/benchmark/scenarios/nova/test_hypervisors.py diff --git a/rally-jobs/rally.yaml b/rally-jobs/rally.yaml index c67f21551a..f51c4ac386 100755 --- a/rally-jobs/rally.yaml +++ b/rally-jobs/rally.yaml @@ -1336,6 +1336,18 @@ failure_rate: max: 0 + NovaHypervisors.list_hypervisors: + - + args: + detailed: True + runner: + type: "constant" + times: 5 + concurrency: 2 + sla: + failure_rate: + max: 0 + VMTasks.boot_runcommand_delete: - args: diff --git a/rally/benchmark/scenarios/nova/hypervisors.py b/rally/benchmark/scenarios/nova/hypervisors.py new file mode 100644 index 0000000000..0a161e96a0 --- /dev/null +++ b/rally/benchmark/scenarios/nova/hypervisors.py @@ -0,0 +1,40 @@ +# Copyright 2015 Cisco Systems Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from rally.benchmark.scenarios import base +from rally.benchmark.scenarios.nova import utils +from rally.benchmark import validation +from rally.common import log as logging +from rally import consts + + +LOG = logging.getLogger(__name__) + + +class NovaHypervisors(utils.NovaScenario): + """Benchmark scenarios for Nova hypervisors.""" + + @validation.required_services(consts.Service.NOVA) + @validation.required_openstack(admin=True) + @base.scenario() + def list_hypervisors(self, detailed=True): + """List hypervisors. + + Measure the "nova hypervisor-list" command performance. + + :param detailed: True if the hypervisor listing should contain + detailed information about all of them + """ + self._list_hypervisors(detailed) diff --git a/rally/benchmark/scenarios/nova/utils.py b/rally/benchmark/scenarios/nova/utils.py index 0363c7d320..05cdf2df5b 100644 --- a/rally/benchmark/scenarios/nova/utils.py +++ b/rally/benchmark/scenarios/nova/utils.py @@ -754,3 +754,8 @@ class NovaScenario(base.Scenario): def _delete_floating_ips_bulk(self, ip_range): """Delete floating IPs by range.""" return self.admin_clients("nova").floating_ips_bulk.delete(ip_range) + + @base.atomic_action_timer("nova.list_hypervisors") + def _list_hypervisors(self, detailed=True): + """List hypervisors.""" + return self.admin_clients("nova").hypervisors.list(detailed) diff --git a/samples/tasks/scenarios/nova/list-hypervisors.json b/samples/tasks/scenarios/nova/list-hypervisors.json new file mode 100644 index 0000000000..d4705f876d --- /dev/null +++ b/samples/tasks/scenarios/nova/list-hypervisors.json @@ -0,0 +1,14 @@ +{ + "NovaHypervisors.list_hypervisors": [ + { + "runner": { + "type": "constant", + "concurrency": 2, + "times": 10 + }, + "args": { + "detailed": true + } + } + ] +} \ No newline at end of file diff --git a/samples/tasks/scenarios/nova/list-hypervisors.yaml b/samples/tasks/scenarios/nova/list-hypervisors.yaml new file mode 100644 index 0000000000..746ce92b0e --- /dev/null +++ b/samples/tasks/scenarios/nova/list-hypervisors.yaml @@ -0,0 +1,9 @@ +--- + NovaHypervisors.list_hypervisors: + - + args: + detailed: True + runner: + type: "constant" + times: 10 + concurrency: 2 diff --git a/tests/unit/benchmark/scenarios/nova/test_hypervisors.py b/tests/unit/benchmark/scenarios/nova/test_hypervisors.py new file mode 100644 index 0000000000..7be1696472 --- /dev/null +++ b/tests/unit/benchmark/scenarios/nova/test_hypervisors.py @@ -0,0 +1,31 @@ +# Copyright 2013 Cisco Systems Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import mock + +from rally.benchmark.scenarios.nova import hypervisors +from tests.unit import test + + +NOVA_HYPERVISORS_MODULE = "rally.benchmark.scenarios.nova.hypervisors" +NOVA_HYPERVISORS = NOVA_HYPERVISORS_MODULE + ".NovaHypervisors" + + +class NovaHypervisorsTestCase(test.TestCase): + def test_list_hypervisors(self): + scenario = hypervisors.NovaHypervisors() + scenario._list_hypervisors = mock.Mock() + scenario.list_hypervisors(detailed=False) + scenario._list_hypervisors.assert_called_once_with(False) diff --git a/tests/unit/benchmark/scenarios/nova/test_utils.py b/tests/unit/benchmark/scenarios/nova/test_utils.py index fba2186b7a..0b88d6ac86 100644 --- a/tests/unit/benchmark/scenarios/nova/test_utils.py +++ b/tests/unit/benchmark/scenarios/nova/test_utils.py @@ -795,3 +795,11 @@ class NovaScenarioTestCase(test.TestCase): fake_cidr) self._test_atomic_action_timer(nova_scenario.atomic_actions(), "nova.delete_floating_ips_bulk") + + @mock.patch(NOVA_UTILS + ".NovaScenario.admin_clients") + def test__list_hypervisors(self, mock_clients): + nova_scenario = utils.NovaScenario() + nova_scenario._list_hypervisors(detailed=False) + mock_clients("nova").hypervisors.list.assert_called_once_with(False) + self._test_atomic_action_timer(nova_scenario.atomic_actions(), + "nova.list_hypervisors")