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

Make more error codes fail fast during the rediscovery #536

Merged
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1,13 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007"#EXTR_HELLO_ROUTING_PROPS#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": #ROUTINGCTX#} {"[mode]": "r"}
S: FAILURE {"code": "Neo.ClientError.Statement.ArgumentError", "message": "Kaboooom."}
{?
C: PULL_ALL
S: IGNORED
?}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007"#EXTR_HELLO_ROUTING_PROPS#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": #ROUTINGCTX#} {"[mode]": "r"}
S: FAILURE {"code": "Neo.ClientError.Request.Invalid", "message": "Kaboooom."}
{?
C: PULL_ALL
S: IGNORED
?}
*: RESET
?: GOODBYE
13 changes: 13 additions & 0 deletions tests/stub/routing/scripts/v3/router_yielding_type_error.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007"#EXTR_HELLO_ROUTING_PROPS#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": #ROUTINGCTX#} {"[mode]": "r"}
S: FAILURE {"code": "Neo.ClientError.Statement.TypeError", "message": "Kaboooom."}
{?
C: PULL_ALL
S: IGNORED
?}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": #ROUTINGCTX#, "[database]": "*"} {"[mode]": "r", "db": "system", "bookmarks": ["foobar"]}
S: FAILURE {"code": "Neo.ClientError.Statement.ArgumentError", "message": "Kaboooom."}
{?
C: PULL {"n": {"Z": "*"}}
S: IGNORED
?}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": #ROUTINGCTX#, "[database]": "*"} {"[mode]": "r", "db": "system", "bookmarks": ["foobar"]}
S: FAILURE {"code": "Neo.ClientError.Request.Invalid", "message": "Kaboooom."}
{?
C: PULL {"n": {"Z": "*"}}
S: IGNORED
?}
*: RESET
?: GOODBYE
13 changes: 13 additions & 0 deletions tests/stub/routing/scripts/v4x1/router_yielding_type_error.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": #ROUTINGCTX#, "[database]": "*"} {"[mode]": "r", "db": "system", "bookmarks": ["foobar"]}
S: FAILURE {"code": "Neo.ClientError.Statement.TypeError", "message": "Kaboooom."}
{?
C: PULL {"n": {"Z": "*"}}
S: IGNORED
?}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX# , "[patch_bolt]": "*"}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] "*"
S: FAILURE {"code": "Neo.ClientError.Statement.ArgumentError", "message": "Kaboooom!"}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX# , "[patch_bolt]": "*"}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] "*"
S: FAILURE {"code": "Neo.ClientError.Request.Invalid", "message": "Kaboooom!"}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX# , "[patch_bolt]": "*"}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] "*"
S: FAILURE {"code": "Neo.ClientError.Statement.TypeError", "message": "Kaboooom!"}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#, "[patch_bolt]": "*"}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] {"[db]": "*"}
S: FAILURE {"code": "Neo.ClientError.Statement.ArgumentError", "message": "Kaboooom."}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#, "[patch_bolt]": "*"}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] {"[db]": "*"}
S: FAILURE {"code": "Neo.ClientError.Request.Invalid", "message": "Kaboooom."}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#, "[patch_bolt]": "*"}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] {"[db]": "*"}
S: FAILURE {"code": "Neo.ClientError.Statement.TypeError", "message": "Kaboooom."}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] {"[db]": "*"}
S: FAILURE {"code": "Neo.ClientError.Statement.ArgumentError", "message": "Kaboooom."}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] {"[db]": "*"}
S: FAILURE {"code": "Neo.ClientError.Request.Invalid", "message": "Kaboooom."}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!: BOLT #VERSION#

C: HELLO {"scheme": "basic", "credentials": "c", "principal": "p", "user_agent": "007", "routing": #ROUTINGCTX#}
S: SUCCESS {"server": "#SERVER_AGENT#", "connection_id": "bolt-123456789"}
*: RESET
C: ROUTE #ROUTINGCTX# ["foobar"] {"[db]": "*"}
S: FAILURE {"code": "Neo.ClientError.Statement.TypeError", "message": "Kaboooom."}
*: RESET
?: GOODBYE
30 changes: 30 additions & 0 deletions tests/stub/routing/test_routing_v5x0.py
Original file line number Diff line number Diff line change
Expand Up @@ -2306,6 +2306,36 @@ def test_should_fail_with_routing_failure_on_any_security_discovery_failure( #
exc.exception.code
)

def test_should_fail_with_invalid_route_statement_argument(self):
exc = self._test_fast_fail_discover(
"router_yielding_argument_error.script",
)

self.assertEqual(
"Neo.ClientError.Statement.ArgumentError",
exc.exception.code
)

def test_should_fail_with_invalid_routing_request(self):
exc = self._test_fast_fail_discover(
"router_yielding_invalid_request.script",
)

self.assertEqual(
"Neo.ClientError.Request.Invalid",
exc.exception.code
)

def test_should_fail_with_type_error_request(self):
exc = self._test_fast_fail_discover(
"router_yielding_type_error.script",
)

self.assertEqual(
"Neo.ClientError.Statement.TypeError",
exc.exception.code
)

def test_should_read_successfully_from_reachable_db_after_trying_unreachable_db( # noqa: E501
self
):
Expand Down