@@ -10,6 +10,23 @@ import {
1010 waitForNewDatabase ,
1111} from "./_integration-timeouts.js" ;
1212
13+ /** Cap in-flight writes/streams so small CI runners and cluster LBs stay responsive. */
14+ const insertChunk = 100 ;
15+ const streamOpenChunk = 5 ;
16+ const docCount = 1000 ;
17+ const parallelStreamCount = 25 ;
18+
19+ async function parallelInChunks (
20+ count : number ,
21+ chunk : number ,
22+ run : ( index : number ) => Promise < unknown > ,
23+ ) : Promise < void > {
24+ for ( let i = 0 ; i < count ; i += chunk ) {
25+ const n = Math . min ( chunk , count - i ) ;
26+ await Promise . all ( Array . from ( { length : n } , ( _ , j ) => run ( i + j ) ) ) ;
27+ }
28+ }
29+
1330describe ( "AQL Stream queries" , function ( ) {
1431 this . timeout ( clusterIntegrationTimeoutMs ) ;
1532 const name = `testdb_${ Date . now ( ) } ` ;
@@ -70,18 +87,18 @@ describe("AQL Stream queries", function () {
7087 expect ( cursor . batches . hasMore ) . to . equal ( true ) ;
7188 } ) ;
7289 } ) ;
73- describe ( "with some data" , ( ) => {
90+ describe ( "with some data" , function ( ) {
91+ // Setup inserts many docs; keep headroom above the single-topology 60s suite ceiling.
92+ this . timeout ( Math . max ( clusterIntegrationTimeoutMs , 120_000 ) ) ;
7493 const cname = "MyTestCollection" ;
7594 before ( async ( ) => {
7695 const collection = await db . createCollection ( cname ) ;
7796 await db . waitForPropagation (
7897 { pathname : `/_api/collection/${ collection . name } ` } ,
7998 propagationForResourceMs ,
8099 ) ;
81- await Promise . all (
82- Array . from ( Array ( 1000 ) . keys ( ) ) . map ( ( i : number ) =>
83- collection . save ( { hallo : i } ) ,
84- ) ,
100+ await parallelInChunks ( docCount , insertChunk , ( i ) =>
101+ collection . save ( { hallo : i } ) ,
85102 ) ;
86103 } ) ;
87104 /*after(async () => {
@@ -90,21 +107,22 @@ describe("AQL Stream queries", function () {
90107 it ( "can access large collection in parallel" , async ( ) => {
91108 const collection = db . collection ( cname ) ;
92109 const query = aql `FOR doc in ${ collection } RETURN doc` ;
93- const options = { batchSize : 250 , stream : true } ;
110+ const options = { batchSize : 250 , stream : true , ttl : 120 } ;
94111
95112 let count = 0 ;
96- const cursors = await Promise . all (
97- Array . from ( Array ( 25 ) ) . map ( ( ) => db . query ( query , options ) ) ,
98- ) ;
113+ const cursors : Cursor [ ] = [ ] ;
114+ await parallelInChunks ( parallelStreamCount , streamOpenChunk , async ( ) => {
115+ cursors . push ( await db . query ( query , options ) ) ;
116+ } ) ;
99117 allCursors . push ( ...cursors ) ;
100118 await Promise . all (
101119 cursors . map ( ( c ) =>
102- ( c as Cursor ) . forEach ( ( ) => {
120+ c . forEach ( ( ) => {
103121 count ++ ;
104122 } ) ,
105123 ) ,
106124 ) ;
107- expect ( count ) . to . equal ( 25 * 1000 ) ;
125+ expect ( count ) . to . equal ( parallelStreamCount * docCount ) ;
108126 } ) ;
109127 it ( "can do writes and reads" , async ( ) => {
110128 const collection = db . collection ( cname ) ;
0 commit comments