Merge "Add EC2 api scenario that list all servers"

This commit is contained in:
Jenkins 2015-08-13 02:06:49 +00:00 committed by Gerrit Code Review
commit 97a07cda3a
7 changed files with 94 additions and 0 deletions

View File

@ -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:

View File

@ -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")

View File

@ -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):

View File

@ -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
}
}
}
]
}

View File

@ -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

View File

@ -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()

View File

@ -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()