Merge "Moving of Nova scenarios into separate classes"
This commit is contained in:
commit
5952c7144b
@ -19,13 +19,15 @@ from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class NovaAgents(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova agents."""
|
||||
"""Scenarios for Nova agents."""
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure()
|
||||
def list_agents(self, hypervisor=None):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(name="NovaAgents.list_agents")
|
||||
class ListAgents(utils.NovaScenario):
|
||||
|
||||
def run(self, hypervisor=None):
|
||||
"""List all builds.
|
||||
|
||||
Measure the "nova agent-list" command performance.
|
||||
|
@ -19,13 +19,15 @@ from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class NovaAggregates(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova aggregates."""
|
||||
"""Scenarios for Nova aggregates."""
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure()
|
||||
def list_aggregates(self):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(name="NovaAggregates.list_aggregates")
|
||||
class ListAggregates(utils.NovaScenario):
|
||||
|
||||
def run(self):
|
||||
"""List all nova aggregates.
|
||||
|
||||
Measure the "nova aggregate-list" command performance.
|
||||
|
@ -19,13 +19,15 @@ from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class NovaAvailabilityZones(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova availability-zones."""
|
||||
"""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):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(name="NovaAvailabilityZones.list_availability_zones")
|
||||
class ListAvailabilityZones(utils.NovaScenario):
|
||||
|
||||
def run(self, detailed=True):
|
||||
"""List all availability zones.
|
||||
|
||||
Measure the "nova availability-zone-list" command performance.
|
||||
|
@ -20,16 +20,19 @@ from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
"""Scenarios for Nova flavors."""
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NovaFlavors(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova flavors."""
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(name="NovaFlavors.list_flavors")
|
||||
class ListFlavors(utils.NovaScenario):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure()
|
||||
def list_flavors(self, detailed=True, **kwargs):
|
||||
def run(self, detailed=True, **kwargs):
|
||||
"""List all flavors.
|
||||
|
||||
Measure the "nova flavor-list" command performance.
|
||||
@ -41,10 +44,14 @@ class NovaFlavors(utils.NovaScenario):
|
||||
"""
|
||||
self._list_flavors(detailed, **kwargs)
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["nova"]})
|
||||
def create_and_list_flavor_access(self, ram, vcpus, disk, **kwargs):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["nova"]},
|
||||
name="NovaFlavors.create_and_list_flavor_access")
|
||||
class CreateAndListFlavorAccess(utils.NovaScenario):
|
||||
|
||||
def run(self, ram, vcpus, disk, **kwargs):
|
||||
"""Create a non-public flavor and list its access rules
|
||||
|
||||
:param ram: Memory in MB for the flavor
|
||||
@ -61,10 +68,14 @@ class NovaFlavors(utils.NovaScenario):
|
||||
flavor = self._create_flavor(ram, vcpus, disk, **kwargs)
|
||||
self._list_flavor_access(flavor.id)
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["nova"]})
|
||||
def create_flavor(self, ram, vcpus, disk, **kwargs):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["nova"]},
|
||||
name="NovaFlavors.create_flavor")
|
||||
class CreateFlavor(utils.NovaScenario):
|
||||
|
||||
def run(self, ram, vcpus, disk, **kwargs):
|
||||
"""Create a flavor.
|
||||
|
||||
:param ram: Memory in MB for the flavor
|
||||
|
@ -19,13 +19,15 @@ from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class NovaHosts(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova hosts."""
|
||||
"""Scenarios for Nova hosts."""
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure()
|
||||
def list_hosts(self, zone=None):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(name="NovaHosts.list_hosts")
|
||||
class ListHosts(utils.NovaScenario):
|
||||
|
||||
def run(self, zone=None):
|
||||
"""List all nova hosts.
|
||||
|
||||
Measure the "nova host-list" command performance.
|
||||
|
@ -19,13 +19,15 @@ from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class NovaHypervisors(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova hypervisors."""
|
||||
"""Scenarios for Nova hypervisors."""
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure()
|
||||
def list_hypervisors(self, detailed=True):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(name="NovaHypervisors.list_hypervisors")
|
||||
class ListHypervisors(utils.NovaScenario):
|
||||
|
||||
def run(self, detailed=True):
|
||||
"""List hypervisors.
|
||||
|
||||
Measure the "nova hypervisor-list" command performance.
|
||||
|
@ -19,13 +19,16 @@ from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class NovaImages(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova images."""
|
||||
"""Scenarios for Nova images."""
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]})
|
||||
def list_images(self, detailed=True, **kwargs):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]},
|
||||
name="NovaImages.list_images")
|
||||
class ListImages(utils.NovaScenario):
|
||||
|
||||
def run(self, detailed=True, **kwargs):
|
||||
"""List all images.
|
||||
|
||||
Measure the "nova image-list" command performance.
|
||||
|
@ -21,13 +21,16 @@ from rally.task import types
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class NovaKeypair(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova keypairs."""
|
||||
"""Scenarios for Nova keypairs."""
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]})
|
||||
def create_and_list_keypairs(self, **kwargs):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]},
|
||||
name="NovaKeypair.create_and_list_keypairs")
|
||||
class CreateAndListKeypairs(utils.NovaScenario):
|
||||
|
||||
def run(self, **kwargs):
|
||||
"""Create a keypair with random name and list keypairs.
|
||||
|
||||
This scenario creates a keypair and then lists all keypairs.
|
||||
@ -38,10 +41,14 @@ class NovaKeypair(utils.NovaScenario):
|
||||
self._create_keypair(**kwargs)
|
||||
self._list_keypairs()
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]})
|
||||
def create_and_delete_keypair(self, **kwargs):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]},
|
||||
name="NovaKeypair.create_and_delete_keypair")
|
||||
class CreateAndDeleteKeypair(utils.NovaScenario):
|
||||
|
||||
def run(self, **kwargs):
|
||||
"""Create a keypair with random name and delete keypair.
|
||||
|
||||
This scenario creates a keypair and then delete that keypair.
|
||||
@ -52,19 +59,21 @@ class NovaKeypair(utils.NovaScenario):
|
||||
keypair = self._create_keypair(**kwargs)
|
||||
self._delete_keypair(keypair)
|
||||
|
||||
@types.convert(image={"type": "glance_image"},
|
||||
flavor={"type": "nova_flavor"})
|
||||
@validation.image_valid_on_flavor("flavor", "image")
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]})
|
||||
|
||||
@types.convert(image={"type": "glance_image"},
|
||||
flavor={"type": "nova_flavor"})
|
||||
@validation.image_valid_on_flavor("flavor", "image")
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]},
|
||||
name="NovaKeypair.boot_and_delete_server_with_keypair")
|
||||
class BootAndDeleteServerWithKeypair(utils.NovaScenario):
|
||||
|
||||
@logging.log_deprecated_args(
|
||||
"'server_kwargs' has been renamed 'boot_server_kwargs'",
|
||||
"0.3.2", ["server_kwargs"], once=True)
|
||||
def boot_and_delete_server_with_keypair(self, image, flavor,
|
||||
boot_server_kwargs=None,
|
||||
server_kwargs=None,
|
||||
**kwargs):
|
||||
def run(self, image, flavor, boot_server_kwargs=None,
|
||||
server_kwargs=None, **kwargs):
|
||||
"""Boot and delete server with keypair.
|
||||
|
||||
Plan of this scenario:
|
||||
@ -88,4 +97,4 @@ class NovaKeypair(utils.NovaScenario):
|
||||
key_name=keypair,
|
||||
**boot_server_kwargs)
|
||||
self._delete_server(server)
|
||||
self._delete_keypair(keypair)
|
||||
self._delete_keypair(keypair)
|
@ -19,13 +19,15 @@ from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class NovaServices(utils.NovaScenario):
|
||||
"""Benchmark scenarios for Nova agents."""
|
||||
"""Scenarios for Nova agents."""
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure()
|
||||
def list_services(self, host=None, binary=None):
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(name="NovaServices.list_services")
|
||||
class ListServices(utils.NovaScenario):
|
||||
|
||||
def run(self, host=None, binary=None):
|
||||
"""List all nova services.
|
||||
|
||||
Measure the "nova service-list" command performance.
|
||||
|
@ -22,7 +22,7 @@ from tests.unit import test
|
||||
class NovaAgentsTestCase(test.TestCase):
|
||||
|
||||
def test_list_agents(self):
|
||||
scenario = agents.NovaAgents()
|
||||
scenario = agents.ListAgents()
|
||||
scenario._list_agents = mock.Mock()
|
||||
scenario.list_agents(hypervisor=None)
|
||||
scenario.run(hypervisor=None)
|
||||
scenario._list_agents.assert_called_once_with(None)
|
||||
|
@ -22,9 +22,9 @@ from tests.unit import test
|
||||
class NovaAggregatesTestCase(test.TestCase):
|
||||
|
||||
def test_list_aggregates(self):
|
||||
scenario = aggregates.NovaAggregates()
|
||||
scenario = aggregates.ListAggregates()
|
||||
scenario._list_aggregates = mock.Mock()
|
||||
scenario.list_aggregates()
|
||||
scenario.run()
|
||||
scenario._list_aggregates.assert_called_once_with()
|
||||
|
||||
def test_create_and_list_aggregates(self):
|
||||
|
@ -22,7 +22,7 @@ from tests.unit import test
|
||||
class NovaAvailabilityZonesTestCase(test.TestCase):
|
||||
|
||||
def test_list_availability_zones(self):
|
||||
scenario = availability_zones.NovaAvailabilityZones()
|
||||
scenario = availability_zones.ListAvailabilityZones()
|
||||
scenario._list_availability_zones = mock.Mock()
|
||||
scenario.list_availability_zones(detailed=False)
|
||||
scenario.run(detailed=False)
|
||||
scenario._list_availability_zones.assert_called_once_with(False)
|
||||
|
@ -24,9 +24,9 @@ from tests.unit import test
|
||||
class NovaFlavorsTestCase(test.TestCase):
|
||||
|
||||
def test_list_flavors(self):
|
||||
scenario = flavors.NovaFlavors()
|
||||
scenario = flavors.ListFlavors()
|
||||
scenario._list_flavors = mock.Mock()
|
||||
scenario.list_flavors(detailed=True, fakearg="fakearg")
|
||||
scenario.run(detailed=True, fakearg="fakearg")
|
||||
scenario._list_flavors.assert_called_once_with(True, fakearg="fakearg")
|
||||
|
||||
@ddt.data({},
|
||||
@ -36,11 +36,10 @@ class NovaFlavorsTestCase(test.TestCase):
|
||||
{"is_public": False, "fakeargs": "fakeargs"})
|
||||
@ddt.unpack
|
||||
def test_create_and_list_flavor_access(self, **kwargs):
|
||||
scenario = flavors.NovaFlavors()
|
||||
scenario = flavors.CreateAndListFlavorAccess()
|
||||
scenario._create_flavor = mock.Mock()
|
||||
scenario._list_flavor_access = mock.Mock()
|
||||
scenario.create_and_list_flavor_access(ram=100, vcpus=1, disk=1,
|
||||
**kwargs)
|
||||
scenario.run(ram=100, vcpus=1, disk=1, **kwargs)
|
||||
kwargs.pop("is_public", None)
|
||||
scenario._create_flavor.assert_called_once_with(100, 1, 1,
|
||||
is_public=False,
|
||||
@ -49,9 +48,9 @@ class NovaFlavorsTestCase(test.TestCase):
|
||||
scenario._create_flavor.return_value.id)
|
||||
|
||||
def test_create_flavor(self):
|
||||
scenario = flavors.NovaFlavors()
|
||||
scenario = flavors.CreateFlavor()
|
||||
scenario._create_flavor = mock.MagicMock()
|
||||
scenario.create_flavor(ram=100, vcpus=1, disk=1, fakeargs="fakeargs")
|
||||
scenario.run(ram=100, vcpus=1, disk=1, fakeargs="fakeargs")
|
||||
scenario._create_flavor.assert_called_once_with(100, 1, 1,
|
||||
fakeargs="fakeargs")
|
||||
|
||||
|
@ -22,7 +22,7 @@ from tests.unit import test
|
||||
class NovaHostsTestCase(test.TestCase):
|
||||
|
||||
def test_list_hosts(self):
|
||||
scenario = hosts.NovaHosts()
|
||||
scenario = hosts.ListHosts()
|
||||
scenario._list_hosts = mock.Mock()
|
||||
scenario.list_hosts(zone=None)
|
||||
scenario.run(zone=None)
|
||||
scenario._list_hosts.assert_called_once_with(None)
|
||||
|
@ -19,13 +19,9 @@ from rally.plugins.openstack.scenarios.nova import hypervisors
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
NOVA_HYPERVISORS_MODULE = "rally.plugins.openstack.scenarios.nova.hypervisors"
|
||||
NOVA_HYPERVISORS = NOVA_HYPERVISORS_MODULE + ".NovaHypervisors"
|
||||
|
||||
|
||||
class NovaHypervisorsTestCase(test.ScenarioTestCase):
|
||||
def test_list_hypervisors(self):
|
||||
scenario = hypervisors.NovaHypervisors(self.context)
|
||||
scenario = hypervisors.ListHypervisors(self.context)
|
||||
scenario._list_hypervisors = mock.Mock()
|
||||
scenario.list_hypervisors(detailed=False)
|
||||
scenario.run(detailed=False)
|
||||
scenario._list_hypervisors.assert_called_once_with(False)
|
||||
|
@ -22,7 +22,7 @@ from tests.unit import test
|
||||
class NovaImagesTestCase(test.TestCase):
|
||||
|
||||
def test_list_images(self):
|
||||
scenario = images.NovaImages()
|
||||
scenario = images.ListImages()
|
||||
scenario._list_images = mock.Mock()
|
||||
scenario.list_images(detailed=False, fakearg="fakearg")
|
||||
scenario.run(detailed=False, fakearg="fakearg")
|
||||
scenario._list_images.assert_called_once_with(False, fakearg="fakearg")
|
||||
|
@ -22,29 +22,29 @@ from tests.unit import test
|
||||
class NovaKeypairTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test_create_and_list_keypairs(self):
|
||||
scenario = keypairs.NovaKeypair(self.context)
|
||||
scenario = keypairs.CreateAndListKeypairs(self.context)
|
||||
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
||||
scenario._list_keypairs = mock.MagicMock()
|
||||
|
||||
scenario.create_and_list_keypairs(fakearg="fakearg")
|
||||
scenario.run(fakearg="fakearg")
|
||||
|
||||
scenario._create_keypair.assert_called_once_with(fakearg="fakearg")
|
||||
scenario._list_keypairs.assert_called_once_with()
|
||||
|
||||
def test_create_and_delete_keypair(self):
|
||||
scenario = keypairs.NovaKeypair(self.context)
|
||||
scenario = keypairs.CreateAndDeleteKeypair(self.context)
|
||||
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
||||
scenario._delete_keypair = mock.MagicMock()
|
||||
|
||||
scenario.create_and_delete_keypair(fakearg="fakearg")
|
||||
scenario.run(fakearg="fakearg")
|
||||
|
||||
scenario._create_keypair.assert_called_once_with(fakearg="fakearg")
|
||||
scenario._delete_keypair.assert_called_once_with("foo_keypair")
|
||||
|
||||
def test_boot_and_delete_server_with_keypair(self):
|
||||
scenario = keypairs.NovaKeypair(self.context)
|
||||
scenario = keypairs.BootAndDeleteServerWithKeypair(self.context)
|
||||
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
||||
scenario._boot_server = mock.MagicMock(return_value="foo_server")
|
||||
@ -56,9 +56,8 @@ class NovaKeypairTestCase(test.ScenarioTestCase):
|
||||
"bar": 2,
|
||||
}
|
||||
|
||||
scenario.boot_and_delete_server_with_keypair(
|
||||
"img", 1, boot_server_kwargs=fake_server_args,
|
||||
fake_arg1="foo", fake_arg2="bar")
|
||||
scenario.run("img", 1, boot_server_kwargs=fake_server_args,
|
||||
fake_arg1="foo", fake_arg2="bar")
|
||||
|
||||
scenario._create_keypair.assert_called_once_with(
|
||||
fake_arg1="foo", fake_arg2="bar")
|
||||
|
@ -22,8 +22,8 @@ from tests.unit import test
|
||||
class NovaServicesTestCase(test.TestCase):
|
||||
|
||||
def test_list_services(self):
|
||||
scenario = services.NovaServices()
|
||||
scenario = services.ListServices()
|
||||
scenario._list_services = mock.Mock()
|
||||
scenario.list_services(host="foo_host", binary="foo_hypervisor")
|
||||
scenario.run(host="foo_host", binary="foo_hypervisor")
|
||||
scenario._list_services.assert_called_once_with("foo_host",
|
||||
"foo_hypervisor")
|
||||
|
Loading…
x
Reference in New Issue
Block a user