tahoe-lafs/src/allmydata/test/test_node.py

749 lines
25 KiB
Python
Raw Normal View History

from past.builtins import unicode
2018-02-07 10:05:21 +00:00
import base64
import os
import stat
import sys
import time
import mock
from textwrap import dedent
2018-08-24 22:51:47 +00:00
from unittest import skipIf
from twisted.trial import unittest
2007-05-24 00:55:04 +00:00
from twisted.internet import defer
from twisted.python import log
from foolscap.api import flushEventualQueue
import foolscap.logging.log
from twisted.application import service
from allmydata.node import (
create_tub_options,
create_main_tub,
create_node_dir,
create_connection_handlers,
config_from_string,
read_config,
MissingConfigEntry,
_tub_portlocation,
formatTimeTahoeStyle,
)
from allmydata.introducer.server import create_introducer
from allmydata import client
from allmydata.util import fileutil, iputil
from allmydata.util.namespace import Namespace
2018-05-29 23:11:28 +00:00
from allmydata.util.configutil import UnknownConfigError
from allmydata.util.i2p_provider import create as create_i2p_provider
from allmydata.util.tor_provider import create as create_tor_provider
2010-02-26 08:14:33 +00:00
import allmydata.test.common_util as testutil
class LoggingMultiService(service.MultiService):
def log(self, msg, **kw):
pass
2018-09-06 18:37:30 +00:00
# see https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2946
2018-01-28 08:27:25 +00:00
def testing_tub(config_data=''):
2018-08-31 19:27:47 +00:00
"""
Creates a 'main' Tub for testing purposes, from config data
"""
2018-01-28 08:27:25 +00:00
from twisted.internet import reactor
basedir = 'dummy_basedir'
2018-03-13 23:11:30 +00:00
config = config_from_string(basedir, 'DEFAULT_PORTNUMFILE_BLANK', config_data)
2018-01-28 08:27:25 +00:00
fileutil.make_dirs(os.path.join(basedir, 'private'))
2018-01-31 20:15:01 +00:00
i2p_provider = create_i2p_provider(reactor, config)
tor_provider = create_tor_provider(reactor, config)
handlers = create_connection_handlers(reactor, config, i2p_provider, tor_provider)
2018-01-28 08:27:25 +00:00
default_connection_handlers, foolscap_connection_handlers = handlers
tub_options = create_tub_options(config)
2018-03-06 23:29:24 +00:00
main_tub = create_main_tub(
2018-01-31 20:15:01 +00:00
config, tub_options, default_connection_handlers,
2018-01-28 08:27:25 +00:00
foolscap_connection_handlers, i2p_provider, tor_provider,
cert_filename='DEFAULT_CERTFILE_BLANK'
)
return main_tub
class TestCase(testutil.SignalMixin, unittest.TestCase):
2017-08-08 16:42:11 +00:00
@defer.inlineCallbacks
def setUp(self):
testutil.SignalMixin.setUp(self)
self.parent = LoggingMultiService()
self.parent.startService()
2017-08-08 16:42:11 +00:00
self._available_port = yield iputil.allocate_tcp_port()
def tearDown(self):
log.msg("%s.tearDown" % self.__class__.__name__)
testutil.SignalMixin.tearDown(self)
d = defer.succeed(None)
d.addCallback(lambda res: self.parent.stopService())
d.addCallback(flushEventualQueue)
return d
def _test_location(self, basedir, expected_addresses, tub_port=None, tub_location=None, local_addresses=None):
2018-02-27 22:00:31 +00:00
create_node_dir(basedir, "testing")
2018-03-04 21:29:17 +00:00
config_data = "[node]\n"
if tub_port:
config_data += "tub.port = {}\n".format(tub_port)
if tub_location is not None:
config_data += "tub.location = {}\n".format(tub_location)
if local_addresses:
self.patch(iputil, 'get_local_addresses_sync',
lambda: local_addresses)
2018-01-28 08:27:25 +00:00
tub = testing_tub(config_data)
tub.setServiceParent(self.parent)
class Foo(object):
pass
furl = tub.registerReference(Foo())
for address in expected_addresses:
self.failUnlessIn(address, furl)
def test_location1(self):
return self._test_location(basedir="test_node/test_location1",
expected_addresses=["192.0.2.0:1234"],
tub_location="192.0.2.0:1234")
def test_location2(self):
return self._test_location(basedir="test_node/test_location2",
expected_addresses=["192.0.2.0:1234", "example.org:8091"],
tub_location="192.0.2.0:1234,example.org:8091")
def test_location_not_set(self):
"""Checks the autogenerated furl when tub.location is not set."""
2017-08-08 16:42:11 +00:00
return self._test_location(
basedir="test_node/test_location3",
expected_addresses=[
"127.0.0.1:{}".format(self._available_port),
"192.0.2.0:{}".format(self._available_port),
],
tub_port=self._available_port,
local_addresses=["127.0.0.1", "192.0.2.0"],
)
def test_location_auto_and_explicit(self):
"""Checks the autogenerated furl when tub.location contains 'AUTO'."""
2017-08-08 16:42:11 +00:00
return self._test_location(
basedir="test_node/test_location4",
expected_addresses=[
"127.0.0.1:{}".format(self._available_port),
"192.0.2.0:{}".format(self._available_port),
"example.com:4321",
],
tub_port=self._available_port,
tub_location="AUTO,example.com:{}".format(self._available_port),
local_addresses=["127.0.0.1", "192.0.2.0", "example.com:4321"],
)
def test_tahoe_cfg_utf8(self):
basedir = "test_node/test_tahoe_cfg_utf8"
fileutil.make_dirs(basedir)
f = open(os.path.join(basedir, 'tahoe.cfg'), 'wb')
f.write(u"\uFEFF[node]\n".encode('utf-8'))
f.write(u"nickname = \u2621\n".encode('utf-8'))
f.close()
config = read_config(basedir, "")
self.failUnlessEqual(config.get_config("node", "nickname").decode('utf-8'),
u"\u2621")
def test_tahoe_cfg_hash_in_name(self):
basedir = "test_node/test_cfg_hash_in_name"
nickname = "Hash#Bang!" # a clever nickname containing a hash
fileutil.make_dirs(basedir)
f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt')
f.write("[node]\n")
f.write("nickname = %s\n" % (nickname,))
f.close()
config = read_config(basedir, "")
self.failUnless(config.nickname == nickname)
2018-03-01 23:07:52 +00:00
def test_config_required(self):
2018-08-24 22:50:04 +00:00
"""
Asking for missing (but required) configuration is an error
"""
2018-03-01 23:07:52 +00:00
basedir = u"test_node/test_config_required"
config = read_config(basedir, "portnum")
2018-03-02 03:51:35 +00:00
with self.assertRaises(Exception):
2018-03-01 23:07:52 +00:00
config.get_config_from_file("it_does_not_exist", required=True)
def test_config_items(self):
"""
All items in a config section can be retrieved.
"""
basedir = u"test_node/test_config_items"
create_node_dir(basedir, "testing")
with open(os.path.join(basedir, 'tahoe.cfg'), 'wt') as f:
f.write(dedent(
"""
[node]
nickname = foo
timeout.disconnect = 12
"""
))
config = read_config(basedir, "portnum")
self.assertEqual(
config.items("node"),
2020-10-16 14:47:49 +00:00
[("nickname", "foo"),
("timeout.disconnect", "12"),
],
)
2018-08-24 22:51:47 +00:00
@skipIf(
"win32" in sys.platform.lower() or "cygwin" in sys.platform.lower(),
"We don't know how to set permissions on Windows.",
)
2018-03-01 23:07:52 +00:00
def test_private_config_unreadable(self):
2018-08-24 22:50:04 +00:00
"""
Asking for inaccessible private config is an error
"""
2018-03-01 23:07:52 +00:00
basedir = u"test_node/test_private_config_unreadable"
create_node_dir(basedir, "testing")
config = read_config(basedir, "portnum")
config.get_or_create_private_config("foo", "contents")
fname = os.path.join(basedir, "private", "foo")
os.chmod(fname, 0)
2018-03-02 03:51:35 +00:00
with self.assertRaises(Exception):
2018-03-01 23:07:52 +00:00
config.get_or_create_private_config("foo")
2018-08-25 06:36:58 +00:00
@skipIf(
"win32" in sys.platform.lower() or "cygwin" in sys.platform.lower(),
"We don't know how to set permissions on Windows.",
)
2018-03-01 23:07:52 +00:00
def test_private_config_unreadable_preexisting(self):
2018-08-25 06:36:58 +00:00
"""
error if reading private config data fails
"""
2018-03-01 23:07:52 +00:00
basedir = u"test_node/test_private_config_unreadable_preexisting"
create_node_dir(basedir, "testing")
config = read_config(basedir, "portnum")
fname = os.path.join(basedir, "private", "foo")
with open(fname, "w") as f:
f.write("stuff")
os.chmod(fname, 0)
2018-03-02 03:51:35 +00:00
with self.assertRaises(Exception):
2018-03-01 23:07:52 +00:00
config.get_private_config("foo")
def test_private_config_missing(self):
2018-08-25 06:31:16 +00:00
"""
a missing config with no default is an error
"""
2018-03-01 23:07:52 +00:00
basedir = u"test_node/test_private_config_missing"
create_node_dir(basedir, "testing")
config = read_config(basedir, "portnum")
2018-03-02 03:51:35 +00:00
with self.assertRaises(MissingConfigEntry):
2018-03-01 23:07:52 +00:00
config.get_or_create_private_config("foo")
def test_private_config(self):
2018-01-29 01:59:56 +00:00
basedir = u"test_node/test_private_config"
privdir = os.path.join(basedir, "private")
fileutil.make_dirs(privdir)
f = open(os.path.join(privdir, 'already'), 'wt')
f.write("secret")
f.close()
2018-01-29 01:59:56 +00:00
basedir = fileutil.abspath_expanduser_unicode(basedir)
2018-03-13 23:11:30 +00:00
config = config_from_string(basedir, "", "")
2018-08-25 06:37:11 +00:00
self.assertEqual(config.get_private_config("already"), "secret")
self.assertEqual(config.get_private_config("not", "default"), "default")
self.assertRaises(MissingConfigEntry, config.get_private_config, "not")
value = config.get_or_create_private_config("new", "start")
2018-08-25 06:37:11 +00:00
self.assertEqual(value, "start")
self.assertEqual(config.get_private_config("new"), "start")
counter = []
def make_newer():
counter.append("called")
return "newer"
value = config.get_or_create_private_config("newer", make_newer)
2018-08-25 06:37:11 +00:00
self.assertEqual(len(counter), 1)
self.assertEqual(value, "newer")
self.assertEqual(config.get_private_config("newer"), "newer")
value = config.get_or_create_private_config("newer", make_newer)
2018-08-25 06:37:11 +00:00
self.assertEqual(len(counter), 1) # don't call unless necessary
self.assertEqual(value, "newer")
def test_write_config_unwritable_file(self):
2018-02-27 01:25:55 +00:00
"""
Existing behavior merely logs any errors upon writing
2018-02-27 22:01:18 +00:00
configuration files; this bad behavior should probably be
fixed to do something better (like fail entirely). See #2905
2018-02-27 01:25:55 +00:00
"""
basedir = "test_node/configdir"
fileutil.make_dirs(basedir)
2018-03-13 23:11:30 +00:00
config = config_from_string(basedir, "", "")
with open(os.path.join(basedir, "bad"), "w") as f:
f.write("bad")
os.chmod(os.path.join(basedir, "bad"), 0o000)
config.write_config_file("bad", "some value")
2018-02-27 22:01:18 +00:00
errs = self.flushLoggedErrors(IOError)
self.assertEqual(1, len(errs))
def test_timestamp(self):
# this modified logger doesn't seem to get used during the tests,
# probably because we don't modify the LogObserver that trial
# installs (only the one that twistd installs). So manually exercise
# it a little bit.
t = formatTimeTahoeStyle("ignored", time.time())
self.failUnless("Z" in t)
t2 = formatTimeTahoeStyle("ignored", int(time.time()))
self.failUnless("Z" in t2)
def test_secrets_dir(self):
basedir = "test_node/test_secrets_dir"
2018-02-27 22:00:31 +00:00
create_node_dir(basedir, "testing")
self.failUnless(os.path.exists(os.path.join(basedir, "private")))
def test_secrets_dir_protected(self):
if "win32" in sys.platform.lower() or "cygwin" in sys.platform.lower():
# We don't know how to test that unprivileged users can't read this
# thing. (Also we don't know exactly how to set the permissions so
# that unprivileged users can't read this thing.)
raise unittest.SkipTest("We don't know how to set permissions on Windows.")
basedir = "test_node/test_secrets_dir_protected"
2018-02-27 22:00:31 +00:00
create_node_dir(basedir, "nothing to see here")
2018-02-27 22:00:31 +00:00
# make sure private dir was created with correct modes
privdir = os.path.join(basedir, "private")
st = os.stat(privdir)
bits = stat.S_IMODE(st[stat.ST_MODE])
self.failUnless(bits & 0o001 == 0, bits)
2018-03-04 21:29:17 +00:00
@defer.inlineCallbacks
def test_logdir_is_str(self):
basedir = "test_node/test_logdir_is_str"
ns = Namespace()
ns.called = False
def call_setLogDir(logdir):
ns.called = True
self.failUnless(isinstance(logdir, unicode), logdir)
self.patch(foolscap.logging.log, 'setLogDir', call_setLogDir)
2018-02-27 22:00:31 +00:00
create_node_dir(basedir, "nothing to see here")
2018-03-05 01:20:13 +00:00
yield client.create_client(basedir)
self.failUnless(ns.called)
2018-02-27 22:00:31 +00:00
class TestMissingPorts(unittest.TestCase):
"""
Test certain error-cases for ports setup
"""
def setUp(self):
self.basedir = self.mktemp()
create_node_dir(self.basedir, "testing")
2018-08-25 06:31:16 +00:00
def test_parsing_tcp(self):
"""
parse explicit tub.port with explicitly-default tub.location
"""
get_addr = mock.patch(
"allmydata.util.iputil.get_local_addresses_sync",
return_value=["LOCAL"],
)
alloc_port = mock.patch(
"allmydata.util.iputil.allocate_tcp_port",
return_value=999,
)
2018-03-05 04:30:52 +00:00
config_data = (
"[node]\n"
"tub.port = tcp:777\n"
"tub.location = AUTO\n"
)
2018-03-13 23:11:30 +00:00
config = config_from_string(self.basedir, "portnum", config_data)
with get_addr, alloc_port:
2018-03-05 04:30:52 +00:00
tubport, tublocation = _tub_portlocation(config)
self.assertEqual(tubport, "tcp:777")
self.assertEqual(tublocation, "tcp:LOCAL:777")
2018-08-25 06:31:16 +00:00
def test_parsing_defaults(self):
"""
parse empty config, check defaults
"""
get_addr = mock.patch(
"allmydata.util.iputil.get_local_addresses_sync",
return_value=["LOCAL"],
)
alloc_port = mock.patch(
"allmydata.util.iputil.allocate_tcp_port",
return_value=999,
2018-05-29 21:52:09 +00:00
)
2018-03-05 04:30:52 +00:00
config_data = (
"[node]\n"
)
2018-03-13 23:11:30 +00:00
config = config_from_string(self.basedir, "portnum", config_data)
with get_addr, alloc_port:
2018-03-05 04:30:52 +00:00
tubport, tublocation = _tub_portlocation(config)
self.assertEqual(tubport, "tcp:999")
self.assertEqual(tublocation, "tcp:LOCAL:999")
2018-08-25 06:31:16 +00:00
def test_parsing_location_complex(self):
"""
location with two options (including defaults)
"""
get_addr = mock.patch(
"allmydata.util.iputil.get_local_addresses_sync",
return_value=["LOCAL"],
)
alloc_port = mock.patch(
"allmydata.util.iputil.allocate_tcp_port",
return_value=999,
)
2018-03-05 04:30:52 +00:00
config_data = (
"[node]\n"
"tub.location = tcp:HOST:888,AUTO\n"
)
2018-03-13 23:11:30 +00:00
config = config_from_string(self.basedir, "portnum", config_data)
with get_addr, alloc_port:
2018-03-05 04:30:52 +00:00
tubport, tublocation = _tub_portlocation(config)
self.assertEqual(tubport, "tcp:999")
self.assertEqual(tublocation, "tcp:HOST:888,tcp:LOCAL:999")
2018-08-25 06:31:16 +00:00
def test_parsing_all_disabled(self):
"""
parse config with both port + location disabled
"""
get_addr = mock.patch(
"allmydata.util.iputil.get_local_addresses_sync",
return_value=["LOCAL"],
)
alloc_port = mock.patch(
"allmydata.util.iputil.allocate_tcp_port",
return_value=999,
)
2018-03-05 04:30:52 +00:00
config_data = (
"[node]\n"
"tub.port = disabled\n"
"tub.location = disabled\n"
)
2018-03-13 23:11:30 +00:00
config = config_from_string(self.basedir, "portnum", config_data)
with get_addr, alloc_port:
2018-03-05 04:30:52 +00:00
res = _tub_portlocation(config)
self.assertTrue(res is None)
def test_empty_tub_port(self):
2018-08-25 06:31:16 +00:00
"""
port povided, but empty is an error
"""
config_data = (
"[node]\n"
"tub.port = \n"
)
2018-03-13 23:11:30 +00:00
config = config_from_string(self.basedir, "portnum", config_data)
with self.assertRaises(ValueError) as ctx:
2018-03-05 04:30:52 +00:00
_tub_portlocation(config)
self.assertIn(
"tub.port must not be empty",
str(ctx.exception)
)
def test_empty_tub_location(self):
2018-08-25 06:31:16 +00:00
"""
location povided, but empty is an error
"""
config_data = (
"[node]\n"
"tub.location = \n"
)
2018-03-13 23:11:30 +00:00
config = config_from_string(self.basedir, "portnum", config_data)
with self.assertRaises(ValueError) as ctx:
2018-03-05 04:30:52 +00:00
_tub_portlocation(config)
self.assertIn(
"tub.location must not be empty",
str(ctx.exception)
)
def test_disabled_port_not_tub(self):
2018-08-25 06:31:16 +00:00
"""
error to disable port but not location
"""
config_data = (
"[node]\n"
"tub.port = disabled\n"
"tub.location = not_disabled\n"
)
2018-03-13 23:11:30 +00:00
config = config_from_string(self.basedir, "portnum", config_data)
with self.assertRaises(ValueError) as ctx:
2018-03-05 04:30:52 +00:00
_tub_portlocation(config)
self.assertIn(
"tub.port is disabled, but not tub.location",
str(ctx.exception)
)
def test_disabled_tub_not_port(self):
2018-08-25 06:31:16 +00:00
"""
error to disable location but not port
"""
config_data = (
"[node]\n"
"tub.port = not_disabled\n"
"tub.location = disabled\n"
)
2018-03-13 23:11:30 +00:00
config = config_from_string(self.basedir, "portnum", config_data)
with self.assertRaises(ValueError) as ctx:
2018-03-05 04:30:52 +00:00
_tub_portlocation(config)
self.assertIn(
"tub.location is disabled, but not tub.port",
str(ctx.exception)
)
2018-01-28 08:32:13 +00:00
BASE_CONFIG = """
[client]
introducer.furl = empty
[tor]
enabled = false
[i2p]
enabled = false
"""
NOLISTEN = """
[node]
tub.port = disabled
tub.location = disabled
"""
DISABLE_STORAGE = """
[storage]
enabled = false
"""
ENABLE_STORAGE = """
[storage]
enabled = true
"""
ENABLE_HELPER = """
[helper]
enabled = true
"""
2019-05-15 06:17:44 +00:00
class FakeTub(object):
def __init__(self):
2020-10-16 14:47:49 +00:00
self.tubID = base64.b32encode(b"foo")
self.listening_ports = []
def setOption(self, name, value): pass
def removeAllConnectionHintHandlers(self): pass
def addConnectionHintHandler(self, hint_type, handler): pass
def listenOn(self, what):
self.listening_ports.append(what)
def setLocation(self, location): pass
def setServiceParent(self, parent): pass
class Listeners(unittest.TestCase):
2018-01-28 08:27:25 +00:00
2018-03-05 04:45:07 +00:00
def test_listen_on_zero(self):
"""
Trying to listen on port 0 should be an error
"""
basedir = self.mktemp()
create_node_dir(basedir, "testing")
with open(os.path.join(basedir, "tahoe.cfg"), "w") as f:
f.write(BASE_CONFIG)
fix(py3): Duplicate section name that py3 catches Python 3 raises an exception that Python 2 doesn't and as such exposes malformed cfg/ini contents used in the tests. The test output diff shows that this mostly converts test `DuplicateSectionError` errors to test errors with different exceptions which is reasonable for the type of fix this is. It does seem to reduce coverage which I'm guessing is because the malformed contents were triggering error handling code paths that aren't triggered now, but I haven't confirmed that. I would think that to cover those cases we should write tests that do that explicitly rather than accidentally. ```diff --- ../../.tox/make-test-py3-all-old.log 2020-10-04 15:13:09.670578482 -0700 +++ ../../.tox/make-test-py3-all-new.log 2020-10-04 15:16:34.054975263 -0700 @@ -1835,7 +1835,7 @@ raise self.failureException(msg) twisted.trial.unittest.FailTest: ['allmydata', 'allmydata.__main__', 'allm[5873 chars]try'] != set() : Some unported modules remain: Ported files: 96 / 292 -Ported lines: 27978 / 93480 +Ported lines: 27978 / 93482 allmydata.test.test_python3.Python3PortingEffortTests.test_finished_porting @@ -2166,11 +2166,11 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), -twisted.trial.unittest.FailTest: configparser.DuplicateSectionError raised instead of ValueError: +twisted.trial.unittest.FailTest: builtins.NameError raised instead of ValueError: Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks _inlineCallbacks(None, g, status) @@ -2178,12 +2178,12 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled_but_helper/tahoe.cfg' [line 10]: section 'node' already exists +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled_but_helper @@ -2194,11 +2194,11 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), -twisted.trial.unittest.FailTest: configparser.DuplicateSectionError raised instead of ValueError: +twisted.trial.unittest.FailTest: builtins.NameError raised instead of ValueError: Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks _inlineCallbacks(None, g, status) @@ -2206,12 +2206,12 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled_but_storage/tahoe.cfg' [line 10]: section 'node' already exists +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled_but_storage @@ -2222,7 +2222,7 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), @@ -2234,10 +2234,10 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) builtins.TypeError: startswith first arg must be str or a tuple of str, not bytes @@ -2250,7 +2250,7 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), @@ -2262,10 +2262,10 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/introducer/server.py", line 76, in create_introducer tor_provider, @@ -7432,23 +7432,17 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 655, in test_disabled + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 657, in test_disabled n = yield client.create_client(basedir) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 243, in create_client - config = read_config(basedir, u"client.port") - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 219, in read_config - _valid_config=_valid_config(), - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/node.py", line 187, in read_config - parser = configutil.get_config(config_fname) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/util/configutil.py", line 50, in get_config - config.readfp(f) - File "/usr/lib/python3.6/configparser.py", line 764, in readfp - self.read_file(fp, source=filename) - File "/usr/lib/python3.6/configparser.py", line 718, in read_file - self._read(f, source) - File "/usr/lib/python3.6/configparser.py", line 1067, in _read - lineno) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled/tahoe.cfg' [line 10]: section 'node' already exists + File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks + result = g.send(result) + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 285, in create_client_from_config + introducer_clients = create_introducer_clients(config, main_tub, _introducer_factory) + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 519, in create_introducer_clients + introducer_cache_filepath, + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/introducer/client.py", line 29, in __init__ + assert type(nickname) is unicode +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled =============================================================================== @@ -7456,7 +7450,7 @@ Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 577, in test_listen_on_zero t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -7466,9 +7460,9 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 605, in test_multiple_ports + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 606, in test_multiple_ports t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -7478,9 +7472,9 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 624, in test_tor_i2p_listeners + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 626, in test_tor_i2p_listeners t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -8781,11 +8775,11 @@ src/allmydata/immutable/downloader/__init__.py 7 1 2 1 78% 12, 11->12 src/allmydata/immutable/downloader/common.py 14 1 2 1 88% 12, 11->12 src/allmydata/immutable/downloader/fetcher.py 147 1 56 1 99% 12, 11->12 -src/allmydata/immutable/downloader/finder.py 143 9 40 5 92% 11, 88-89, 108, 115, 170-173, 10->11, 87->88, 107->108, 113->115, 165->exit +src/allmydata/immutable/downloader/finder.py 143 11 40 5 91% 11, 88-89, 108, 115, 170-173, 231-232, 10->11, 87->88, 107->108, 113->115, 165->exit src/allmydata/immutable/downloader/node.py 282 9 66 9 94% 11, 170-172, 224-235, 271, 10->11, 43->exit, 60->68, 165->169, 169->170, 256->exit, 270->271, 517->exit, 537->exit src/allmydata/immutable/downloader/segmentation.py 118 1 22 1 99% 11, 10->11 -src/allmydata/immutable/downloader/share.py 453 15 154 8 96% 11, 210, 248-250, 354, 430-437, 518, 722-725, 862, 10->11, 209->210, 239->248, 352->354, 515->518, 660->663, 710->722, 762->exit -src/allmydata/immutable/downloader/status.py 154 9 36 1 95% 11, 223, 226, 230, 232, 234, 274, 285, 287, 10->11 +src/allmydata/immutable/downloader/share.py 453 23 154 11 94% 11, 210, 239-250, 289-290, 354, 399-400, 430-437, 518, 722-725, 775, 862, 10->11, 209->210, 222->239, 288->289, 352->354, 397->399, 515->518, 660->663, 710->722, 762->exit, 774->775 +src/allmydata/immutable/downloader/status.py 154 12 36 1 93% 11, 65-67, 223, 226, 230, 232, 234, 274, 285, 287, 10->11 src/allmydata/immutable/encode.py 421 13 124 10 95% 114, 197-200, 278-280, 405, 412, 462, 509, 562, 687, 102->104, 113->114, 195->197, 404->405, 411->412, 461->462, 499->509, 505->511, 561->562, 685->687 src/allmydata/immutable/filenode.py 196 48 30 5 72% 77-78, 83, 85, 88, 94-101, 104-124, 127-172, 254, 258, 315, 40->42, 224->227, 227->229, 251->254, 257->258 src/allmydata/immutable/happiness_upload.py 214 1 132 3 99% 15, 13->15, 213->211, 280->279 @@ -8808,7 +8802,7 @@ src/allmydata/mutable/repairer.py 57 37 18 0 29% 13, 15, 17, 19, 29-34, 65-71, 74-126, 129-131 src/allmydata/mutable/retrieve.py 489 123 120 33 71% 46, 48, 50, 52, 56, 58, 60, 62, 64, 89-90, 133, 186-193, 204-208, 211-212, 224-226, 231, 240, 251, 312, 318, 344-354, 377, 385-386, 399-400, 425-434, 490, 501, 515-516, 529-540, 564-578, 591-592, 629-630, 653-654, 674-675, 681-682, 698, 712-729, 758-760, 765, 772-774, 790-792, 871, 883, 909-910, 919-941, 965-966, 981-994, 999-1005, 129->133, 167->169, 169->171, 201->204, 223->224, 230->231, 237->239, 239->240, 243->247, 249->251, 309->312, 317->318, 376->377, 381->385, 391->394, 396->399, 424->425, 489->490, 499->501, 514->515, 590->591, 628->629, 652->653, 673->674, 677->687, 680->681, 687->694, 694->698, 755->764, 764->765, 868->871, 880->883, 964->965 src/allmydata/mutable/servermap.py 612 240 186 26 56% 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 74, 130-139, 142, 148, 159-161, 175, 177, 183, 186-199, 206, 213, 217-220, 231, 234-238, 243-252, 255-259, 315, 328-350, 358-363, 370-372, 379, 429, 433, 443-447, 495, 498, 506-508, 514-516, 569-570, 603-611, 623-638, 718-721, 732-741, 792, 796, 803-804, 850-851, 872-874, 911-915, 929-945, 961-975, 982-999, 1003-1013, 1043-1045, 1050-1052, 1060-1064, 1069-1070, 1093-1100, 1106-1186, 1214-1215, 1232-1233, 313->315, 427->429, 432->433, 439->443, 459->461, 493->495, 497->498, 504->506, 509->514, 566->569, 597->603, 687->exit, 702->exit, 710->exit, 717->718, 727->732, 759->exit, 791->792, 795->796, 869->872, 1039->1043, 1047->1050, 1059->1060, 1066->1069, 1092->1093, 1213->1214 -src/allmydata/node.py 388 84 146 34 75% 120, 132, 190, 241, 243-245, 278, 284, 294-295, 303-306, 315, 320, 339, 341, 361, 393-396, 422, 449, 453, 490, 493, 500, 511-512, 548, 566, 574, 581, 583, 590-591, 601, 612, 629-633, 679, 681, 738-741, 747, 756, 764, 792-805, 808-809, 814-815, 825-846, 189->190, 240->241, 242->243, 277->278, 314->315, 319->320, 338->339, 340->341, 360->361, 391->393, 421->422, 448->449, 451->453, 489->490, 492->493, 499->500, 510->511, 537->535, 547->548, 565->566, 573->574, 580->581, 582->583, 589->590, 600->601, 611->612, 622->629, 673->679, 680->681, 737->738, 746->747, 763->764, 821->830, 823->821 +src/allmydata/node.py 388 84 146 33 75% 120, 132, 190, 241, 243-245, 278, 284, 294-295, 303-306, 315, 320, 339, 341, 361, 393-396, 422, 449, 453, 490, 493, 500, 511-512, 548, 566, 574, 581, 583, 590-591, 601, 612, 629-633, 679, 681, 738-741, 747, 756, 764, 792-805, 808-809, 814-815, 825-846, 189->190, 240->241, 242->243, 277->278, 314->315, 319->320, 338->339, 340->341, 360->361, 391->393, 421->422, 448->449, 451->453, 489->490, 492->493, 499->500, 510->511, 547->548, 565->566, 573->574, 580->581, 582->583, 589->590, 600->601, 611->612, 622->629, 673->679, 680->681, 737->738, 746->747, 763->764, 821->830, 823->821 src/allmydata/nodemaker.py 97 23 38 10 70% 49, 61, 66, 70, 81, 94, 107-115, 130-138, 141-150, 57->61, 65->66, 69->70, 79->81, 86->95, 90->94, 104->107, 124->exit, 129->130, 129->133 src/allmydata/scripts/admin.py 51 20 2 1 60% 9-14, 25, 28, 31-37, 40-46, 57, 59, 61-66, 56->57 src/allmydata/scripts/backupdb.py 146 91 14 1 36% 84-91, 94-96, 99, 103, 106, 111-114, 117-119, 122, 125, 128, 176-221, 231-242, 245-263, 266-272, 308-324, 327-333, 336-341, 306->308 @@ -8843,7 +8837,7 @@ src/allmydata/storage/common.py 24 1 4 2 89% 11, 10->11, 36->39 src/allmydata/storage/crawler.py 222 1 64 3 99% 16, 13->16, 96->99, 496->505 src/allmydata/storage/expirer.py 240 1 81 2 99% 9, 7->9, 250->exit -src/allmydata/storage/immutable.py 198 1 48 5 98% 12, 11->12, 142->140, 155->160, 187->197, 273->exit +src/allmydata/storage/immutable.py 198 2 48 6 97% 12, 101, 11->12, 100->101, 142->140, 155->160, 187->197, 273->exit src/allmydata/storage/lease.py 35 1 4 1 95% 12, 11->12 src/allmydata/storage/mutable.py 289 8 90 6 96% 12, 162, 252, 289, 362-367, 11->12, 160->162, 247->252, 307->311, 354->362, 448->exit src/allmydata/storage/server.py 371 9 120 9 96% 13, 92, 222, 243, 329, 349, 375, 422-423, 10->13, 91->92, 221->222, 241->243, 289->300, 317->329, 325->305, 346->349, 374->375 @@ -8905,7 +8899,7 @@ src/allmydata/windows/fixups.py 133 133 54 0 0% 1-237 src/allmydata/windows/registry.py 42 42 12 0 0% 1-77 ------------------------------------------------------------------------------------------------ -TOTAL 27477 11786 8244 602 54% +TOTAL 27477 11800 8244 605 54% 18 files skipped due to complete coverage. + '[' '!' -z 1 ']' ``` Trac: refs #3455
2020-10-01 15:40:17 +00:00
f.write("[node]\n")
2018-03-05 04:45:07 +00:00
f.write("tub.port = tcp:0\n")
f.write("tub.location = AUTO\n")
config = client.read_config(basedir, "client.port")
i2p_provider = mock.Mock()
tor_provider = mock.Mock()
dfh, fch = create_connection_handlers(None, config, i2p_provider, tor_provider)
tub_options = create_tub_options(config)
t = FakeTub()
with mock.patch("allmydata.node.Tub", return_value=t):
with self.assertRaises(ValueError) as ctx:
create_main_tub(config, tub_options, dfh, fch, i2p_provider, tor_provider)
self.assertIn(
"you must choose",
str(ctx.exception),
)
def test_multiple_ports(self):
2018-02-27 22:00:31 +00:00
basedir = self.mktemp()
create_node_dir(basedir, "testing")
port1 = iputil.allocate_tcp_port()
port2 = iputil.allocate_tcp_port()
port = ("tcp:%d:interface=127.0.0.1,tcp:%d:interface=127.0.0.1" %
(port1, port2))
location = "tcp:localhost:%d,tcp:localhost:%d" % (port1, port2)
2018-02-27 22:00:31 +00:00
with open(os.path.join(basedir, "tahoe.cfg"), "w") as f:
f.write(BASE_CONFIG)
fix(py3): Duplicate section name that py3 catches Python 3 raises an exception that Python 2 doesn't and as such exposes malformed cfg/ini contents used in the tests. The test output diff shows that this mostly converts test `DuplicateSectionError` errors to test errors with different exceptions which is reasonable for the type of fix this is. It does seem to reduce coverage which I'm guessing is because the malformed contents were triggering error handling code paths that aren't triggered now, but I haven't confirmed that. I would think that to cover those cases we should write tests that do that explicitly rather than accidentally. ```diff --- ../../.tox/make-test-py3-all-old.log 2020-10-04 15:13:09.670578482 -0700 +++ ../../.tox/make-test-py3-all-new.log 2020-10-04 15:16:34.054975263 -0700 @@ -1835,7 +1835,7 @@ raise self.failureException(msg) twisted.trial.unittest.FailTest: ['allmydata', 'allmydata.__main__', 'allm[5873 chars]try'] != set() : Some unported modules remain: Ported files: 96 / 292 -Ported lines: 27978 / 93480 +Ported lines: 27978 / 93482 allmydata.test.test_python3.Python3PortingEffortTests.test_finished_porting @@ -2166,11 +2166,11 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), -twisted.trial.unittest.FailTest: configparser.DuplicateSectionError raised instead of ValueError: +twisted.trial.unittest.FailTest: builtins.NameError raised instead of ValueError: Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks _inlineCallbacks(None, g, status) @@ -2178,12 +2178,12 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled_but_helper/tahoe.cfg' [line 10]: section 'node' already exists +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled_but_helper @@ -2194,11 +2194,11 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), -twisted.trial.unittest.FailTest: configparser.DuplicateSectionError raised instead of ValueError: +twisted.trial.unittest.FailTest: builtins.NameError raised instead of ValueError: Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks _inlineCallbacks(None, g, status) @@ -2206,12 +2206,12 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled_but_storage/tahoe.cfg' [line 10]: section 'node' already exists +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled_but_storage @@ -2222,7 +2222,7 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), @@ -2234,10 +2234,10 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) builtins.TypeError: startswith first arg must be str or a tuple of str, not bytes @@ -2250,7 +2250,7 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), @@ -2262,10 +2262,10 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/introducer/server.py", line 76, in create_introducer tor_provider, @@ -7432,23 +7432,17 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 655, in test_disabled + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 657, in test_disabled n = yield client.create_client(basedir) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 243, in create_client - config = read_config(basedir, u"client.port") - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 219, in read_config - _valid_config=_valid_config(), - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/node.py", line 187, in read_config - parser = configutil.get_config(config_fname) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/util/configutil.py", line 50, in get_config - config.readfp(f) - File "/usr/lib/python3.6/configparser.py", line 764, in readfp - self.read_file(fp, source=filename) - File "/usr/lib/python3.6/configparser.py", line 718, in read_file - self._read(f, source) - File "/usr/lib/python3.6/configparser.py", line 1067, in _read - lineno) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled/tahoe.cfg' [line 10]: section 'node' already exists + File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks + result = g.send(result) + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 285, in create_client_from_config + introducer_clients = create_introducer_clients(config, main_tub, _introducer_factory) + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 519, in create_introducer_clients + introducer_cache_filepath, + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/introducer/client.py", line 29, in __init__ + assert type(nickname) is unicode +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled =============================================================================== @@ -7456,7 +7450,7 @@ Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 577, in test_listen_on_zero t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -7466,9 +7460,9 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 605, in test_multiple_ports + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 606, in test_multiple_ports t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -7478,9 +7472,9 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 624, in test_tor_i2p_listeners + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 626, in test_tor_i2p_listeners t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -8781,11 +8775,11 @@ src/allmydata/immutable/downloader/__init__.py 7 1 2 1 78% 12, 11->12 src/allmydata/immutable/downloader/common.py 14 1 2 1 88% 12, 11->12 src/allmydata/immutable/downloader/fetcher.py 147 1 56 1 99% 12, 11->12 -src/allmydata/immutable/downloader/finder.py 143 9 40 5 92% 11, 88-89, 108, 115, 170-173, 10->11, 87->88, 107->108, 113->115, 165->exit +src/allmydata/immutable/downloader/finder.py 143 11 40 5 91% 11, 88-89, 108, 115, 170-173, 231-232, 10->11, 87->88, 107->108, 113->115, 165->exit src/allmydata/immutable/downloader/node.py 282 9 66 9 94% 11, 170-172, 224-235, 271, 10->11, 43->exit, 60->68, 165->169, 169->170, 256->exit, 270->271, 517->exit, 537->exit src/allmydata/immutable/downloader/segmentation.py 118 1 22 1 99% 11, 10->11 -src/allmydata/immutable/downloader/share.py 453 15 154 8 96% 11, 210, 248-250, 354, 430-437, 518, 722-725, 862, 10->11, 209->210, 239->248, 352->354, 515->518, 660->663, 710->722, 762->exit -src/allmydata/immutable/downloader/status.py 154 9 36 1 95% 11, 223, 226, 230, 232, 234, 274, 285, 287, 10->11 +src/allmydata/immutable/downloader/share.py 453 23 154 11 94% 11, 210, 239-250, 289-290, 354, 399-400, 430-437, 518, 722-725, 775, 862, 10->11, 209->210, 222->239, 288->289, 352->354, 397->399, 515->518, 660->663, 710->722, 762->exit, 774->775 +src/allmydata/immutable/downloader/status.py 154 12 36 1 93% 11, 65-67, 223, 226, 230, 232, 234, 274, 285, 287, 10->11 src/allmydata/immutable/encode.py 421 13 124 10 95% 114, 197-200, 278-280, 405, 412, 462, 509, 562, 687, 102->104, 113->114, 195->197, 404->405, 411->412, 461->462, 499->509, 505->511, 561->562, 685->687 src/allmydata/immutable/filenode.py 196 48 30 5 72% 77-78, 83, 85, 88, 94-101, 104-124, 127-172, 254, 258, 315, 40->42, 224->227, 227->229, 251->254, 257->258 src/allmydata/immutable/happiness_upload.py 214 1 132 3 99% 15, 13->15, 213->211, 280->279 @@ -8808,7 +8802,7 @@ src/allmydata/mutable/repairer.py 57 37 18 0 29% 13, 15, 17, 19, 29-34, 65-71, 74-126, 129-131 src/allmydata/mutable/retrieve.py 489 123 120 33 71% 46, 48, 50, 52, 56, 58, 60, 62, 64, 89-90, 133, 186-193, 204-208, 211-212, 224-226, 231, 240, 251, 312, 318, 344-354, 377, 385-386, 399-400, 425-434, 490, 501, 515-516, 529-540, 564-578, 591-592, 629-630, 653-654, 674-675, 681-682, 698, 712-729, 758-760, 765, 772-774, 790-792, 871, 883, 909-910, 919-941, 965-966, 981-994, 999-1005, 129->133, 167->169, 169->171, 201->204, 223->224, 230->231, 237->239, 239->240, 243->247, 249->251, 309->312, 317->318, 376->377, 381->385, 391->394, 396->399, 424->425, 489->490, 499->501, 514->515, 590->591, 628->629, 652->653, 673->674, 677->687, 680->681, 687->694, 694->698, 755->764, 764->765, 868->871, 880->883, 964->965 src/allmydata/mutable/servermap.py 612 240 186 26 56% 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 74, 130-139, 142, 148, 159-161, 175, 177, 183, 186-199, 206, 213, 217-220, 231, 234-238, 243-252, 255-259, 315, 328-350, 358-363, 370-372, 379, 429, 433, 443-447, 495, 498, 506-508, 514-516, 569-570, 603-611, 623-638, 718-721, 732-741, 792, 796, 803-804, 850-851, 872-874, 911-915, 929-945, 961-975, 982-999, 1003-1013, 1043-1045, 1050-1052, 1060-1064, 1069-1070, 1093-1100, 1106-1186, 1214-1215, 1232-1233, 313->315, 427->429, 432->433, 439->443, 459->461, 493->495, 497->498, 504->506, 509->514, 566->569, 597->603, 687->exit, 702->exit, 710->exit, 717->718, 727->732, 759->exit, 791->792, 795->796, 869->872, 1039->1043, 1047->1050, 1059->1060, 1066->1069, 1092->1093, 1213->1214 -src/allmydata/node.py 388 84 146 34 75% 120, 132, 190, 241, 243-245, 278, 284, 294-295, 303-306, 315, 320, 339, 341, 361, 393-396, 422, 449, 453, 490, 493, 500, 511-512, 548, 566, 574, 581, 583, 590-591, 601, 612, 629-633, 679, 681, 738-741, 747, 756, 764, 792-805, 808-809, 814-815, 825-846, 189->190, 240->241, 242->243, 277->278, 314->315, 319->320, 338->339, 340->341, 360->361, 391->393, 421->422, 448->449, 451->453, 489->490, 492->493, 499->500, 510->511, 537->535, 547->548, 565->566, 573->574, 580->581, 582->583, 589->590, 600->601, 611->612, 622->629, 673->679, 680->681, 737->738, 746->747, 763->764, 821->830, 823->821 +src/allmydata/node.py 388 84 146 33 75% 120, 132, 190, 241, 243-245, 278, 284, 294-295, 303-306, 315, 320, 339, 341, 361, 393-396, 422, 449, 453, 490, 493, 500, 511-512, 548, 566, 574, 581, 583, 590-591, 601, 612, 629-633, 679, 681, 738-741, 747, 756, 764, 792-805, 808-809, 814-815, 825-846, 189->190, 240->241, 242->243, 277->278, 314->315, 319->320, 338->339, 340->341, 360->361, 391->393, 421->422, 448->449, 451->453, 489->490, 492->493, 499->500, 510->511, 547->548, 565->566, 573->574, 580->581, 582->583, 589->590, 600->601, 611->612, 622->629, 673->679, 680->681, 737->738, 746->747, 763->764, 821->830, 823->821 src/allmydata/nodemaker.py 97 23 38 10 70% 49, 61, 66, 70, 81, 94, 107-115, 130-138, 141-150, 57->61, 65->66, 69->70, 79->81, 86->95, 90->94, 104->107, 124->exit, 129->130, 129->133 src/allmydata/scripts/admin.py 51 20 2 1 60% 9-14, 25, 28, 31-37, 40-46, 57, 59, 61-66, 56->57 src/allmydata/scripts/backupdb.py 146 91 14 1 36% 84-91, 94-96, 99, 103, 106, 111-114, 117-119, 122, 125, 128, 176-221, 231-242, 245-263, 266-272, 308-324, 327-333, 336-341, 306->308 @@ -8843,7 +8837,7 @@ src/allmydata/storage/common.py 24 1 4 2 89% 11, 10->11, 36->39 src/allmydata/storage/crawler.py 222 1 64 3 99% 16, 13->16, 96->99, 496->505 src/allmydata/storage/expirer.py 240 1 81 2 99% 9, 7->9, 250->exit -src/allmydata/storage/immutable.py 198 1 48 5 98% 12, 11->12, 142->140, 155->160, 187->197, 273->exit +src/allmydata/storage/immutable.py 198 2 48 6 97% 12, 101, 11->12, 100->101, 142->140, 155->160, 187->197, 273->exit src/allmydata/storage/lease.py 35 1 4 1 95% 12, 11->12 src/allmydata/storage/mutable.py 289 8 90 6 96% 12, 162, 252, 289, 362-367, 11->12, 160->162, 247->252, 307->311, 354->362, 448->exit src/allmydata/storage/server.py 371 9 120 9 96% 13, 92, 222, 243, 329, 349, 375, 422-423, 10->13, 91->92, 221->222, 241->243, 289->300, 317->329, 325->305, 346->349, 374->375 @@ -8905,7 +8899,7 @@ src/allmydata/windows/fixups.py 133 133 54 0 0% 1-237 src/allmydata/windows/registry.py 42 42 12 0 0% 1-77 ------------------------------------------------------------------------------------------------ -TOTAL 27477 11786 8244 602 54% +TOTAL 27477 11800 8244 605 54% 18 files skipped due to complete coverage. + '[' '!' -z 1 ']' ``` Trac: refs #3455
2020-10-01 15:40:17 +00:00
f.write("[node]\n")
f.write("tub.port = %s\n" % port)
f.write("tub.location = %s\n" % location)
2018-02-27 22:00:31 +00:00
2018-03-04 21:29:17 +00:00
config = client.read_config(basedir, "client.port")
2018-01-28 08:27:25 +00:00
i2p_provider = mock.Mock()
tor_provider = mock.Mock()
2018-01-31 20:02:30 +00:00
dfh, fch = create_connection_handlers(None, config, i2p_provider, tor_provider)
2018-01-28 08:27:25 +00:00
tub_options = create_tub_options(config)
t = FakeTub()
2018-01-28 08:27:25 +00:00
with mock.patch("allmydata.node.Tub", return_value=t):
2018-01-31 20:02:30 +00:00
create_main_tub(config, tub_options, dfh, fch, i2p_provider, tor_provider)
self.assertEqual(t.listening_ports,
["tcp:%d:interface=127.0.0.1" % port1,
"tcp:%d:interface=127.0.0.1" % port2])
def test_tor_i2p_listeners(self):
2018-02-27 22:00:31 +00:00
basedir = self.mktemp()
config_fname = os.path.join(basedir, "tahoe.cfg")
os.mkdir(basedir)
os.mkdir(os.path.join(basedir, "private"))
with open(config_fname, "w") as f:
f.write(BASE_CONFIG)
fix(py3): Duplicate section name that py3 catches Python 3 raises an exception that Python 2 doesn't and as such exposes malformed cfg/ini contents used in the tests. The test output diff shows that this mostly converts test `DuplicateSectionError` errors to test errors with different exceptions which is reasonable for the type of fix this is. It does seem to reduce coverage which I'm guessing is because the malformed contents were triggering error handling code paths that aren't triggered now, but I haven't confirmed that. I would think that to cover those cases we should write tests that do that explicitly rather than accidentally. ```diff --- ../../.tox/make-test-py3-all-old.log 2020-10-04 15:13:09.670578482 -0700 +++ ../../.tox/make-test-py3-all-new.log 2020-10-04 15:16:34.054975263 -0700 @@ -1835,7 +1835,7 @@ raise self.failureException(msg) twisted.trial.unittest.FailTest: ['allmydata', 'allmydata.__main__', 'allm[5873 chars]try'] != set() : Some unported modules remain: Ported files: 96 / 292 -Ported lines: 27978 / 93480 +Ported lines: 27978 / 93482 allmydata.test.test_python3.Python3PortingEffortTests.test_finished_porting @@ -2166,11 +2166,11 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), -twisted.trial.unittest.FailTest: configparser.DuplicateSectionError raised instead of ValueError: +twisted.trial.unittest.FailTest: builtins.NameError raised instead of ValueError: Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks _inlineCallbacks(None, g, status) @@ -2178,12 +2178,12 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 685, in test_disabled_but_helper + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 687, in test_disabled_but_helper yield client.create_client(basedir) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled_but_helper/tahoe.cfg' [line 10]: section 'node' already exists +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled_but_helper @@ -2194,11 +2194,11 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), -twisted.trial.unittest.FailTest: configparser.DuplicateSectionError raised instead of ValueError: +twisted.trial.unittest.FailTest: builtins.NameError raised instead of ValueError: Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks _inlineCallbacks(None, g, status) @@ -2206,12 +2206,12 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 668, in test_disabled_but_storage + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 670, in test_disabled_but_storage yield client.create_client(basedir) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled_but_storage/tahoe.cfg' [line 10]: section 'node' already exists +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled_but_storage @@ -2222,7 +2222,7 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), @@ -2234,10 +2234,10 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 739, in test_create_client_invalid_config + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 741, in test_create_client_invalid_config yield client.create_client(self.basedir) builtins.TypeError: startswith first arg must be str or a tuple of str, not bytes @@ -2250,7 +2250,7 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/trial/_synctest.py", line 355, in __exit__ self._expectedName, reason.getTraceback()), @@ -2262,10 +2262,10 @@ result = result.throwExceptionIntoGenerator(g) File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) --- <exception caught here> --- - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 702, in test_port_none_introducer + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 704, in test_port_none_introducer yield create_introducer(basedir) File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/introducer/server.py", line 76, in create_introducer tor_provider, @@ -7432,23 +7432,17 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 655, in test_disabled + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 657, in test_disabled n = yield client.create_client(basedir) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 243, in create_client - config = read_config(basedir, u"client.port") - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 219, in read_config - _valid_config=_valid_config(), - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/node.py", line 187, in read_config - parser = configutil.get_config(config_fname) - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/util/configutil.py", line 50, in get_config - config.readfp(f) - File "/usr/lib/python3.6/configparser.py", line 764, in readfp - self.read_file(fp, source=filename) - File "/usr/lib/python3.6/configparser.py", line 718, in read_file - self._read(f, source) - File "/usr/lib/python3.6/configparser.py", line 1067, in _read - lineno) -configparser.DuplicateSectionError: While reading from '/home/rpatterson/src/work/sfu/tahoe-lafs/_trial_temp/test_node/test_disabled/tahoe.cfg' [line 10]: section 'node' already exists + File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py36-coverage/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks + result = g.send(result) + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 285, in create_client_from_config + introducer_clients = create_introducer_clients(config, main_tub, _introducer_factory) + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/client.py", line 519, in create_introducer_clients + introducer_cache_filepath, + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/introducer/client.py", line 29, in __init__ + assert type(nickname) is unicode +builtins.NameError: name 'unicode' is not defined allmydata.test.test_node.ClientNotListening.test_disabled =============================================================================== @@ -7456,7 +7450,7 @@ Traceback (most recent call last): File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 577, in test_listen_on_zero t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -7466,9 +7460,9 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 605, in test_multiple_ports + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 606, in test_multiple_ports t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -7478,9 +7472,9 @@ =============================================================================== [ERROR] Traceback (most recent call last): - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 624, in test_tor_i2p_listeners + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 626, in test_tor_i2p_listeners t = FakeTub() - File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 549, in __init__ + File "/home/rpatterson/src/work/sfu/tahoe-lafs/src/allmydata/test/test_node.py", line 548, in __init__ self.tubID = base64.b32encode("foo") File "/usr/lib/python3.6/base64.py", line 154, in b32encode s = memoryview(s).tobytes() @@ -8781,11 +8775,11 @@ src/allmydata/immutable/downloader/__init__.py 7 1 2 1 78% 12, 11->12 src/allmydata/immutable/downloader/common.py 14 1 2 1 88% 12, 11->12 src/allmydata/immutable/downloader/fetcher.py 147 1 56 1 99% 12, 11->12 -src/allmydata/immutable/downloader/finder.py 143 9 40 5 92% 11, 88-89, 108, 115, 170-173, 10->11, 87->88, 107->108, 113->115, 165->exit +src/allmydata/immutable/downloader/finder.py 143 11 40 5 91% 11, 88-89, 108, 115, 170-173, 231-232, 10->11, 87->88, 107->108, 113->115, 165->exit src/allmydata/immutable/downloader/node.py 282 9 66 9 94% 11, 170-172, 224-235, 271, 10->11, 43->exit, 60->68, 165->169, 169->170, 256->exit, 270->271, 517->exit, 537->exit src/allmydata/immutable/downloader/segmentation.py 118 1 22 1 99% 11, 10->11 -src/allmydata/immutable/downloader/share.py 453 15 154 8 96% 11, 210, 248-250, 354, 430-437, 518, 722-725, 862, 10->11, 209->210, 239->248, 352->354, 515->518, 660->663, 710->722, 762->exit -src/allmydata/immutable/downloader/status.py 154 9 36 1 95% 11, 223, 226, 230, 232, 234, 274, 285, 287, 10->11 +src/allmydata/immutable/downloader/share.py 453 23 154 11 94% 11, 210, 239-250, 289-290, 354, 399-400, 430-437, 518, 722-725, 775, 862, 10->11, 209->210, 222->239, 288->289, 352->354, 397->399, 515->518, 660->663, 710->722, 762->exit, 774->775 +src/allmydata/immutable/downloader/status.py 154 12 36 1 93% 11, 65-67, 223, 226, 230, 232, 234, 274, 285, 287, 10->11 src/allmydata/immutable/encode.py 421 13 124 10 95% 114, 197-200, 278-280, 405, 412, 462, 509, 562, 687, 102->104, 113->114, 195->197, 404->405, 411->412, 461->462, 499->509, 505->511, 561->562, 685->687 src/allmydata/immutable/filenode.py 196 48 30 5 72% 77-78, 83, 85, 88, 94-101, 104-124, 127-172, 254, 258, 315, 40->42, 224->227, 227->229, 251->254, 257->258 src/allmydata/immutable/happiness_upload.py 214 1 132 3 99% 15, 13->15, 213->211, 280->279 @@ -8808,7 +8802,7 @@ src/allmydata/mutable/repairer.py 57 37 18 0 29% 13, 15, 17, 19, 29-34, 65-71, 74-126, 129-131 src/allmydata/mutable/retrieve.py 489 123 120 33 71% 46, 48, 50, 52, 56, 58, 60, 62, 64, 89-90, 133, 186-193, 204-208, 211-212, 224-226, 231, 240, 251, 312, 318, 344-354, 377, 385-386, 399-400, 425-434, 490, 501, 515-516, 529-540, 564-578, 591-592, 629-630, 653-654, 674-675, 681-682, 698, 712-729, 758-760, 765, 772-774, 790-792, 871, 883, 909-910, 919-941, 965-966, 981-994, 999-1005, 129->133, 167->169, 169->171, 201->204, 223->224, 230->231, 237->239, 239->240, 243->247, 249->251, 309->312, 317->318, 376->377, 381->385, 391->394, 396->399, 424->425, 489->490, 499->501, 514->515, 590->591, 628->629, 652->653, 673->674, 677->687, 680->681, 687->694, 694->698, 755->764, 764->765, 868->871, 880->883, 964->965 src/allmydata/mutable/servermap.py 612 240 186 26 56% 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 74, 130-139, 142, 148, 159-161, 175, 177, 183, 186-199, 206, 213, 217-220, 231, 234-238, 243-252, 255-259, 315, 328-350, 358-363, 370-372, 379, 429, 433, 443-447, 495, 498, 506-508, 514-516, 569-570, 603-611, 623-638, 718-721, 732-741, 792, 796, 803-804, 850-851, 872-874, 911-915, 929-945, 961-975, 982-999, 1003-1013, 1043-1045, 1050-1052, 1060-1064, 1069-1070, 1093-1100, 1106-1186, 1214-1215, 1232-1233, 313->315, 427->429, 432->433, 439->443, 459->461, 493->495, 497->498, 504->506, 509->514, 566->569, 597->603, 687->exit, 702->exit, 710->exit, 717->718, 727->732, 759->exit, 791->792, 795->796, 869->872, 1039->1043, 1047->1050, 1059->1060, 1066->1069, 1092->1093, 1213->1214 -src/allmydata/node.py 388 84 146 34 75% 120, 132, 190, 241, 243-245, 278, 284, 294-295, 303-306, 315, 320, 339, 341, 361, 393-396, 422, 449, 453, 490, 493, 500, 511-512, 548, 566, 574, 581, 583, 590-591, 601, 612, 629-633, 679, 681, 738-741, 747, 756, 764, 792-805, 808-809, 814-815, 825-846, 189->190, 240->241, 242->243, 277->278, 314->315, 319->320, 338->339, 340->341, 360->361, 391->393, 421->422, 448->449, 451->453, 489->490, 492->493, 499->500, 510->511, 537->535, 547->548, 565->566, 573->574, 580->581, 582->583, 589->590, 600->601, 611->612, 622->629, 673->679, 680->681, 737->738, 746->747, 763->764, 821->830, 823->821 +src/allmydata/node.py 388 84 146 33 75% 120, 132, 190, 241, 243-245, 278, 284, 294-295, 303-306, 315, 320, 339, 341, 361, 393-396, 422, 449, 453, 490, 493, 500, 511-512, 548, 566, 574, 581, 583, 590-591, 601, 612, 629-633, 679, 681, 738-741, 747, 756, 764, 792-805, 808-809, 814-815, 825-846, 189->190, 240->241, 242->243, 277->278, 314->315, 319->320, 338->339, 340->341, 360->361, 391->393, 421->422, 448->449, 451->453, 489->490, 492->493, 499->500, 510->511, 547->548, 565->566, 573->574, 580->581, 582->583, 589->590, 600->601, 611->612, 622->629, 673->679, 680->681, 737->738, 746->747, 763->764, 821->830, 823->821 src/allmydata/nodemaker.py 97 23 38 10 70% 49, 61, 66, 70, 81, 94, 107-115, 130-138, 141-150, 57->61, 65->66, 69->70, 79->81, 86->95, 90->94, 104->107, 124->exit, 129->130, 129->133 src/allmydata/scripts/admin.py 51 20 2 1 60% 9-14, 25, 28, 31-37, 40-46, 57, 59, 61-66, 56->57 src/allmydata/scripts/backupdb.py 146 91 14 1 36% 84-91, 94-96, 99, 103, 106, 111-114, 117-119, 122, 125, 128, 176-221, 231-242, 245-263, 266-272, 308-324, 327-333, 336-341, 306->308 @@ -8843,7 +8837,7 @@ src/allmydata/storage/common.py 24 1 4 2 89% 11, 10->11, 36->39 src/allmydata/storage/crawler.py 222 1 64 3 99% 16, 13->16, 96->99, 496->505 src/allmydata/storage/expirer.py 240 1 81 2 99% 9, 7->9, 250->exit -src/allmydata/storage/immutable.py 198 1 48 5 98% 12, 11->12, 142->140, 155->160, 187->197, 273->exit +src/allmydata/storage/immutable.py 198 2 48 6 97% 12, 101, 11->12, 100->101, 142->140, 155->160, 187->197, 273->exit src/allmydata/storage/lease.py 35 1 4 1 95% 12, 11->12 src/allmydata/storage/mutable.py 289 8 90 6 96% 12, 162, 252, 289, 362-367, 11->12, 160->162, 247->252, 307->311, 354->362, 448->exit src/allmydata/storage/server.py 371 9 120 9 96% 13, 92, 222, 243, 329, 349, 375, 422-423, 10->13, 91->92, 221->222, 241->243, 289->300, 317->329, 325->305, 346->349, 374->375 @@ -8905,7 +8899,7 @@ src/allmydata/windows/fixups.py 133 133 54 0 0% 1-237 src/allmydata/windows/registry.py 42 42 12 0 0% 1-77 ------------------------------------------------------------------------------------------------ -TOTAL 27477 11786 8244 602 54% +TOTAL 27477 11800 8244 605 54% 18 files skipped due to complete coverage. + '[' '!' -z 1 ']' ``` Trac: refs #3455
2020-10-01 15:40:17 +00:00
f.write("[node]\n")
f.write("tub.port = listen:i2p,listen:tor\n")
f.write("tub.location = tcp:example.org:1234\n")
2018-03-04 21:29:17 +00:00
config = client.read_config(basedir, "client.port")
2018-01-28 08:27:25 +00:00
tub_options = create_tub_options(config)
t = FakeTub()
2018-03-04 21:29:17 +00:00
i2p_provider = mock.Mock()
tor_provider = mock.Mock()
2018-01-31 20:02:30 +00:00
dfh, fch = create_connection_handlers(None, config, i2p_provider, tor_provider)
2018-01-28 08:27:25 +00:00
with mock.patch("allmydata.node.Tub", return_value=t):
2018-01-31 20:02:30 +00:00
create_main_tub(config, tub_options, dfh, fch, i2p_provider, tor_provider)
2018-01-28 08:27:25 +00:00
self.assertEqual(i2p_provider.get_listener.mock_calls, [mock.call()])
self.assertEqual(tor_provider.get_listener.mock_calls, [mock.call()])
2018-09-07 03:21:02 +00:00
self.assertEqual(
t.listening_ports,
[
i2p_provider.get_listener(),
tor_provider.get_listener(),
]
)
2018-01-28 08:27:25 +00:00
class ClientNotListening(unittest.TestCase):
2018-01-28 08:27:25 +00:00
@defer.inlineCallbacks
def test_disabled(self):
basedir = "test_node/test_disabled"
2018-02-27 22:00:31 +00:00
create_node_dir(basedir, "testing")
f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt')
f.write(BASE_CONFIG)
f.write(NOLISTEN)
f.write(DISABLE_STORAGE)
f.close()
2018-01-28 08:27:25 +00:00
n = yield client.create_client(basedir)
self.assertEqual(n.tub.getListeners(), [])
@defer.inlineCallbacks
def test_disabled_but_storage(self):
basedir = "test_node/test_disabled_but_storage"
2018-02-27 22:00:31 +00:00
create_node_dir(basedir, "testing")
f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt')
f.write(BASE_CONFIG)
f.write(NOLISTEN)
f.write(ENABLE_STORAGE)
f.close()
with self.assertRaises(ValueError) as ctx:
yield client.create_client(basedir)
self.assertIn(
"storage is enabled, but tub is not listening",
str(ctx.exception),
)
@defer.inlineCallbacks
def test_disabled_but_helper(self):
basedir = "test_node/test_disabled_but_helper"
2018-02-27 22:00:31 +00:00
create_node_dir(basedir, "testing")
f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt')
f.write(BASE_CONFIG)
f.write(NOLISTEN)
f.write(DISABLE_STORAGE)
f.write(ENABLE_HELPER)
f.close()
with self.assertRaises(ValueError) as ctx:
yield client.create_client(basedir)
self.assertIn(
"helper is enabled, but tub is not listening",
str(ctx.exception),
)
class IntroducerNotListening(unittest.TestCase):
@defer.inlineCallbacks
def test_port_none_introducer(self):
basedir = "test_node/test_port_none_introducer"
2018-02-27 22:00:31 +00:00
create_node_dir(basedir, "testing")
with open(os.path.join(basedir, 'tahoe.cfg'), 'wt') as f:
f.write("[node]\n")
f.write("tub.port = disabled\n")
f.write("tub.location = disabled\n")
with self.assertRaises(ValueError) as ctx:
yield create_introducer(basedir)
self.assertIn(
"we are Introducer, but tub is not listening",
str(ctx.exception),
)
2018-05-29 23:11:28 +00:00
class Configuration(unittest.TestCase):
def setUp(self):
self.basedir = self.mktemp()
fileutil.make_dirs(self.basedir)
def test_read_invalid_config(self):
with open(os.path.join(self.basedir, 'tahoe.cfg'), 'w') as f:
f.write(
'[invalid section]\n'
'foo = bar\n'
)
with self.assertRaises(UnknownConfigError) as ctx:
read_config(
self.basedir,
"client.port",
)
self.assertIn(
"invalid section",
str(ctx.exception),
)
@defer.inlineCallbacks
2018-05-29 23:11:28 +00:00
def test_create_client_invalid_config(self):
with open(os.path.join(self.basedir, 'tahoe.cfg'), 'w') as f:
f.write(
'[invalid section]\n'
'foo = bar\n'
)
with self.assertRaises(UnknownConfigError) as ctx:
yield client.create_client(self.basedir)
2018-05-29 23:11:28 +00:00
self.assertIn(
"invalid section",
str(ctx.exception),
)