Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection acquisition timeout #504

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you need to add delay to the session run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I want to make sure that the connection_acquisition_timeout_ms (6000ms) counts for each connection acquisition separately. So even though the total delay (4s during router handshake, 4s during reader handshake) exceeds the set timeout, it should still work because the individual delays are below the timeout.


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