Skip to content

Commit

Permalink
Fix connection acquisition timeout (#504)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
robsdedude authored Aug 5, 2022
1 parent 75da808 commit 1a6f053
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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")
Expand Down

0 comments on commit 1a6f053

Please sign in to comment.