Fix tox env to facilitate generation of tarballs
This also fixes three UTs which started failing after
changing the tox environment. The issue with the tests
was that they were assuming a specific order of elements
in a JSON request body, which started breaking after the
tox environment change.
Change-Id: I3a882f8e5052c4bdf04f1b75c86ab0ebbd8c72c0
Closes-bug: 1588753
(cherry picked from commit 35278b9b3c
)
This commit is contained in:
parent
a4db86906c
commit
56d9f33d8a
|
@ -33,6 +33,7 @@ from neutron.extensions import portbindings
|
|||
from neutron import manager
|
||||
from opflexagent import constants as ocst
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
sys.modules["apicapi"] = mock.Mock()
|
||||
|
||||
|
@ -203,17 +204,31 @@ class ApicMappingTestCase(
|
|||
{u'attributes':
|
||||
{u'dn': u'uni/tn-common/out-supported/rsectx',
|
||||
u'tDn': u'', u'tnFvCtxName': u'default'}}}])}
|
||||
self.trimmed_l3out = u'{"l3extOut": {"attributes": {"rn": "Shd-Sub\
|
||||
"}, "children": [ {"l3extRsNdIfPol": {"tnNdIfPolName": ""}}, \
|
||||
{"l3extRsDampeningPol": {"tnRtctrlProfileName": ""}}, {"ospfRsIfPol": \
|
||||
{"tnOspfIfPolName": ""}}, {"l3extRsEngressQosDppPol": {"tnQosDppPolName": ""}}\
|
||||
, {"bfdRsIfPol": {"tnBfdIfPolName": ""}}, {"bgpRsPeerPfxPol": \
|
||||
{"tnBgpPeerPfxPolName": ""}}, {"eigrpRsIfPol": {"tnEigrpIfPolName": ""}}, \
|
||||
{"l3extLNodeP": {"attributes": {"dn": "uni/tn-test-tenant/out-Shd-Sub/\
|
||||
lnodep-Leaf3-4_NP"}, "children": [{"l3extLIfP": {"children": [{"\
|
||||
l3extRsPathL3OutAtt": {"attributes": {"ifInstT": "sub-interface", "encap": \
|
||||
"vlan-999"}}}]}}]}}, {"l3extRsEctx": {"attributes": {"dn": "uni/tn-test-tenant\
|
||||
/out-Shd-Sub/rsectx", "tnFvCtxName": "myl3p"}}}]}}'
|
||||
self.trimmed_l3out = [{}, {}, {}, {},
|
||||
{u'l3extRsNdIfPol':
|
||||
{u'tnNdIfPolName': u''}},
|
||||
{u'l3extRsDampeningPol':
|
||||
{u'tnRtctrlProfileName': u''}},
|
||||
{u'ospfRsIfPol': {u'tnOspfIfPolName': u''}},
|
||||
{u'l3extRsEngressQosDppPol':
|
||||
{u'tnQosDppPolName': u''}},
|
||||
{u'bfdRsIfPol': {u'tnBfdIfPolName': u''}},
|
||||
{u'bgpRsPeerPfxPol': {u'tnBgpPeerPfxPolName': u''}},
|
||||
{u'eigrpRsIfPol': {u'tnEigrpIfPolName': u''}},
|
||||
{u'l3extLNodeP':
|
||||
{u'attributes':
|
||||
{u'dn': u'uni/tn-test-tenant/out-Shd-Sub/lnodep-Leaf3-4_NP'},
|
||||
u'children': [{u'l3extLIfP':
|
||||
{u'children': [{u'l3extRsPathL3OutAtt':
|
||||
{u'attributes':
|
||||
{u'ifInstT':
|
||||
u'sub-interface',
|
||||
u'encap': 'vlan-999'
|
||||
}}}]}}]}},
|
||||
{u'l3extRsEctx':
|
||||
{u'attributes':
|
||||
{u'dn': u'uni/tn-test-tenant/out-Shd-Sub/rsectx',
|
||||
u'tnFvCtxName': u'myl3p'}}}]
|
||||
self.driver.apic_manager.apic.fvTenant.rn = echo2
|
||||
self.driver.apic_manager.apic.l3extOut.rn = echo2
|
||||
self.driver.l3out_vlan_alloc.reserve_vlan.return_value = 999
|
||||
|
@ -2049,6 +2064,22 @@ class TestL3Policy(ApicMappingTestCase):
|
|||
router_ports[0]['fixed_ips'][0]['subnet_id'] == subnet['id'] or
|
||||
router_ports[1]['fixed_ips'][0]['subnet_id'] == subnet['id'])
|
||||
|
||||
def _wrap_up_l3out_request(self, l3out_str, l3p_id, es_id):
|
||||
# try to simulate what the implementation does here also for UT purpose
|
||||
|
||||
request = {}
|
||||
request['children'] = self.trimmed_l3out
|
||||
request['attributes'] = {'rn': u'Shd-Sub'}
|
||||
|
||||
final_req = {}
|
||||
final_req['l3extOut'] = request
|
||||
final_req = jsonutils.dumps(final_req)
|
||||
final_req = re.sub('Shd-Sub',
|
||||
l3out_str % (l3p_id, es_id), final_req)
|
||||
final_req = re.sub('{},*', '', final_req)
|
||||
|
||||
return final_req
|
||||
|
||||
def _test_l3p_plugged_to_es_at_creation(self, shared_es,
|
||||
shared_l3p, is_edge_nat=False):
|
||||
# Verify L3P is correctly plugged to ES on APIC during create
|
||||
|
@ -2158,8 +2189,8 @@ class TestL3Policy(ApicMappingTestCase):
|
|||
mgr.ensure_static_route_created.call_args_list)
|
||||
else:
|
||||
if is_edge_nat and self.nat_enabled:
|
||||
final_req = re.sub('Shd-Sub',
|
||||
l3out_str % (l3p['id'], es['id']), self.trimmed_l3out)
|
||||
final_req = self._wrap_up_l3out_request(l3out_str,
|
||||
l3p['id'], es['id'])
|
||||
mgr.apic.post_body.assert_called_once_with(
|
||||
mgr.apic.l3extOut.mo, final_req, l3p_owner,
|
||||
l3out_str % (l3p['id'], es['id']))
|
||||
|
@ -2308,8 +2339,8 @@ class TestL3Policy(ApicMappingTestCase):
|
|||
mgr.ensure_static_route_created.call_args_list)
|
||||
else:
|
||||
if is_edge_nat and self.nat_enabled:
|
||||
final_req = re.sub('Shd-Sub',
|
||||
l3out_str % (l3p['id'], es['id']), self.trimmed_l3out)
|
||||
final_req = self._wrap_up_l3out_request(l3out_str,
|
||||
l3p['id'], es['id'])
|
||||
mgr.apic.post_body.assert_called_once_with(
|
||||
mgr.apic.l3extOut.mo, final_req, l3p_owner,
|
||||
l3out_str % (l3p['id'], es['id']))
|
||||
|
@ -2616,9 +2647,8 @@ class TestL3Policy(ApicMappingTestCase):
|
|||
mgr.ensure_logical_node_profile_created.call_args_list)
|
||||
else:
|
||||
if is_edge_nat and self.nat_enabled:
|
||||
final_req = re.sub('Shd-Sub',
|
||||
l3out_str % (l3p['id'], es2['id']),
|
||||
self.trimmed_l3out)
|
||||
final_req = self._wrap_up_l3out_request(l3out_str,
|
||||
l3p['id'], es2['id'])
|
||||
mgr.apic.post_body.assert_called_once_with(
|
||||
mgr.apic.l3extOut.mo, final_req, l3p_owner,
|
||||
l3out_str % (l3p['id'], es2['id']))
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
# preserve old behavior of using an arg as a regex when '--' is not present
|
||||
case $@ in
|
||||
(*--*) ostestr $@;;
|
||||
('') ostestr;;
|
||||
(*) ostestr --regex "$@"
|
||||
esac
|
14
tox.ini
14
tox.ini
|
@ -1,20 +1,21 @@
|
|||
[tox]
|
||||
envlist = py27,py33,pep8
|
||||
minversion = 1.6
|
||||
minversion = 2.3.1
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
# Note the hash seed is set to 0 until neutron can be tested with a
|
||||
# random hash seed successfully.
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
PYTHONHASHSEED=0
|
||||
passenv = TRACE_FAILONLY GENERATE_HASHES http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
|
||||
usedevelop = True
|
||||
install_command =
|
||||
{toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
pip install -U -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/mitaka} {opts} {packages}
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
whitelist_externals = sh
|
||||
commands =
|
||||
python setup.py testr --slowest --testr-args='{posargs}'
|
||||
{toxinidir}/tools/ostestr_compat_shim.sh {posargs}
|
||||
# there is also secret magic in ostestr which lets you run in a fail only
|
||||
# mode. To do this define the TRACE_FAILONLY environmental variable.
|
||||
|
||||
[testenv:hashtest]
|
||||
# This is the same as default environment, but with a random PYTHONHASHSEED.
|
||||
|
@ -56,6 +57,7 @@ commands =
|
|||
coverage html --include='gbpservice/*' -d covhtml -i
|
||||
|
||||
[testenv:venv]
|
||||
install_command = pip install -U {opts} {packages}
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:docs]
|
||||
|
|
Loading…
Reference in New Issue