Merge pull request #1302 from tahoe-lafs/4028-more-integration

Fix another integration test failure

Fixes ticket:4028
This commit is contained in:
Itamar Turner-Trauring 2023-05-23 14:51:07 -04:00 committed by GitHub
commit 41131ca755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 5 deletions

View File

@ -401,9 +401,6 @@ def alice(
reactor, request, temp_dir, introducer_furl, flog_gatherer, "alice",
web_port="tcp:9980:interface=localhost",
storage=False,
# We're going to kill this ourselves, so no need for finalizer to
# do it:
finalize=False,
)
)
pytest_twisted.blockon(await_client_ready(process))

0
newsfragments/4028.minor Normal file
View File

View File

@ -332,6 +332,7 @@ class StorageClient(object):
_base_url: DecodedURL
_swissnum: bytes
_treq: Union[treq, StubTreq, HTTPClient]
_pool: Optional[HTTPConnectionPool]
_clock: IReactorTime
@classmethod
@ -361,7 +362,7 @@ class StorageClient(object):
)
https_url = DecodedURL().replace(scheme="https", host=nurl.host, port=nurl.port)
return cls(https_url, swissnum, treq_client, reactor)
return cls(https_url, swissnum, treq_client, pool, reactor)
def relative_url(self, path: str) -> DecodedURL:
"""Get a URL relative to the base URL."""
@ -501,6 +502,11 @@ class StorageClient(object):
).read()
raise ClientException(response.code, response.phrase, data)
def shutdown(self) -> Deferred:
"""Shutdown any connections."""
if self._pool is not None:
return self._pool.closeCachedConnections()
@define(hash=True)
class StorageClientGeneral(object):

View File

@ -1271,6 +1271,11 @@ class HTTPNativeStorageServer(service.MultiService):
if self._lc.running:
self._lc.stop()
self._failed_to_connect("shut down")
if self._istorage_server is not None:
client_shutting_down = self._istorage_server._http_client.shutdown()
result.addCallback(lambda _: client_shutting_down)
return result

View File

@ -331,6 +331,7 @@ class CustomHTTPServerTests(SyncTestCase):
DecodedURL.from_text("http://127.0.0.1"),
SWISSNUM_FOR_TEST,
treq=treq,
pool=None,
# We're using a Treq private API to get the reactor, alas, but only
# in a test, so not going to worry about it too much. This would be
# fixed if https://github.com/twisted/treq/issues/226 were ever
@ -512,6 +513,7 @@ class HttpTestFixture(Fixture):
DecodedURL.from_text("http://127.0.0.1"),
SWISSNUM_FOR_TEST,
treq=self.treq,
pool=None,
clock=self.clock,
)
@ -624,6 +626,7 @@ class GenericHTTPAPITests(SyncTestCase):
DecodedURL.from_text("http://127.0.0.1"),
b"something wrong",
treq=StubTreq(self.http.http_server.get_resource()),
pool=None,
clock=self.http.clock,
)
)
@ -1455,7 +1458,7 @@ class SharedImmutableMutableTestsMixin:
self.client.advise_corrupt_share(storage_index, 13, reason)
)
for (si, share_number) in [(storage_index, 11), (urandom(16), 13)]:
for si, share_number in [(storage_index, 11), (urandom(16), 13)]:
with assert_fails_with_http_code(self, http.NOT_FOUND):
self.http.result_of_with_flush(
self.client.advise_corrupt_share(si, share_number, reason)