diff --git a/rally-jobs/nova.yaml b/rally-jobs/nova.yaml index c9a66369db..d8ec54f666 100644 --- a/rally-jobs/nova.yaml +++ b/rally-jobs/nova.yaml @@ -35,6 +35,26 @@ failure_rate: max: 0 + EC2Servers.list_servers: + - + runner: + type: "constant" + times: 3 + concurrency: 3 + context: + users: + tenants: 3 + users_per_tenant: 1 + ec2_servers: + flavor: + name: "m1.tiny" + image: + name: {{image_name}} + servers_per_tenant: 2 + sla: + failure_rate: + max: 0 + Quotas.nova_update_and_delete: - args: diff --git a/rally/plugins/openstack/scenarios/ec2/servers.py b/rally/plugins/openstack/scenarios/ec2/servers.py index 0a5cd28366..acbaf8bc45 100644 --- a/rally/plugins/openstack/scenarios/ec2/servers.py +++ b/rally/plugins/openstack/scenarios/ec2/servers.py @@ -26,6 +26,17 @@ LOG = logging.getLogger(__name__) class EC2Servers(utils.EC2Scenario): """Benchmark scenarios for servers using EC2.""" + @validation.required_services(consts.Service.EC2) + @validation.required_openstack(users=True) + @base.scenario(context={"cleanup": ["ec2"]}) + def list_servers(self): + """List all servers. + + This simple scenario tests the EC2 API list function by listing + all the servers. + """ + self._list_servers() + @types.set(image=types.EC2ImageResourceType, flavor=types.EC2FlavorResourceType) @validation.image_valid_on_flavor("flavor", "image") diff --git a/rally/plugins/openstack/scenarios/ec2/utils.py b/rally/plugins/openstack/scenarios/ec2/utils.py index c36307bdba..ef65d616a2 100644 --- a/rally/plugins/openstack/scenarios/ec2/utils.py +++ b/rally/plugins/openstack/scenarios/ec2/utils.py @@ -48,6 +48,11 @@ CONF.register_opts(EC2_BENCHMARK_OPTS, group=benchmark_group) class EC2Scenario(scenario.OpenStackScenario): """Base class for EC2 scenarios with basic atomic actions.""" + @base.atomic_action_timer("ec2.list_servers") + def _list_servers(self): + """Returns user servers list.""" + return self.clients("ec2").get_only_instances() + @base.atomic_action_timer("ec2.boot_servers") def _boot_servers(self, image_id, flavor_name, instance_num=1, **kwargs): diff --git a/samples/tasks/scenarios/ec2/list-servers.json b/samples/tasks/scenarios/ec2/list-servers.json new file mode 100644 index 0000000000..ef36bc6085 --- /dev/null +++ b/samples/tasks/scenarios/ec2/list-servers.json @@ -0,0 +1,26 @@ +{ + "EC2Servers.list_servers": [ + { + "runner": { + "type": "constant", + "times": 1, + "concurrency": 1 + }, + "context": { + "users": { + "tenants": 1, + "users_per_tenant": 1 + }, + "ec2_servers": { + "flavor": { + "name": "m1.tiny" + }, + "image": { + "name": "^cirros.*uec$" + }, + "servers_per_tenant": 2 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/ec2/list-servers.yaml b/samples/tasks/scenarios/ec2/list-servers.yaml new file mode 100644 index 0000000000..5befad2e8c --- /dev/null +++ b/samples/tasks/scenarios/ec2/list-servers.yaml @@ -0,0 +1,17 @@ +--- + EC2Servers.list_servers: + - + runner: + type: "constant" + times: 1 + concurrency: 1 + context: + users: + tenants: 1 + users_per_tenant: 1 + ec2_servers: + flavor: + name: "m1.tiny" + image: + name: "^cirros.*uec$" + servers_per_tenant: 2 diff --git a/tests/unit/plugins/openstack/scenarios/ec2/test_servers.py b/tests/unit/plugins/openstack/scenarios/ec2/test_servers.py index 87ab82588a..2457355280 100644 --- a/tests/unit/plugins/openstack/scenarios/ec2/test_servers.py +++ b/tests/unit/plugins/openstack/scenarios/ec2/test_servers.py @@ -20,6 +20,12 @@ from tests.unit import test class EC2ServersTestCase(test.ScenarioTestCase): + def test_list_servers(self): + scenario = servers.EC2Servers() + scenario._list_servers = mock.MagicMock() + scenario.list_servers() + scenario._list_servers.assert_called_once_with() + def test_boot_server(self): scenario = servers.EC2Servers() scenario._boot_servers = mock.Mock() diff --git a/tests/unit/plugins/openstack/scenarios/ec2/test_utils.py b/tests/unit/plugins/openstack/scenarios/ec2/test_utils.py index 373f8cbbb6..dd83fe4504 100644 --- a/tests/unit/plugins/openstack/scenarios/ec2/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/ec2/test_utils.py @@ -30,6 +30,15 @@ class EC2ScenarioTestCase(test.ScenarioTestCase): self.reservations = mock.MagicMock(instances=[self.server1, self.server2]) + def test__list_servers(self): + servers_list = [] + self.clients("ec2").get_only_instances.return_value = servers_list + ec2_scenario = utils.EC2Scenario() + return_servers_list = ec2_scenario._list_servers() + self.assertEqual(servers_list, return_servers_list) + self._test_atomic_action_timer(ec2_scenario.atomic_actions(), + "ec2.list_servers") + def test__update_resource(self): resource = mock.MagicMock() scenario = utils.EC2Scenario()