Merge "Add EC2 api scenario that list all servers"
This commit is contained in:
commit
97a07cda3a
@ -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:
|
||||
|
@ -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")
|
||||
|
@ -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):
|
||||
|
26
samples/tasks/scenarios/ec2/list-servers.json
Normal file
26
samples/tasks/scenarios/ec2/list-servers.json
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
17
samples/tasks/scenarios/ec2/list-servers.yaml
Normal file
17
samples/tasks/scenarios/ec2/list-servers.yaml
Normal 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
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user