@@ -110,6 +110,7 @@ describe('#integration stress tests', () => {
110
110
}
111
111
112
112
verifyServers ( context )
113
+ . then ( ( ) => verifyCommandsRun ( context , TEST_MODE . commandsCount ) )
113
114
. then ( ( ) => verifyNodeCount ( context ) )
114
115
. then ( ( ) => done ( ) )
115
116
. catch ( error => done . fail ( error ) )
@@ -275,7 +276,7 @@ describe('#integration stress tests', () => {
275
276
context . log ( commandId , 'Query completed successfully' )
276
277
277
278
return session . close ( ) . then ( ( ) => {
278
- const possibleError = verifyQueryResult ( result )
279
+ const possibleError = verifyQueryResult ( result , context )
279
280
callback ( possibleError )
280
281
} )
281
282
} )
@@ -315,10 +316,19 @@ describe('#integration stress tests', () => {
315
316
context . queryCompleted ( result , accessMode , session . lastBookmark ( ) )
316
317
context . log ( commandId , 'Transaction function executed successfully' )
317
318
318
- return session . close ( ) . then ( ( ) => {
319
- const possibleError = verifyQueryResult ( result )
320
- callback ( possibleError )
321
- } )
319
+ return session
320
+ . close ( )
321
+ . then ( ( ) => {
322
+ const possibleError = verifyQueryResult ( result , context )
323
+ callback ( possibleError )
324
+ } )
325
+ . catch ( error => {
326
+ context . log (
327
+ commandId ,
328
+ `Error closing the session ${ JSON . stringify ( error ) } `
329
+ )
330
+ callback ( error )
331
+ } )
322
332
} )
323
333
. catch ( error => {
324
334
context . log (
@@ -354,7 +364,7 @@ describe('#integration stress tests', () => {
354
364
355
365
tx . run ( query , params )
356
366
. then ( result => {
357
- let commandError = verifyQueryResult ( result )
367
+ let commandError = verifyQueryResult ( result , context )
358
368
359
369
tx . commit ( )
360
370
. catch ( commitError => {
@@ -387,10 +397,13 @@ describe('#integration stress tests', () => {
387
397
}
388
398
}
389
399
390
- function verifyQueryResult ( result ) {
400
+ function verifyQueryResult ( result , context ) {
391
401
if ( ! result ) {
392
402
return new Error ( 'Received undefined result' )
393
- } else if ( result . records . length === 0 ) {
403
+ } else if (
404
+ result . records . length === 0 &&
405
+ context . writeCommandsRun < TEST_MODE . parallelism
406
+ ) {
394
407
// it is ok to receive no nodes back for read queries at the beginning of the test
395
408
return null
396
409
} else if ( result . records . length === 1 ) {
@@ -423,6 +436,14 @@ describe('#integration stress tests', () => {
423
436
return null
424
437
}
425
438
439
+ function verifyCommandsRun ( context , expectedCommandsRun ) {
440
+ if ( context . commandsRun !== expectedCommandsRun ) {
441
+ throw new Error (
442
+ `Unexpected commands run: ${ context . commandsRun } , expected: ${ expectedCommandsRun } `
443
+ )
444
+ }
445
+ }
446
+
426
447
function verifyNodeCount ( context ) {
427
448
const expectedNodeCount = context . createdNodesCount
428
449
@@ -506,10 +527,10 @@ describe('#integration stress tests', () => {
506
527
507
528
function fetchClusterAddresses ( context ) {
508
529
const session = context . driver . session ( )
509
- return session . run ( 'CALL dbms.cluster.overview()' ) . then ( result =>
510
- session . close ( ) . then ( ( ) => {
530
+ return session
531
+ . readTransaction ( tx => tx . run ( 'CALL dbms.cluster.overview()' ) )
532
+ . then ( result => {
511
533
const records = result . records
512
-
513
534
const supportsMultiDb = protocolVersion >= 4.0
514
535
const followers = supportsMultiDb
515
536
? addressesForMultiDb ( records , 'FOLLOWER' )
@@ -518,9 +539,10 @@ describe('#integration stress tests', () => {
518
539
? addressesForMultiDb ( records , 'READ_REPLICA' )
519
540
: addressesWithRole ( records , 'READ_REPLICA' )
520
541
521
- return new ClusterAddresses ( followers , readReplicas )
542
+ return session
543
+ . close ( )
544
+ . then ( ( ) => new ClusterAddresses ( followers , readReplicas ) )
522
545
} )
523
- )
524
546
}
525
547
526
548
function addressesForMultiDb ( records , role , db = 'neo4j' ) {
@@ -630,6 +652,20 @@ describe('#integration stress tests', () => {
630
652
this . protocolVersion = null
631
653
}
632
654
655
+ get commandsRun ( ) {
656
+ return [
657
+ ...Object . values ( this . readServersWithQueryCount ) ,
658
+ ...Object . values ( this . writeServersWithQueryCount )
659
+ ] . reduce ( ( a , b ) => a + b , 0 )
660
+ }
661
+
662
+ get writeCommandsRun ( ) {
663
+ return [ ...Object . values ( this . writeServersWithQueryCount ) ] . reduce (
664
+ ( a , b ) => a + b ,
665
+ 0
666
+ )
667
+ }
668
+
633
669
queryCompleted ( result , accessMode , bookmark ) {
634
670
const serverInfo = result . summary . server
635
671
this . protocolVersion = serverInfo . protocolVersion
0 commit comments