From 6d15b4a0d0e862363e25b65c89ecea9c06f6a576 Mon Sep 17 00:00:00 2001 From: Gracjan Sadowicz Date: Thu, 26 Nov 2026 14:45:17 +0100 Subject: [PATCH] Let the OS pick the test servers' TCP ports The test servers listened for TCP on fixed ports 38881 and 38882. Both sit in Linux's ephemeral port range, so an outgoing connection can already hold one of them when a server starts. The secured server was given "localhost", which it binds on every address it resolves to while keeping the ones it could bind. With 127.0.0.1:38882 taken it listened on ::1 only, the IPv4 client got connection refused on every retry, and the secured subscription tests timed out. Both servers now use port 0 and report the port they got to clients, the same way RavenDB's own test servers run. The secured one binds 127.0.0.1 only, so it cannot end up reachable over IPv6 alone. --- ravendb/tests/test_base.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ravendb/tests/test_base.py b/ravendb/tests/test_base.py index 0496cedf..966f708a 100644 --- a/ravendb/tests/test_base.py +++ b/ravendb/tests/test_base.py @@ -168,9 +168,10 @@ def server_path(self) -> str: @property def command_arguments(self) -> List[str]: + # No ServerUrl.Tcp: the server then listens for TCP on a free port of the ServerUrl host and tells + # clients which one, so a fixed port can never be taken by another process or a parallel run. return [ "--ServerUrl=http://127.0.0.1:0", - "--ServerUrl.Tcp=tcp://127.0.0.1:38881", "--Features.Availability=Experimental", ] @@ -185,12 +186,13 @@ def get_server_path(self) -> str: @property def command_arguments(self) -> List[str]: - https_server_url = self.https_server_url - tcp_server_url = https_server_url.replace("https", "tcp", 1).rsplit(":", 1)[0] + ":38882" + # TCP gets a free port picked by the OS, which the server reports to clients. It is bound to a single + # IPv4 address on purpose: given a host name such as "localhost", the server binds every address + # the name resolves to and keeps those it could bind, so an IPv4 client might find nothing there. return [ f"--Security.Certificate.Path={self.server_certificate_path}", - f"--ServerUrl={https_server_url}", - f"--ServerUrl.Tcp={tcp_server_url}", + f"--ServerUrl={self.https_server_url}", + "--ServerUrl.Tcp=tcp://127.0.0.1:0", ] @property