Skip to content

Commit 5b1c2eb

Browse files
Peter Wilhelmsson2hdddg
Peter Wilhelmsson
authored andcommitted
Send address to routing procedure on 4.0
1 parent 22c4c59 commit 5b1c2eb

8 files changed

+16
-19
lines changed

src/internal/routing-util.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,10 @@ export default class RoutingUtil {
148148
if (protocolVersion >= 4.0) {
149149
query = CALL_GET_ROUTING_TABLE_MULTI_DB
150150
params = {
151-
context: this._routingContext,
151+
context: this._routingContext || {},
152152
database: database || null
153153
}
154-
if (protocolVersion >= 4.1) {
155-
params.context = params.context || {}
156-
params.context.address = this._initialAddress
157-
}
154+
params.context.address = this._initialAddress
158155
} else {
159156
query = CALL_GET_ROUTING_TABLE
160157
params = { context: this._routingContext }

test/internal/node/routing.driver.boltkit.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,21 +2242,21 @@ describe('#stub-routing routing driver with stub server', () => {
22422242
// Given
22432243
const router1 = await boltStub.start(
22442244
'./test/resources/boltstub/v4/acquire_endpoints_aDatabase_no_servers.script',
2245-
9001
2245+
9002
22462246
)
22472247
const router2 = await boltStub.start(
22482248
'./test/resources/boltstub/v4/acquire_endpoints_aDatabase.script',
2249-
9002
2249+
9003
22502250
)
22512251
const reader1 = await boltStub.start(
22522252
'./test/resources/boltstub/v4/read_from_aDatabase.script',
22532253
9005
22542254
)
22552255

2256-
const driver = boltStub.newDriver('neo4j://127.0.0.1:9000', {
2256+
const driver = boltStub.newDriver('neo4j://127.0.0.1:9001', {
22572257
resolver: address => [
2258-
'neo4j://127.0.0.1:9001',
2259-
'neo4j://127.0.0.1:9002'
2258+
'neo4j://127.0.0.1:9002',
2259+
'neo4j://127.0.0.1:9003'
22602260
]
22612261
})
22622262

test/internal/routing-util.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ describe('#unit RoutingUtil', () => {
237237
'CALL dbms.routing.getRoutingTable($context, $database)'
238238
])
239239
expect(connection.seenParameters).toEqual([
240-
{ context: {}, database: null }
240+
{ context: { address: '127.0.0.1' }, database: null }
241241
])
242242
expect(connection.seenProtocolOptions).toEqual([
243243
jasmine.objectContaining({
@@ -264,7 +264,7 @@ describe('#unit RoutingUtil', () => {
264264
'CALL dbms.routing.getRoutingTable($context, $database)'
265265
])
266266
expect(connection.seenParameters).toEqual([
267-
{ context: {}, database: null }
267+
{ context: { address: '127.0.0.1' }, database: null }
268268
])
269269
expect(connection.seenProtocolOptions).toEqual([
270270
jasmine.objectContaining({
@@ -290,7 +290,7 @@ describe('#unit RoutingUtil', () => {
290290
'CALL dbms.routing.getRoutingTable($context, $database)'
291291
])
292292
expect(connection.seenParameters).toEqual([
293-
{ context: {}, database: null }
293+
{ context: { address: '127.0.0.1' }, database: null }
294294
])
295295
expect(connection.seenProtocolOptions).toEqual([
296296
jasmine.objectContaining({
@@ -515,7 +515,7 @@ describe('#unit RoutingUtil', () => {
515515
}
516516

517517
function callRoutingProcedure (session, database, routingContext) {
518-
const util = new RoutingUtil(routingContext || {})
518+
const util = new RoutingUtil(routingContext || {}, '127.0.0.1')
519519
return util.callRoutingProcedure(session, database, ROUTER_ADDRESS)
520520
}
521521

test/resources/boltstub/v4/acquire_endpoints_aDatabase.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO RESET
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {}, "database": "aDatabase"} {"mode": "r", "db": "system"}
6+
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {"address": "127.0.0.1:9001"}, "database": "aDatabase"} {"mode": "r", "db": "system"}
77
PULL {"n": -1}
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9007","127.0.0.1:9008"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005","127.0.0.1:9006"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]

test/resources/boltstub/v4/acquire_endpoints_aDatabase_no_servers.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO RESET
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {}, "database":"aDatabase"} {"mode": "r", "db": "system"}
6+
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {"address": "127.0.0.1:9001"}, "database":"aDatabase"} {"mode": "r", "db": "system"}
77
PULL {"n": -1}
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, []]

test/resources/boltstub/v4/acquire_endpoints_aDatabase_with_bookmark.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO RESET
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {}, "database": "aDatabase"} {"mode": "r", "db": "system", "bookmarks": ["system:1111", "aDatabase:5555"]}
6+
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {"address":"127.0.0.1:9001"}, "database": "aDatabase"} {"mode": "r", "db": "system", "bookmarks": ["system:1111", "aDatabase:5555"]}
77
PULL {"n": -1}
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9007","127.0.0.1:9008"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005","127.0.0.1:9006"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]

test/resources/boltstub/v4/acquire_endpoints_db_not_found.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO RESET
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {}, "database": "aDatabase"} {"mode": "r", "db": "system"}
6+
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {"address": "127.0.0.1:9001"}, "database": "aDatabase"} {"mode": "r", "db": "system"}
77
PULL {"n": -1}
88
S: FAILURE {"code": "Neo.ClientError.Database.DatabaseNotFound", "message": "database not found"}
99
IGNORED

test/resources/boltstub/v4/acquire_endpoints_default_database.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO RESET
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {}, "database": null} {"mode": "r", "db": "system"}
6+
C: RUN "CALL dbms.routing.getRoutingTable($context, $database)" {"context": {"address": "127.0.0.1:9001"}, "database": null} {"mode": "r", "db": "system"}
77
PULL {"n": -1}
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9007","127.0.0.1:9008"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005","127.0.0.1:9006"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]

0 commit comments

Comments
 (0)