Skip to content

Commit

Permalink
Merge pull request #1195 from tahoe-lafs/3895-tor-test-failing
Browse files Browse the repository at this point in the history
Fix integration test for Tor

Fixes ticket:3895
  • Loading branch information
itamarst committed May 16, 2022
2 parents be2c6b0 + 3abf992 commit 0cf0b1e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions integration/test_tor.py
Expand Up @@ -40,8 +40,11 @@

@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, 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.
gold_path = join(temp_dir, "gold")
Expand Down Expand Up @@ -143,5 +146,6 @@ def _create_anonymous_node(reactor, name, control_port, request, temp_dir, flog_
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
9 changes: 5 additions & 4 deletions integration/util.py
Expand Up @@ -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, 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
'ready'. A client is deemed ready if:
- it answers `http://<node_url>/statistics/?t=json/`
- there is at least one storage-server connected
- there is at least one storage-server connected (configurable via
``minimum_number_of_servers``)
- every storage-server has a "last_received_data" and it is
within the last `liveness` seconds
Expand All @@ -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']) < minimum_number_of_servers:
print("waiting because insufficient servers")
time.sleep(1)
continue
server_times = [
Expand Down
Empty file added newsfragments/3895.minor
Empty file.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -114,7 +114,7 @@ def read_version_py(infname):
"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",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -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

Expand Down

0 comments on commit 0cf0b1e

Please sign in to comment.