Commit Graph

19 Commits

Author SHA1 Message Date
tpltnt
c8f11dc2d3 ported old-style classes to new-style 2019-05-26 08:28:18 +02:00
Daira Hopwood
3ae6ceb6a8 Add Namespace utility class. (This is already used in the leasedb/cloud backend branch.)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2015-07-17 22:12:25 +01:00
Brian Warner
d27a57cb49 Avoid Popen() of executables that don't exist
The stdlib 'subprocess' module in python-2.7.4 through 2.7.7 suffers
from http://bugs.python.org/issue18851 which causes unrelated file
descriptors to be closed when `subprocess.call()` fails the `exec()`,
such as when the executable being invoked does not actually exist. There
appears to be some randomness involved. This was fixed in python-2.7.8.

Tahoe's iputil.py uses subprocess.call on many different "ifconfig"-type
executables, most of which don't exist on any given platform (added in
git commit 8e31d66cd0). This results in a lot of file-descriptor
closing, which (at least during unit tests) tends to clobber important
things like Tub TCP sockets. This seems to be the root cause behind
ticket:2121, in which normal code tries to close already-closed sockets,
crashing the unit tests. Since different platforms have different
ifconfigs, some platforms will experience more failed execs than others,
so this bug could easily behave differently on linux vs freebsd, as well
as working normally on python-2.7.8 or 2.7.4.

This patch inserts a guard to make sure that os.path.isfile() is true
before allowing Popen.call() to try executing the target. This ought to
be enough to avoid the bug. It changes both iputil.py and
allmydata.__init__ (which uses Popen for calling "lsb_release"), which
are all the places where 'subprocess' is used outside of unit tests.

Other potential fixes: use the 'subprocess32' module from PyPI (which is
a bug-free backport of the Python3 stdlib subprocess module, but would
introduce a new dependency), or require python >= 2.7.8 (but this would
rule out development/deployment on the current OS-X 10.9 release, which
ships with 2.7.5, as well as other distributions like Ubuntu 14.04 LTS).

I believe this closes ticket:2121, and given the apparent relationship
between 2121 and 2023, I think it also closes ticket:2023 (although
since 2023 doesn't have copies of the failing log files, it's hard to
tell). I'm hoping that this will tide us over until 1.11 is released, at
which point we can execute on the plan to remove iputil.py entirely by
changing the way that nodes learn their externally-facing IP address.
2014-09-12 13:01:56 -07:00
Daira Hopwood
b088380736 test_iputil.py: fix and improve tests on Windows.
Test all platform variants (Unix, Windows, Cygwin) on each platform.

Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>
2013-06-26 16:44:05 +01:00
Daira Hopwood
f97b8e5e1d test_iputil.py: repair a test for cygwin (which is intended to behave differently).
Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>
2013-06-25 23:32:02 +01:00
Daira Hopwood
16b245563d test_iputil.py: use more realistic error for 'command not found' in mock.
Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>
2013-06-25 19:50:52 +01:00
Daira Hopwood
b31a4f6e87 test_iputil.py: repair a test by mocking 'get_local_ip_for'.
Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>
2013-06-25 19:50:00 +01:00
Daira Hopwood
a493ee0bb6 iputil.py: add tests for recent changes. refs #1381, #1988, #982, #1064, #1536, #1935, #898, #1707, #1918
Signed-off-by: Daira Hopwood <david-sarah@jacaranda.org>
2013-06-25 19:15:05 +01:00
Zooko O'Whielacronx
f19c240ca8 tests: bump up the timeout on this iputil test from 2s to 4s 2010-06-09 07:30:17 -07:00
david-sarah
e76092e16c Change relative imports to absolute 2010-02-26 01:14:33 -07:00
Brian Warner
b73c380cdb move testutil into test/common_util.py, since it doesn't count as 'code under test' for our pyflakes numbers 2008-10-28 21:28:31 -07:00
Zooko O'Whielacronx
af0edec753 filter out "0.0.0.0" from detected IP addresses 2007-10-13 00:38:16 -07:00
Brian Warner
8307aaccb6 testutil: make SignalMixin actually be a mixin (and not inherit from TestCase), use it from all tests that start notes and thus exec ifconfig 2007-04-23 21:15:02 -07:00
Brian Warner
073333c791 iputil/testutil: fix pyflakes errors/warnings 2007-04-18 18:33:37 -07:00
Zooko O'Whielacronx
a154641462 iputil.list_async_addresses now "works" on cygwin 2007-04-18 17:30:08 -07:00
Brian Warner
88a7fdcaab test_iputil: improve error message 2007-04-16 15:05:25 -07:00
Brian Warner
93c4a5ebb0 test_iputil: remove the test that only works on linux, since we're using the cross-unix 'get_local_addresses_async' anyways. This should allow the tests to pass on OS-X 2007-03-29 11:21:17 -07:00
Brian Warner
2c261ce996 change node startup to put all local addresses in the PBURL, including 127.0.0.1. This should facilitate testing on both connected and disconnected systems. 2007-03-07 18:43:17 -07:00
Brian Warner
18325251bf iputil: add get_local_addresses(), an attempt to enumerate all IPv4 addresses on this host. This is pretty unix-specific for right now (it calls ifconfig) 2007-03-07 18:22:30 -07:00