@@ -23,7 +23,7 @@ import parallelLimit from 'async/parallelLimit';
2323import _ from 'lodash' ;
2424import sharedNeo4j from '../internal/shared-neo4j' ;
2525
26- describe ( 'stress tests' , ( ) => {
26+ fdescribe ( 'stress tests' , ( ) => {
2727
2828 const TEST_MODES = {
2929 fast : {
@@ -78,6 +78,7 @@ describe('stress tests', () => {
7878 done . fail ( error ) ;
7979 }
8080
81+ verifyServers ( context ) ;
8182 verifyNodeCount ( context )
8283 . then ( ( ) => done ( ) )
8384 . catch ( error => done . fail ( error ) ) ;
@@ -152,12 +153,9 @@ describe('stress tests', () => {
152153 context . log ( commandId , `About to run ${ accessMode } query` ) ;
153154
154155 session . run ( query , params ) . then ( result => {
155-
156- if ( accessMode === WRITE ) {
157- context . nodeCreated ( ) ;
158- }
159-
156+ context . queryCompleted ( result , accessMode ) ;
160157 context . log ( commandId , `Query completed successfully` ) ;
158+
161159 session . close ( ( ) => {
162160 const possibleError = verifyQueryResult ( result ) ;
163161 callback ( possibleError ) ;
@@ -187,13 +185,9 @@ describe('stress tests', () => {
187185 commandError = commitError ;
188186 }
189187 } ) . then ( ( ) => {
190- context . setBookmark ( session . lastBookmark ( ) ) ;
191-
188+ context . queryCompleted ( result , accessMode , session . lastBookmark ( ) ) ;
192189 context . log ( commandId , `Transaction committed successfully` ) ;
193190
194- if ( accessMode === WRITE ) {
195- context . nodeCreated ( ) ;
196- }
197191 session . close ( ( ) => {
198192 callback ( commandError ) ;
199193 } ) ;
@@ -249,6 +243,17 @@ describe('stress tests', () => {
249243 } ) ;
250244 }
251245
246+ function verifyServers ( context ) {
247+ const routing = DATABASE_URI . indexOf ( 'bolt+routing' ) === 0 ;
248+ const seenServers = context . seenServers ( ) ;
249+
250+ if ( routing && seenServers . length <= 1 ) {
251+ throw new Error ( `Routing driver used too few servers: ${ seenServers } ` ) ;
252+ } else if ( ! routing && seenServers . length !== 1 ) {
253+ throw new Error ( `Direct driver used too many servers: ${ seenServers } ` ) ;
254+ }
255+ }
256+
252257 function randomParams ( ) {
253258 return {
254259 name : `Person-${ Date . now ( ) } ` ,
@@ -301,20 +306,27 @@ describe('stress tests', () => {
301306 this . createdNodesCount = 0 ;
302307 this . _commandIdCouter = 0 ;
303308 this . _loggingEnabled = loggingEnabled ;
309+ this . _seenServers = new Set ( ) ;
304310 }
305311
306- setBookmark ( bookmark ) {
307- this . bookmark = bookmark ;
308- }
309-
310- nodeCreated ( ) {
311- this . createdNodesCount ++ ;
312+ queryCompleted ( result , accessMode , bookmark ) {
313+ if ( accessMode === WRITE ) {
314+ this . createdNodesCount ++ ;
315+ }
316+ if ( bookmark ) {
317+ this . bookmark = bookmark ;
318+ }
319+ this . _seenServers . add ( result . summary . server . address ) ;
312320 }
313321
314322 nextCommandId ( ) {
315323 return this . _commandIdCouter ++ ;
316324 }
317325
326+ seenServers ( ) {
327+ return Array . from ( this . _seenServers ) ;
328+ }
329+
318330 log ( commandId , message ) {
319331 if ( this . _loggingEnabled ) {
320332 console . log ( `Command [${ commandId } ]: ${ message } ` ) ;
0 commit comments