From 1a6f05304f7cf4363cd05f0efa61c18076e6b8ce Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Fri, 5 Aug 2022 11:08:51 +0200 Subject: [PATCH] Fix connection acquisition timeout (#504) When the driver is performing routing, the connection acquisition for a connection to the router should also be affected by the connection acquisition timeout. However, it should have its own timeout because it's a separate acquisition. --- .../test_connection_acquisition_timeout_ms.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/stub/driver_parameters/test_connection_acquisition_timeout_ms.py b/tests/stub/driver_parameters/test_connection_acquisition_timeout_ms.py index af4b778e5..7e4a8ea86 100644 --- a/tests/stub/driver_parameters/test_connection_acquisition_timeout_ms.py +++ b/tests/stub/driver_parameters/test_connection_acquisition_timeout_ms.py @@ -178,15 +178,15 @@ def test_should_fail_when_connection_timeout_is_reached_first(self): with self.assertRaises(types.DriverError): list(self._session.run("RETURN 1 AS n")) - def test_does_not_encompass_router_handshake(self): + def test_router_handshake_has_own_timeout_in_time(self): self._start_server(self._router, "router_hello_delay.script") - self._start_server(self._server, "session_run.script") + self._start_server(self._server, "session_run_auth_delay.script") uri = "neo4j://%s" % self._router.address auth = types.AuthorizationToken("basic", principal="neo4j", credentials="pass") self._driver = Driver(self._backend, uri, auth, - connection_acquisition_timeout_ms=2000, + connection_acquisition_timeout_ms=6000, connection_timeout_ms=720000) self._session = self._driver.session("r") list(self._session.run("RETURN 1 AS n")) @@ -198,6 +198,20 @@ def test_does_not_encompass_router_handshake(self): self._router.done() self._server.done() + def test_router_handshake_has_own_timeout_too_slow(self): + self._start_server(self._router, "router_hello_delay.script") + self._start_server(self._server, "session_run.script") + + uri = "neo4j://%s" % self._router.address + auth = types.AuthorizationToken("basic", principal="neo4j", + credentials="pass") + self._driver = Driver(self._backend, uri, auth, + connection_acquisition_timeout_ms=2000, + connection_timeout_ms=720000) + self._session = self._driver.session("r") + with self.assertRaises(types.DriverError): + list(self._session.run("RETURN 1 AS n")) + def test_does_not_encompass_router_route_response(self): self._start_server(self._router, "router_route_delay.script") self._start_server(self._server, "session_run.script")