Fix broken logic in some neutron scenarios

_get_or_create_network: create networks only if there is no networks
in context.

_get_or_create_subnets: create subnets only if there is no subnets
in context.

Unit tests are passing because of bug in ddt [0]
This issue was actually caught by rally-ci (rally-pg-py27-unit) but was
ignored by revievers.

Running tests without testr may be used as workaround:

    .tox/py27/bin/python -m unittest discover tests/unit

[0] https://github.com/txels/ddt/issues/35

Change-Id: Ib77bd4f7eeaec2ed3a712e1d56a20d1f87325264
This commit is contained in:
Sergey Skripnick 2015-11-18 21:23:02 +02:00
parent 4a338a6152
commit 9c13b516fd
2 changed files with 9 additions and 9 deletions

View File

@ -282,12 +282,11 @@ class NeutronScenario(scenario.OpenStackScenario):
context instead.
:returns: Network dict
"""
if "networks" not in self.context["tenant"]:
if "networks" in self.context["tenant"]:
return random.choice(self.context["tenant"]["networks"])
else:
LOG.warning(_("Running this scenario without either the 'network' "
"or 'existing_network' context is deprecated"))
elif network_create_args is None:
return random.choice(self.context["tenant"]["networks"])
return self._create_network(network_create_args or {})
def _get_or_create_subnets(self, network,
@ -304,8 +303,9 @@ class NeutronScenario(scenario.OpenStackScenario):
:param subnets_per_network: int, number of subnets for one network
:returns: List of subnet dicts
"""
if len(network.get("subnets", [])):
return network["subnets"]
subnets = network.get("subnets")
if subnets:
return subnets
else:
return self._create_subnets(network, subnet_create_args,
subnet_cidr_start, subnets_per_network)

View File

@ -50,8 +50,8 @@ class TestCase(base.BaseTestCase):
self.assertIsNotNone(action_duration)
self.assertIsInstance(action_duration, float)
def assertSequenceEqual(self, iterable_1, iterable_2):
self.assertEqual(tuple(iterable_1), tuple(iterable_2))
def assertSequenceEqual(self, iterable_1, iterable_2, msg=None):
self.assertEqual(tuple(iterable_1), tuple(iterable_2), msg)
class DBTestCase(TestCase):