Fix LB create and delete VIPs failure when concurrency > 1

Create pools in the scenario instead of context because only one VIP
can be associated for a pool. Thus when concurrency>1 failures are
avoided.

Closes-bug: #1501467
Change-Id: Ibed79807f812a4e46cce0252cfffa8a59624081b
This commit is contained in:
Kiran 2015-09-24 14:36:26 +05:30
parent 9a17d8490e
commit 0903c73036
3 changed files with 26 additions and 20 deletions

View File

@ -209,19 +209,17 @@
NeutronLoadbalancerV1.create_and_delete_vips:
-
args:
pool_create_args: {}
vip_create_args: {}
runner:
type: "constant"
times: {{smoke or 20}}
concurrency: {{smoke or 1}}
concurrency: {{smoke or 10}}
context:
users:
tenants: {{smoke or 5}}
users_per_tenant: {{smoke or 2}}
network: {}
lbaas:
pool: {}
lbaas_version: 1
quotas:
neutron:
network: -1

View File

@ -120,23 +120,23 @@ class NeutronLoadbalancerV1(utils.NeutronScenario):
@validation.required_services(consts.Service.NEUTRON)
@validation.required_openstack(users=True)
@validation.required_contexts("network")
@validation.required_contexts("lbaas")
@scenario.configure(context={"cleanup": ["neutron"]})
def create_and_delete_vips(self, vip_create_args=None):
def create_and_delete_vips(self, pool_create_args=None,
vip_create_args=None):
"""Create a vip(v1) and then delete vips(v1).
Measure the "neutron lb-vip-create" and "neutron lb-vip-delete"
command performance. The scenario creates a vip for pool and
then deletes those vips.
:param pool_create_args: dict, POST /lb/pools request options
:param vip_create_args: dict, POST /lb/vips request options
"""
vips = []
pools = []
pool_create_args = pool_create_args or {}
vip_create_args = vip_create_args or {}
networks = self.context.get("tenant", {}).get("networks", [])
for net in networks:
[pools.append(pool) for pool in net.get("lb_pools")]
pools = self._create_v1_pools(networks, **pool_create_args)
with atomic.ActionTimer(self, "neutron.create_%s_vips" % len(pools)):
for pool in pools:
vips.append(self._create_v1_vip(pool, **vip_create_args))

View File

@ -33,12 +33,6 @@ class NeutronLoadbalancerv1TestCase(test.TestCase):
"subnets": ["fake_subnet"]}]}})
return context
def _get_context_pools(self):
context = self._get_context()
for network in context["tenant"]["networks"]:
network.update({"lb_pools": [{"pool": {"id": "pool-id"}}]})
return context
@ddt.data(
{},
{"pool_create_args": None},
@ -172,24 +166,38 @@ class NeutronLoadbalancerv1TestCase(test.TestCase):
{"vip_create_args": None},
{"vip_create_args": {}},
{"vip_create_args": {"name": "given-name"}},
{"pool_create_args": None},
{"pool_create_args": {}},
{"pool_create_args": {"name": "given-pool-name"}},
)
@ddt.unpack
def test_create_and_delete_vips(self, vip_create_args=None):
def test_create_and_delete_vips(self, pool_create_args=None,
vip_create_args=None):
pools = [{
"pool": {
"id": "pool-id"
}
}]
vip = {
"vip": {
"id": "vip-id"
}
}
neutron_scenario = loadbalancer_v1.NeutronLoadbalancerV1(
self._get_context_pools())
self._get_context())
vip_data = vip_create_args or {}
pool_data = pool_create_args or {}
networks = self._get_context()["tenant"]["networks"]
neutron_scenario._create_v1_pools = mock.Mock(return_value=pools)
neutron_scenario._create_v1_vip = mock.Mock(return_value=vip)
neutron_scenario._delete_v1_vip = mock.Mock()
neutron_scenario.create_and_delete_vips(
pool_create_args=pool_create_args,
vip_create_args=vip_create_args)
for net in self._get_context_pools()["tenant"]["networks"]:
neutron_scenario._create_v1_pools.assert_called_once_with(
networks, **pool_data)
neutron_scenario._create_v1_vip.assert_has_calls(
[mock.call(pool, **vip_data) for pool in net["lb_pools"]])
[mock.call(pool, **vip_data) for pool in pools])
neutron_scenario._delete_v1_vip.assert_has_calls(
[mock.call(vip["vip"])])