Expand Nova API benchmark in Rally

Add support for listing nova hosts, agents, availability-zones
and aggregates.

blueprint extend-api-benchmark-in-nova-scenarios

Change-Id: I1facd17719299128e758334b468c01a83518889e
This commit is contained in:
Piyush Raman Srivastava 2016-02-16 00:57:36 -08:00
parent bf38ddbdc1
commit 5c289b9e6e
19 changed files with 471 additions and 0 deletions

View File

@ -876,3 +876,45 @@
sla: sla:
failure_rate: failure_rate:
max: 0 max: 0
NovaAgents.list_agents:
-
runner:
type: "constant"
concurrency: 2
times: 5
sla:
failure_rate:
max: 0
NovaAggregates.list_aggregates:
-
runner:
type: "constant"
concurrency: 2
times : 5
sla:
failure_rate:
max: 0
NovaAvailabilityZones.list_availability_zones:
-
args:
detailed: true
runner:
type: "constant"
concurrency: 2
times: 5
sla:
failure_rate:
max: 0
NovaHosts.list_hosts:
-
runner:
type: "constant"
concurrency: 2
times: 5
sla:
failure_rate:
max: 0

View File

@ -0,0 +1,41 @@
# Copyright 2016 IBM Corp.
# 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.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils
from rally.task import validation
LOG = logging.getLogger(__name__)
class NovaAgents(utils.NovaScenario):
"""Benchmark scenarios for Nova agents."""
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure()
def list_agents(self, hypervisor=None):
"""List all builds.
Measure the "nova agent-list" command performance.
:param hypervisor: List agent builds on a specific hypervisor.
None (default value) means list for all
hypervisors
"""
self._list_agents(hypervisor)

View File

@ -0,0 +1,37 @@
# Copyright 2016 IBM Corp.
# 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.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils
from rally.task import validation
LOG = logging.getLogger(__name__)
class NovaAggregates(utils.NovaScenario):
"""Benchmark scenarios for Nova aggregates."""
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure()
def list_aggregates(self):
"""List all nova aggregates.
Measure the "nova aggregate-list" command performance.
"""
self._list_aggregates()

View File

@ -0,0 +1,40 @@
# Copyright 2016 IBM Corp.
# 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.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils
from rally.task import validation
LOG = logging.getLogger(__name__)
class NovaAvailabilityZones(utils.NovaScenario):
"""Benchmark scenarios for Nova availability-zones."""
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure()
def list_availability_zones(self, detailed=True):
"""List all availability zones.
Measure the "nova availability-zone-list" command performance.
:param detailed: True if the availability-zone listing should contain
detailed information about all of them
"""
self._list_availability_zones(detailed)

View File

@ -0,0 +1,41 @@
# Copyright 2016 IBM Corp
# 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.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils
from rally.task import validation
LOG = logging.getLogger(__name__)
class NovaHosts(utils.NovaScenario):
"""Benchmark scenarios for Nova hosts."""
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure()
def list_hosts(self, zone=None):
"""List all nova hosts.
Measure the "nova host-list" command performance.
:param zone: List nova hosts in an availibility-zone.
None (default value) means list hosts in all
availibility-zones
"""
self._list_hosts(zone)

View File

@ -903,3 +903,37 @@ class NovaScenario(scenario.OpenStackScenario):
:returns: flavors list :returns: flavors list
""" """
return self.clients("nova").flavors.list(detailed, **kwargs) return self.clients("nova").flavors.list(detailed, **kwargs)
@atomic.action_timer("nova.list_agents")
def _list_agents(self, hypervisor=None):
"""List all nova-agent builds.
:param hypervisor: The nova-hypervisor ID on which we need to list all
the builds
:returns: Nova-agent build list
"""
return self.admin_clients("nova").agents.list(hypervisor)
@atomic.action_timer("nova.list_aggregates")
def _list_aggregates(self):
"""Returns list of all os-aggregates."""
return self.admin_clients("nova").aggregates.list()
@atomic.action_timer("nova.list_availbility_zones")
def _list_availability_zones(self, detailed=True):
"""List availability-zones.
:param detailed: True if the availability-zone listing should contain
detailed information
:returns: Availability-zone list
"""
return self.admin_clients("nova").availability_zones.list(detailed)
@atomic.action_timer("nova.list_hosts")
def _list_hosts(self, zone=None):
"""List nova hosts.
:param zone: List all hosts in the given nova availability-zone ID
:returns: Nova host list
"""
return self.admin_clients("nova").hosts.list(zone)

View File

@ -0,0 +1,11 @@
{
"NovaAgents.list_agents": [
{
"runner": {
"type": "constant",
"concurrency": 2,
"times": 10
}
}
]
}

View File

@ -0,0 +1,7 @@
---
NovaAgents.list_agents:
-
runner:
type: "constant"
concurrency: 2
times: 10

View File

@ -0,0 +1,11 @@
{
"NovaAggregates.list_aggregates": [
{
"runner": {
"type": "constant",
"concurrency": 2,
"times": 10
}
}
]
}

View File

@ -0,0 +1,7 @@
---
NovaAggregates.list_aggregates:
-
runner:
type: "constant"
concurrency: 2
times : 10

View File

@ -0,0 +1,14 @@
{
"NovaAvailabilityZones.list_availability_zones": [
{
"runner": {
"type": "constant",
"concurrency": 2,
"times": 10
},
"args": {
"detailed": true
}
}
]
}

View File

@ -0,0 +1,9 @@
---
NovaAvailabilityZones.list_availability_zones:
-
args:
detailed: true
runner:
type: "constant"
concurrency: 2
times: 10

View File

@ -0,0 +1,11 @@
{
"NovaHosts.list_hosts": [
{
"runner": {
"type": "constant",
"concurrency": 2,
"times": 10
}
}
]
}

View File

@ -0,0 +1,7 @@
---
NovaHosts.list_hosts:
-
runner:
type: "constant"
concurrency: 2
times: 10

View File

@ -0,0 +1,28 @@
# Copyright 2016 IBM Corp.
# 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.plugins.openstack.scenarios.nova import agents
from tests.unit import test
class NovaAgentsTestCase(test.TestCase):
def test_list_agents(self):
scenario = agents.NovaAgents()
scenario._list_agents = mock.Mock()
scenario.list_agents(hypervisor=None)
scenario._list_agents.assert_called_once_with(None)

View File

@ -0,0 +1,28 @@
# Copyright 2016 IBM Corp.
# 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.plugins.openstack.scenarios.nova import aggregates
from tests.unit import test
class NovaAggregatesTestCase(test.TestCase):
def test_list_aggregates(self):
scenario = aggregates.NovaAggregates()
scenario._list_aggregates = mock.Mock()
scenario.list_aggregates()
scenario._list_aggregates.assert_called_once_with()

View File

@ -0,0 +1,28 @@
# Copyright 2016 IBM Corp.
# 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.plugins.openstack.scenarios.nova import availability_zones
from tests.unit import test
class NovaAvailabilityZonesTestCase(test.TestCase):
def test_list_availability_zones(self):
scenario = availability_zones.NovaAvailabilityZones()
scenario._list_availability_zones = mock.Mock()
scenario.list_availability_zones(detailed=False)
scenario._list_availability_zones.assert_called_once_with(False)

View File

@ -0,0 +1,28 @@
# Copyright 2016 IBM Corp.
# 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.plugins.openstack.scenarios.nova import hosts
from tests.unit import test
class NovaHostsTestCase(test.TestCase):
def test_list_hosts(self):
scenario = hosts.NovaHosts()
scenario._list_hosts = mock.Mock()
scenario.list_hosts(zone=None)
scenario._list_hosts.assert_called_once_with(None)

View File

@ -875,3 +875,50 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
True, fakearg="fakearg") True, fakearg="fakearg")
self._test_atomic_action_timer(nova_scenario.atomic_actions(), self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_flavors") "nova.list_flavors")
@ddt.data({},
{"hypervisor": "foo_hypervisor"})
@ddt.unpack
def test__list_agents(self, hypervisor=None):
nova_scenario = utils.NovaScenario()
self.admin_clients("nova").agents.list.return_value = "agents_list"
result = nova_scenario._list_agents(hypervisor)
self.assertEqual("agents_list", result)
self.admin_clients("nova").agents.list.assert_called_once_with(
hypervisor)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_agents")
def test__list_aggregates(self):
nova_scenario = utils.NovaScenario()
self.admin_clients("nova").aggregates.list.return_value = (
"aggregates_list")
result = nova_scenario._list_aggregates()
self.assertEqual("aggregates_list", result)
self.admin_clients("nova").aggregates.list.assert_called_once_with()
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_aggregates")
def test__list_availability_zones(self):
nova_scenario = utils.NovaScenario()
self.admin_clients("nova").availability_zones.list.return_value = (
"availability_zones_list")
result = nova_scenario._list_availability_zones(detailed=True)
self.assertEqual("availability_zones_list", result)
nova_admin_client = self.admin_clients("nova")
availability_zones_client = nova_admin_client.availability_zones
availability_zones_client.list.assert_called_once_with(True)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_availbility_zones")
@ddt.data({},
{"zone": "foo_zone"})
@ddt.unpack
def test__list_hosts(self, zone=None):
nova_scenario = utils.NovaScenario()
self.admin_clients("nova").hosts.list.return_value = "hosts_list"
result = nova_scenario._list_hosts(zone)
self.assertEqual("hosts_list", result)
self.admin_clients("nova").hosts.list.assert_called_once_with(zone)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_hosts")