From 4e2c685a1296032a080fdb7f311ed2e32c3a011a Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Wed, 18 Jan 2023 13:28:24 -0500 Subject: [PATCH] Fix test_directory_deep_check by having it re-assert its preferred config Previously the changes test_vectors.py made to Alice's configuration invalidated test_directory_deep_check's assumptions. --- integration/test_web.py | 24 ++++++++++++------------ integration/util.py | 14 ++++++++------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/integration/test_web.py b/integration/test_web.py index 22f08da82..95a09a5f5 100644 --- a/integration/test_web.py +++ b/integration/test_web.py @@ -7,18 +7,9 @@ Most of the tests have cursory asserts and encode 'what the WebAPI did at the time of testing' -- not necessarily a cohesive idea of what the WebAPI *should* do in every situation. It's not clear the latter exists anywhere, however. - -Ported to Python 3. """ -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from future.utils import PY2 -if PY2: - from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 +from __future__ import annotations import time from urllib.parse import unquote as url_unquote, quote as url_quote @@ -32,6 +23,7 @@ import requests import html5lib from bs4 import BeautifulSoup +from pytest_twisted import ensureDeferred def test_index(alice): """ @@ -252,10 +244,18 @@ def test_status(alice): assert found_download, "Failed to find the file we downloaded in the status-page" -def test_directory_deep_check(alice): +@ensureDeferred +async def test_directory_deep_check(reactor, request, alice): """ use deep-check and confirm the result pages work """ + # Make sure the node is configured compatibly with expectations of this + # test. + happy = 3 + required = 2 + total = 4 + + await util.reconfigure(reactor, request, alice, (happy, required, total), convergence=None) # create a directory resp = requests.post( @@ -313,7 +313,7 @@ def test_directory_deep_check(alice): ) def check_repair_data(checkdata): - assert checkdata["healthy"] is True + assert checkdata["healthy"] assert checkdata["count-happiness"] == 4 assert checkdata["count-good-share-hosts"] == 4 assert checkdata["count-shares-good"] == 4 diff --git a/integration/util.py b/integration/util.py index a39fa26bc..25aebd931 100644 --- a/integration/util.py +++ b/integration/util.py @@ -766,7 +766,7 @@ def insert(item: tuple[α, β], d: dict[α, β]) -> dict[α, β]: return d -async def reconfigure(reactor, request, node: TahoeProcess, params: tuple[int, int, int], convergence: bytes) -> None: +async def reconfigure(reactor, request, node: TahoeProcess, params: tuple[int, int, int], convergence: None | bytes) -> None: """ Reconfigure a Tahoe-LAFS node with different ZFEC parameters and convergence secret. @@ -780,7 +780,8 @@ async def reconfigure(reactor, request, node: TahoeProcess, params: tuple[int, i :param node: The Tahoe-LAFS node to reconfigure. :param params: The ``happy``, ``needed``, and ``total`` ZFEC encoding parameters. - :param convergence: The convergence secret. + :param convergence: If given, the convergence secret. If not given, the + existing convergence secret will be left alone. :return: ``None`` after the node configuration has been rewritten, the node has been restarted, and the node is ready to provide service. @@ -799,10 +800,11 @@ async def reconfigure(reactor, request, node: TahoeProcess, params: tuple[int, i config.set_config("client", "shares.needed", str(needed)) config.set_config("client", "shares.total", str(total)) - cur_convergence = config.get_private_config("convergence").encode("ascii") - if base32.a2b(cur_convergence) != convergence: - changed = True - config.write_private_config("convergence", base32.b2a(convergence)) + if convergence is not None: + cur_convergence = config.get_private_config("convergence").encode("ascii") + if base32.a2b(cur_convergence) != convergence: + changed = True + config.write_private_config("convergence", base32.b2a(convergence)) if changed: # restart the node