From b0b67826e8c9a026879c68c04c13d2cce9a6466e Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 13 May 2022 12:58:55 -0400 Subject: [PATCH 1/6] More verbose output is helpful when debugging. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 859cf18e0..fc95a0469 100644 --- a/tox.ini +++ b/tox.ini @@ -97,7 +97,7 @@ setenv = COVERAGE_PROCESS_START=.coveragerc commands = # NOTE: 'run with "py.test --keep-tempdir -s -v integration/" to debug failures' - py.test --timeout=1800 --coverage -v {posargs:integration} + py.test --timeout=1800 --coverage -s -v {posargs:integration} coverage combine coverage report From 20b021809c0a2cf3bd2abf5991de5638b48134b9 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 13 May 2022 12:59:04 -0400 Subject: [PATCH 2/6] Fix(?) the intermittently failing test. --- integration/test_tor.py | 6 +++++- newsfragments/3895.minor | 0 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 newsfragments/3895.minor diff --git a/integration/test_tor.py b/integration/test_tor.py index b0419f0d2..5b701287c 100644 --- a/integration/test_tor.py +++ b/integration/test_tor.py @@ -21,7 +21,8 @@ from . import util from twisted.python.filepath import ( FilePath, ) - +from twisted.internet.task import deferLater +from twisted.internet import reactor from allmydata.test.common import ( write_introducer, ) @@ -68,6 +69,9 @@ def test_onion_service_storage(reactor, request, temp_dir, flog_gatherer, tor_ne cap = proto.output.getvalue().strip().split()[-1] print("TEH CAP!", cap) + # For some reason a wait is needed, or sometimes the get fails... + yield deferLater(reactor, 2, lambda: None) + proto = util._CollectOutputProtocol(capture_stderr=False) reactor.spawnProcess( proto, diff --git a/newsfragments/3895.minor b/newsfragments/3895.minor new file mode 100644 index 000000000..e69de29bb From 757b4492d75c899d21809ff51f3383189c7eb3c7 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 13 May 2022 13:29:08 -0400 Subject: [PATCH 3/6] A more semantically correct fix. --- integration/test_tor.py | 16 ++++++++-------- integration/util.py | 9 +++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/integration/test_tor.py b/integration/test_tor.py index 5b701287c..d17e0f5cf 100644 --- a/integration/test_tor.py +++ b/integration/test_tor.py @@ -21,8 +21,7 @@ from . import util from twisted.python.filepath import ( FilePath, ) -from twisted.internet.task import deferLater -from twisted.internet import reactor + from allmydata.test.common import ( write_introducer, ) @@ -41,8 +40,11 @@ if PY2: @pytest_twisted.inlineCallbacks def test_onion_service_storage(reactor, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl): - yield _create_anonymous_node(reactor, 'carol', 8008, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl) - yield _create_anonymous_node(reactor, 'dave', 8009, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl) + carol = yield _create_anonymous_node(reactor, 'carol', 8008, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl) + dave = yield _create_anonymous_node(reactor, 'dave', 8009, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl) + util.await_client_ready(carol, expected_number_of_servers=2) + util.await_client_ready(dave, expected_number_of_servers=2) + # ensure both nodes are connected to "a grid" by uploading # something via carol, and retrieve it using dave. gold_path = join(temp_dir, "gold") @@ -69,9 +71,6 @@ def test_onion_service_storage(reactor, request, temp_dir, flog_gatherer, tor_ne cap = proto.output.getvalue().strip().split()[-1] print("TEH CAP!", cap) - # For some reason a wait is needed, or sometimes the get fails... - yield deferLater(reactor, 2, lambda: None) - proto = util._CollectOutputProtocol(capture_stderr=False) reactor.spawnProcess( proto, @@ -147,5 +146,6 @@ shares.total = 2 f.write(node_config) print("running") - yield util._run_node(reactor, node_dir.path, request, None) + result = yield util._run_node(reactor, node_dir.path, request, None) print("okay, launched") + return result diff --git a/integration/util.py b/integration/util.py index 7c7a1efd2..0ec824f82 100644 --- a/integration/util.py +++ b/integration/util.py @@ -482,14 +482,15 @@ def web_post(tahoe, uri_fragment, **kwargs): return resp.content -def await_client_ready(tahoe, timeout=10, liveness=60*2): +def await_client_ready(tahoe, timeout=10, liveness=60*2, expected_number_of_servers=1): """ Uses the status API to wait for a client-type node (in `tahoe`, a `TahoeProcess` instance usually from a fixture e.g. `alice`) to be 'ready'. A client is deemed ready if: - it answers `http:///statistics/?t=json/` - - there is at least one storage-server connected + - there is at least one storage-server connected (configurable via + ``expected_number_of_servers``) - every storage-server has a "last_received_data" and it is within the last `liveness` seconds @@ -506,8 +507,8 @@ def await_client_ready(tahoe, timeout=10, liveness=60*2): time.sleep(1) continue - if len(js['servers']) == 0: - print("waiting because no servers at all") + if len(js['servers']) != expected_number_of_servers: + print("waiting because insufficient servers") time.sleep(1) continue server_times = [ From f752f547ba50e283a13abac8b9764cef305ad2a0 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 13 May 2022 13:30:47 -0400 Subject: [PATCH 4/6] More servers is fine. --- integration/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integration/util.py b/integration/util.py index 0ec824f82..ad9249e45 100644 --- a/integration/util.py +++ b/integration/util.py @@ -482,7 +482,7 @@ def web_post(tahoe, uri_fragment, **kwargs): return resp.content -def await_client_ready(tahoe, timeout=10, liveness=60*2, expected_number_of_servers=1): +def await_client_ready(tahoe, timeout=10, liveness=60*2, minimum_number_of_servers=1): """ Uses the status API to wait for a client-type node (in `tahoe`, a `TahoeProcess` instance usually from a fixture e.g. `alice`) to be @@ -490,7 +490,7 @@ def await_client_ready(tahoe, timeout=10, liveness=60*2, expected_number_of_serv - it answers `http:///statistics/?t=json/` - there is at least one storage-server connected (configurable via - ``expected_number_of_servers``) + ``minimum_number_of_servers``) - every storage-server has a "last_received_data" and it is within the last `liveness` seconds @@ -507,7 +507,7 @@ def await_client_ready(tahoe, timeout=10, liveness=60*2, expected_number_of_serv time.sleep(1) continue - if len(js['servers']) != expected_number_of_servers: + if len(js['servers']) < minimum_number_of_servers: print("waiting because insufficient servers") time.sleep(1) continue From 69f1244c5a85914535008911b231b1483fdee953 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 13 May 2022 13:42:10 -0400 Subject: [PATCH 5/6] Fix keyword argument name. --- integration/test_tor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/test_tor.py b/integration/test_tor.py index d17e0f5cf..c78fa8098 100644 --- a/integration/test_tor.py +++ b/integration/test_tor.py @@ -42,8 +42,8 @@ if PY2: def test_onion_service_storage(reactor, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl): carol = yield _create_anonymous_node(reactor, 'carol', 8008, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl) dave = yield _create_anonymous_node(reactor, 'dave', 8009, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl) - util.await_client_ready(carol, expected_number_of_servers=2) - util.await_client_ready(dave, expected_number_of_servers=2) + util.await_client_ready(carol, minimum_number_of_servers=2) + util.await_client_ready(dave, minimum_number_of_servers=2) # ensure both nodes are connected to "a grid" by uploading # something via carol, and retrieve it using dave. From 3abf992321c62728cf194090380dc46c32dc0156 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 13 May 2022 14:05:53 -0400 Subject: [PATCH 6/6] Autobahn regression workaround. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c84d0ecde..2b4fd6988 100644 --- a/setup.py +++ b/setup.py @@ -114,7 +114,7 @@ install_requires = [ "attrs >= 18.2.0", # WebSocket library for twisted and asyncio - "autobahn >= 19.5.2", + "autobahn < 22.4.1", # remove this when https://github.com/crossbario/autobahn-python/issues/1566 is fixed # Support for Python 3 transition "future >= 0.18.2",