@@ -21,7 +21,11 @@ import neo4j from '../src'
2121import { READ , WRITE } from '../src/driver'
2222import parallelLimit from 'async/parallelLimit'
2323import _ from 'lodash'
24- import { ServerVersion , VERSION_3_2_0 } from '../src/internal/server-version'
24+ import {
25+ ServerVersion ,
26+ VERSION_3_2_0 ,
27+ VERSION_4_0_0
28+ } from '../src/internal/server-version'
2529import sharedNeo4j from './internal/shared-neo4j'
2630
2731describe ( '#integration stress tests' , ( ) => {
@@ -47,6 +51,15 @@ describe('#integration stress tests', () => {
4751 'STRESS_TEST_DATABASE_URI' ,
4852 'bolt://localhost'
4953 )
54+
55+ const USERNAME = fromEnvOrDefault (
56+ 'NEO4J_USERNAME' ,
57+ sharedNeo4j . authToken . principal
58+ )
59+ const PASSWORD = fromEnvOrDefault (
60+ 'NEO4J_PASSWORD' ,
61+ sharedNeo4j . authToken . credentials
62+ )
5063 const LOGGING_ENABLED = fromEnvOrDefault ( 'STRESS_TEST_LOGGING_ENABLED' , false )
5164
5265 let originalTimeout
@@ -57,16 +70,20 @@ describe('#integration stress tests', () => {
5770 jasmine . DEFAULT_TIMEOUT_INTERVAL = TEST_MODE . maxRunTimeMs
5871
5972 const config = {
60- logging : neo4j . logging . console ( LOGGING_ENABLED ? 'debug' : 'info' )
73+ logging : neo4j . logging . console ( LOGGING_ENABLED ? 'debug' : 'info' ) ,
74+ encrypted : true
6175 }
62- driver = neo4j . driver ( DATABASE_URI , sharedNeo4j . authToken , config )
76+ driver = neo4j . driver (
77+ DATABASE_URI ,
78+ neo4j . auth . basic ( USERNAME , PASSWORD ) ,
79+ config
80+ )
6381
6482 await sharedNeo4j . cleanupAndGetVersion ( driver )
6583 } )
6684
6785 afterEach ( async ( ) => {
6886 jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout
69-
7087 await driver . close ( )
7188 } )
7289
@@ -459,14 +476,28 @@ describe('#integration stress tests', () => {
459476 session . close ( ) . then ( ( ) => {
460477 const records = result . records
461478
462- const followers = addressesWithRole ( records , 'FOLLOWER' )
463- const readReplicas = addressesWithRole ( records , 'READ_REPLICA' )
479+ const version = ServerVersion . fromString ( result . summary . server . version )
480+ const supportsMultiDb = version . compareTo ( VERSION_4_0_0 ) >= 0
481+ const followers = supportsMultiDb
482+ ? addressesForMultiDb ( records , 'FOLLOWER' )
483+ : addressesWithRole ( records , 'FOLLOWER' )
484+ const readReplicas = supportsMultiDb
485+ ? addressesForMultiDb ( records , 'READ_REPLICA' )
486+ : addressesWithRole ( records , 'READ_REPLICA' )
464487
465488 return new ClusterAddresses ( followers , readReplicas )
466489 } )
467490 )
468491 }
469492
493+ function addressesForMultiDb ( records , role , db = 'neo4j' ) {
494+ return _ . uniq (
495+ records
496+ . filter ( record => record . get ( 'databases' ) [ db ] === role )
497+ . map ( record => record . get ( 'addresses' ) [ 0 ] . replace ( 'bolt://' , '' ) )
498+ )
499+ }
500+
470501 function addressesWithRole ( records , role ) {
471502 return _ . uniq (
472503 records
@@ -550,16 +581,6 @@ describe('#integration stress tests', () => {
550581 return defaultValue
551582 }
552583
553- function cleanupDb ( driver ) {
554- const session = driver . session ( )
555- return session
556- . run ( 'MATCH (n) DETACH DELETE n' )
557- . then ( ( ) => session . close ( ) )
558- . catch ( error => {
559- console . log ( 'Error clearing the database: ' , error )
560- } )
561- }
562-
563584 function arraysEqual ( array1 , array2 ) {
564585 return _ . difference ( array1 , array2 ) . length === 0
565586 }
0 commit comments