fix rally scenarios
1. ec2_servers has been commited to rally and our ec2_server object now conflicts with rally`s. in this patchset our object has been renamed. 2. rally now doesn't save context between runs. it passes original context to each run. before this feature we stored something in context and didn't count first run. moved to using global var of ec2 plugin. rally was changed here - https://review.openstack.org/#/c/203911/9 3. added route tables preparation for floating ip associating. 4. Scenarios was refactored in rally https://review.openstack.org/#/c/212831/3 Change-Id: I57d6298a8ae734720f68a0caf2b36c92f32893b0
This commit is contained in:
parent
f5b320edbb
commit
61a965cfc9
|
@ -10,7 +10,7 @@
|
|||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
prepare_ec2_client:
|
||||
ec2_servers:
|
||||
ec2api_servers:
|
||||
flavor: "m1.nano"
|
||||
image: "*cirros*"
|
||||
servers_per_tenant: 200
|
||||
|
@ -27,7 +27,7 @@
|
|||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
prepare_ec2_client:
|
||||
ec2_servers:
|
||||
ec2api_servers:
|
||||
flavor: "m1.nano"
|
||||
image: "*cirros*"
|
||||
servers_per_tenant: 200
|
||||
|
@ -49,7 +49,7 @@
|
|||
# tenants: 1
|
||||
# users_per_tenant: 1
|
||||
# prepare_ec2_client:
|
||||
# ec2_networks:
|
||||
# ec2api_networks:
|
||||
# subnets_per_tenant: 50
|
||||
# nis_per_subnet: 10
|
||||
|
||||
|
|
|
@ -95,6 +95,17 @@ class EC2Objects(context.Context):
|
|||
data = client.attach_internet_gateway(VpcId=vpc_id,
|
||||
InternetGatewayId=gw_id)
|
||||
|
||||
data = client.describe_route_tables(
|
||||
Filters=[{'Name': 'vpc-id', 'Values': [vpc_id]}])
|
||||
# len(data['RouteTables']) should be 1
|
||||
route_table_id = data['RouteTables'][0]['RouteTableId']
|
||||
kwargs = {
|
||||
'DestinationCidrBlock': '0.0.0.0/0',
|
||||
'RouteTableId': route_table_id,
|
||||
'GatewayId': gw_id
|
||||
}
|
||||
client.create_route(*[], **kwargs)
|
||||
|
||||
return subnet_id
|
||||
|
||||
def assign_floating_ips(self, tenant_id, client):
|
||||
|
@ -115,12 +126,6 @@ class EC2Objects(context.Context):
|
|||
data = client.allocate_address(*[], **kwargs)
|
||||
alloc_id = data.get('AllocationId')
|
||||
public_ip = data['PublicIp']
|
||||
if is_vpc:
|
||||
self.context["tenants"][tenant_id]["addresses"].append(
|
||||
{'AllocationId': alloc_id})
|
||||
else:
|
||||
self.context["tenants"][tenant_id]["addresses"].append(
|
||||
{'PublicIp': public_ip})
|
||||
|
||||
kwargs = {'InstanceId': instance_id}
|
||||
if is_vpc:
|
||||
|
@ -129,12 +134,12 @@ class EC2Objects(context.Context):
|
|||
kwargs['PublicIp'] = public_ip
|
||||
try:
|
||||
data = client.associate_address(*[], **kwargs)
|
||||
kwargs.pop('InstanceId')
|
||||
self.context["tenants"][tenant_id]["addresses"].append(kwargs)
|
||||
except Exception:
|
||||
LOG.exception('')
|
||||
if is_vpc:
|
||||
data = client.release_address(AllocationId=alloc_id)
|
||||
else:
|
||||
data = client.release_address(PublicIp=public_ip)
|
||||
kwargs.pop('InstanceId')
|
||||
data = client.release_address(*[], **kwargs)
|
||||
|
||||
def terminate_instances_and_wait(self, tenant_id, client):
|
||||
ids = self.context["tenants"][tenant_id].get("servers", [])
|
||||
|
@ -170,7 +175,10 @@ class EC2Objects(context.Context):
|
|||
LOG.info("Cleanup addresses")
|
||||
kwargss = self.context["tenants"][tenant_id].get("addresses", [])
|
||||
for kwargs in kwargss:
|
||||
data = client.release_address(*[], **kwargs)
|
||||
try:
|
||||
data = client.release_address(*[], **kwargs)
|
||||
except Exception:
|
||||
LOG.exception('')
|
||||
|
||||
def cleanup_networks(self, tenant_id, client):
|
||||
LOG.info("Cleanup networks")
|
||||
|
@ -214,7 +222,7 @@ class EC2Objects(context.Context):
|
|||
LOG.exception('')
|
||||
|
||||
|
||||
@context.configure(name="ec2_networks", order=451)
|
||||
@context.configure(name="ec2api_networks", order=451)
|
||||
class FakeNetworkGenerator(EC2Objects):
|
||||
"""Context class for adding temporary networks for benchmarks.
|
||||
|
||||
|
@ -269,7 +277,7 @@ class FakeNetworkGenerator(EC2Objects):
|
|||
self.cleanup_networks(tenant_id, client)
|
||||
|
||||
|
||||
@context.configure(name="ec2_servers", order=450)
|
||||
@context.configure(name="ec2api_servers", order=450)
|
||||
class FakeServerGenerator(EC2Objects):
|
||||
"""Context class for adding temporary servers for benchmarks.
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ from rally.common import utils as rutils
|
|||
from rally import consts
|
||||
from rally import osclients
|
||||
from rally.task import context
|
||||
from rally.task.scenarios import base as scenario_base
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -60,7 +59,7 @@ class FakeImageGenerator(context.Context):
|
|||
current_images = []
|
||||
for i in range(images_per_tenant):
|
||||
kw = {
|
||||
"name": scenario_base.Scenario._generate_random_name(),
|
||||
"name": "image-" + tenant_id[0:8] + "-" + str(i),
|
||||
"container_format": container_format,
|
||||
"disk_format": disk_format,
|
||||
"size": 1000000,
|
||||
|
|
|
@ -13,29 +13,36 @@
|
|||
import functools
|
||||
|
||||
from rally.common import log as logging
|
||||
from rally.task.scenarios import base
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task import atomic
|
||||
|
||||
from ec2api.tests.functional import botocoreclient
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AtomicActionWithoutFirst(base.AtomicAction):
|
||||
_count_args = dict()
|
||||
|
||||
|
||||
class ActionTimerWithoutFirst(atomic.ActionTimer):
|
||||
|
||||
def __init__(self, scenario_instance, name):
|
||||
super(AtomicActionWithoutFirst, self).__init__(scenario_instance, name)
|
||||
super(ActionTimerWithoutFirst, self).__init__(scenario_instance, name)
|
||||
self.scenario_instance = scenario_instance
|
||||
self.name = name
|
||||
|
||||
def __exit__(self, type, value, tb):
|
||||
args = self.scenario_instance.context['user']['ec2args']
|
||||
if self.name in args:
|
||||
super(AtomicActionWithoutFirst, self).__exit__(type, value, tb)
|
||||
if self.name in _count_args:
|
||||
super(ActionTimerWithoutFirst, self).__exit__(type, value, tb)
|
||||
else:
|
||||
args[self.name] = True
|
||||
_count_args[self.name] = True
|
||||
|
||||
|
||||
class EC2APIPlugin(base.Scenario):
|
||||
class EC2APIPlugin(scenario.OpenStackScenario):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EC2APIPlugin, self).__init__(*args, **kwargs)
|
||||
count_args = dict()
|
||||
|
||||
def _get_client(self, is_nova):
|
||||
args = self.context['user']['ec2args']
|
||||
|
@ -46,15 +53,15 @@ class EC2APIPlugin(base.Scenario):
|
|||
|
||||
def _run_both(self, base_name, func):
|
||||
client = self._get_client(True)
|
||||
with AtomicActionWithoutFirst(self, base_name + '_nova'):
|
||||
with ActionTimerWithoutFirst(self, base_name + '_nova'):
|
||||
func(self, client)
|
||||
client = self._get_client(False)
|
||||
with AtomicActionWithoutFirst(self, base_name + '_ec2api'):
|
||||
with ActionTimerWithoutFirst(self, base_name + '_ec2api'):
|
||||
func(self, client)
|
||||
|
||||
def _run_ec2(self, base_name, func):
|
||||
client = self._get_client(False)
|
||||
with AtomicActionWithoutFirst(self, base_name + '_ec2api'):
|
||||
with ActionTimerWithoutFirst(self, base_name + '_ec2api'):
|
||||
func(self, client)
|
||||
|
||||
def _runner(run_func):
|
||||
|
@ -65,54 +72,54 @@ class EC2APIPlugin(base.Scenario):
|
|||
return runner
|
||||
return wrap
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_both)
|
||||
def describe_instances(self, client):
|
||||
data = client.describe_instances()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_both)
|
||||
def describe_addresses(self, client):
|
||||
data = client.describe_addresses()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_both)
|
||||
def describe_security_groups(self, client):
|
||||
data = client.describe_security_groups()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_both)
|
||||
def describe_regions(self, client):
|
||||
data = client.describe_regions()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_both)
|
||||
def describe_images(self, client):
|
||||
data = client.describe_images()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_ec2)
|
||||
def describe_vpcs(self, client):
|
||||
data = client.describe_vpcs()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_ec2)
|
||||
def describe_subnets(self, client):
|
||||
data = client.describe_subnets()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_ec2)
|
||||
def describe_network_interfaces(self, client):
|
||||
data = client.describe_network_interfaces()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_ec2)
|
||||
def describe_route_tables(self, client):
|
||||
data = client.describe_route_tables()
|
||||
|
||||
_instance_id_by_client = dict()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
@_runner(_run_both)
|
||||
def describe_one_instance(self, client):
|
||||
client_id = str(client._endpoint)
|
||||
|
@ -128,7 +135,7 @@ class EC2APIPlugin(base.Scenario):
|
|||
|
||||
data = client.describe_instances(InstanceIds=[instance_id])
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
def describe_all_in_one(self):
|
||||
self.describe_addresses()
|
||||
self.describe_instances()
|
||||
|
@ -139,7 +146,7 @@ class EC2APIPlugin(base.Scenario):
|
|||
self.describe_network_interfaces()
|
||||
self.describe_route_tables()
|
||||
|
||||
@base.scenario()
|
||||
@scenario.configure()
|
||||
def describe_networks(self):
|
||||
self.describe_vpcs()
|
||||
self.describe_subnets()
|
||||
|
|
Loading…
Reference in New Issue