[Gate] Avoid sphinx_build error and fix functional test

Sphinx version 1.7.5 is raised doc build failures. Maybe deps are not
suitable with current sphinx version.

This patch fixes functional test, due to neutron out of date
version and setns() of pynetns doesn't return any open FD anymore [2].

[1] http://lists.openstack.org/pipermail/openstack-dev/2018-April/128986.html
[2] 2e7964f498

Co-Authored-By: Nguyen Phuong An <AnNP@vn.fujitsu.com>
Change-Id: I44c89a4637a6c6b10f374f83ff76fb1225b603b7
This commit is contained in:
Nguyen Van Trung 2018-07-04 20:28:13 +07:00
parent 4b4db7e98c
commit 1f3bfe2f6f
6 changed files with 38 additions and 37 deletions

View File

@ -50,12 +50,19 @@ extensions = ['sphinxcontrib.apidoc',
'oslo_config.sphinxconfiggen',
'openstackdocstheme',]
try:
import openstackdocstheme
extensions.append('openstackdocstheme')
except ImportError:
openstackdocstheme = None
todo_include_todos = True
# sphinxcontrib.apidoc options
apidoc_module_dir = '../../neutron_fwaas'
apidoc_output_dir = 'contributor/api'
apidoc_excluded_paths = [
'db/migration/alembic_migrations/*',
'setup.py',
'tests/*',
'tests']
@ -141,7 +148,10 @@ modindex_common_prefix = ['neutron_fwaas.']
# Sphinx are currently 'default' and 'sphinxdoc'.
# html_theme_path = ["."]
# html_theme = '_theme'
html_theme = 'openstackdocs'
if openstackdocstheme is not None:
html_theme = 'openstackdocs'
else:
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@ -258,7 +268,7 @@ _config_generator_config_files = [
]
def _get_config_generator_config_definition(config_file):
def _get_config_generator_config_definition(conf):
config_file_path = '../../etc/oslo-config-generator/%s' % conf
# oslo_config.sphinxconfiggen appends '.conf.sample' to the filename,
# strip file extentension (.conf or .ini).

View File

@ -52,7 +52,7 @@ munch==2.1.0
netaddr==0.7.18
netifaces==0.10.4
neutron-lib==1.13.0
neutron==12.0.0
neutron==13.0.0.0b1
openstackdocstheme==1.18.1
openstacksdk==0.11.2
os-client-config==1.28.0

View File

@ -45,20 +45,17 @@ def in_namespace(namespace):
org_netns_fd = os.open(PROCESS_NETNS, os.O_RDONLY)
try:
new_netns_fd = pynetns.setns(namespace)
pynetns.setns(namespace)
try:
try:
yield
finally:
try:
# NOTE(cby): this code is not executed only if we fail to
# move in target namespace
pynetns.setns(org_netns_fd)
except Exception as e:
msg = _('Failed to move back in original netns: %s') % e
LOG.critical(msg)
raise BackInNamespaceExit(msg)
yield
finally:
os.close(new_netns_fd)
try:
# NOTE(cby): this code is not executed only if we fail to
# move in target namespace
pynetns.setns(org_netns_fd)
except Exception as e:
msg = _('Failed to move back in original netns: %s') % e
LOG.critical(msg)
raise BackInNamespaceExit(msg)
finally:
os.close(org_netns_fd)

View File

@ -39,25 +39,14 @@ class InNamespaceTest(base.BaseTestCase):
self.addCleanup(close_patch.stop)
self.setns_mock = mock.patch(
'pyroute2.netns.setns', side_effect=self.fake_setns
).start()
def fake_setns(self, setns):
if setns is self.ORG_NETNS_FD:
return self.ORG_NETNS_FD
elif setns is self.NEW_NETNS:
return self.NEW_NETNS_FD
else:
self.fail('invalid netns name')
'pyroute2.netns.setns').start()
def test_in_namespace(self):
with utils.in_namespace(self.NEW_NETNS):
self.setns_mock.assert_called_once_with(self.NEW_NETNS)
setns_calls = [mock.call(self.NEW_NETNS),
mock.call(self.ORG_NETNS_FD)]
close_calls = [mock.call(self.NEW_NETNS_FD),
mock.call(self.ORG_NETNS_FD)]
setns_calls = [mock.call(self.ORG_NETNS_FD)]
close_calls = [mock.call(self.ORG_NETNS_FD)]
self.setns_mock.assert_has_calls(setns_calls)
self.close_mock.assert_has_calls(close_calls)
@ -74,10 +63,8 @@ class InNamespaceTest(base.BaseTestCase):
self.setns_mock.assert_called_once_with(self.NEW_NETNS)
raise ValueError
setns_calls = [mock.call(self.NEW_NETNS),
mock.call(self.ORG_NETNS_FD)]
close_calls = [mock.call(self.NEW_NETNS_FD),
mock.call(self.ORG_NETNS_FD)]
setns_calls = [mock.call(self.ORG_NETNS_FD)]
close_calls = [mock.call(self.ORG_NETNS_FD)]
self.setns_mock.assert_has_calls(setns_calls)
self.close_mock.assert_has_calls(close_calls)

View File

@ -17,4 +17,4 @@ oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0
oslo.privsep>=1.23.0 # Apache-2.0
pyroute2>=0.4.21;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2)
neutron>=12.0.0 # Apache-2.0
neutron>=13.0.0.0b1 # Apache-2.0

11
tox.ini
View File

@ -10,10 +10,14 @@ usedevelop = True
deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
whitelist_externals = sh find
whitelist_externals =
sh
find
rm
commands =
find . -type f -name "*.py[c|o]" -delete
find . -type d -name "__pycache__" -delete
rm -rf .tox/lower-constraints/*
{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.
@ -79,8 +83,11 @@ commands =
commands = {posargs}
[testenv:docs]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html
commands =
rm -rf doc/source/contributor/api
sphinx-build -W -b html doc/source doc/build/html
[doc8]
ignore = D000