@@ -78,6 +78,7 @@ describe('stress tests', () => {
78
78
done . fail ( error ) ;
79
79
}
80
80
81
+ verifyServers ( context ) ;
81
82
verifyNodeCount ( context )
82
83
. then ( ( ) => done ( ) )
83
84
. catch ( error => done . fail ( error ) ) ;
@@ -152,12 +153,9 @@ describe('stress tests', () => {
152
153
context . log ( commandId , `About to run ${ accessMode } query` ) ;
153
154
154
155
session . run ( query , params ) . then ( result => {
155
-
156
- if ( accessMode === WRITE ) {
157
- context . nodeCreated ( ) ;
158
- }
159
-
156
+ context . queryCompleted ( result , accessMode ) ;
160
157
context . log ( commandId , `Query completed successfully` ) ;
158
+
161
159
session . close ( ( ) => {
162
160
const possibleError = verifyQueryResult ( result ) ;
163
161
callback ( possibleError ) ;
@@ -187,13 +185,9 @@ describe('stress tests', () => {
187
185
commandError = commitError ;
188
186
}
189
187
} ) . then ( ( ) => {
190
- context . setBookmark ( session . lastBookmark ( ) ) ;
191
-
188
+ context . queryCompleted ( result , accessMode , session . lastBookmark ( ) ) ;
192
189
context . log ( commandId , `Transaction committed successfully` ) ;
193
190
194
- if ( accessMode === WRITE ) {
195
- context . nodeCreated ( ) ;
196
- }
197
191
session . close ( ( ) => {
198
192
callback ( commandError ) ;
199
193
} ) ;
@@ -249,6 +243,17 @@ describe('stress tests', () => {
249
243
} ) ;
250
244
}
251
245
246
+ function verifyServers ( context ) {
247
+ const routing = DATABASE_URI . startsWith ( 'bolt+routing' ) ;
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
+
252
257
function randomParams ( ) {
253
258
return {
254
259
name : `Person-${ Date . now ( ) } ` ,
@@ -301,20 +306,27 @@ describe('stress tests', () => {
301
306
this . createdNodesCount = 0 ;
302
307
this . _commandIdCouter = 0 ;
303
308
this . _loggingEnabled = loggingEnabled ;
309
+ this . _seenServers = new Set ( ) ;
304
310
}
305
311
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 ) ;
312
320
}
313
321
314
322
nextCommandId ( ) {
315
323
return this . _commandIdCouter ++ ;
316
324
}
317
325
326
+ seenServers ( ) {
327
+ return Array . from ( this . _seenServers ) ;
328
+ }
329
+
318
330
log ( commandId , message ) {
319
331
if ( this . _loggingEnabled ) {
320
332
console . log ( `Command [${ commandId } ]: ${ message } ` ) ;
0 commit comments