yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #55839
[Bug 1619028] Re: test_get_free_namespace_port fails on systems without sysctl
Reviewed: https://review.openstack.org/363917
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=5e4204804ea4b364d27d014d13ecb529bc370ea6
Submitter: Jenkins
Branch: master
commit 5e4204804ea4b364d27d014d13ecb529bc370ea6
Author: Corey Wright <corey.wright@xxxxxxxxxxxxx>
Date: Wed Aug 31 14:34:13 2016 -0500
Mock call to sysctl for test_get_free_namespace_port
The code under test shouldn't execute local commands for multiple
reasons (eg the command doesn't exist on the test system), so mock out
the execution of sysctl in test_get_free_namespace_port (copying the
code from test_get_unused_port).
Change-Id: I58aa578274310ae2ca015069f99edb84716fb0b5
Closes-bug: #1619028
** Changed in: neutron
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1619028
Title:
test_get_free_namespace_port fails on systems without sysctl
Status in neutron:
Fix Released
Bug description:
If the unit test test_get_free_namespace_port runs on a system without
sysctl, then the test fails as it tries to execute sysctl, because
sysctl doesn't exist.
======================================================================
FAIL: neutron.tests.unit.tests.common.test_net_helpers.PortAllocationTestCase.test_get_free_namespace_port
neutron.tests.unit.tests.common.test_net_helpers.PortAllocationTestCase.test_get_free_namespace_port
----------------------------------------------------------------------
_StringException: Empty attachments:
pythonlogging:''
stderr
stdout
Traceback (most recent call last):
File "neutron/tests/unit/tests/common/test_net_helpers.py", line 65, in test_get_free_namespace_port
n_const.PROTO_NAME_TCP)
File "neutron/tests/common/net_helpers.py", line 215, in get_free_namespace_port
return get_unused_port(used_ports)
File "neutron/tests/common/net_helpers.py", line 186, in get_unused_port
['sysctl', '-n', 'net.ipv4.ip_local_port_range'])
File "neutron/agent/linux/utils.py", line 117, in execute
addl_env=addl_env)
File "neutron/agent/linux/utils.py", line 87, in create_process
stderr=subprocess.PIPE)
File "neutron/common/utils.py", line 85, in subprocess_popen
close_fds=close_fds, env=env)
File "/var/lib/jenkins/workspace/test-neutron-rax-patches-change/virtualenv/local/lib/python2.7/site-packages/eventlet/green/subprocess.py", line 53, in __init__
subprocess_orig.Popen.__init__(self, args, 0, *argss, **kwds)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Code under test shouldn't be allowed to execute local commands for multiple reasons:
0. a test system is not a deployment system
1. the command might not exist
2. the command's output might be system-dependent
3. the command might unintentionally alter the state of the system
The execution of sysctl should be mocked.
To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1619028/+subscriptions
References