@@ -7,8 +7,8 @@ const ARANGO_VERSION = Number(process.env.ARANGO_VERSION || 30000);
77const describe34 = ARANGO_VERSION >= 30400 ? describe : describe . skip ;
88
99describe34 ( "AQL Stream queries" , function ( ) {
10- // create database takes 11s in a standard cluster
11- this . timeout ( 20000 ) ;
10+ // create database takes 11s in a standard cluster and sometimes even more
11+ this . timeout ( 30000 ) ;
1212
1313 let name = `testdb_${ Date . now ( ) } ` ;
1414 let db : Database ;
@@ -82,51 +82,69 @@ describe34("AQL Stream queries", function() {
8282 } ) ;
8383 } ) ;
8484 describe ( "with some data" , ( ) => {
85- let cname = "MyTestCollection"
85+ let cname = "MyTestCollection" ;
8686 before ( done => {
8787 let collection = db . collection ( cname ) ;
88- collection . create ( )
88+ collection
89+ . create ( )
8990 . then ( ( ) => {
90- return Promise . all ( Array . apply ( null , { length : 1000 } )
91- . map ( Number . call , Number )
92- . map ( ( i : Number ) => collection . save ( { hallo : i } ) ) ) ;
93- } ) . then ( ( ) => void done ( ) ) . catch ( done ) ;
91+ return Promise . all (
92+ Array . apply ( null , { length : 1000 } )
93+ . map ( Number . call , Number )
94+ . map ( ( i : Number ) => collection . save ( { hallo : i } ) )
95+ ) ;
96+ } )
97+ . then ( ( ) => void done ( ) )
98+ . catch ( done ) ;
9499 } ) ;
95100 /*after(done => {
96101 db.collection(cname).drop().then(() => done()).catch(done);
97102 });*/
98- it ( "can access large collection in parallel" , ( done ) => {
103+ it ( "can access large collection in parallel" , done => {
99104 let collection = db . collection ( cname ) ;
100105 let query = aql `FOR doc in ${ collection } RETURN doc` ;
101106 const opts = { batchSize : 250 , options : { stream : true } } ;
102107
103108 let count = 0 ;
104- Promise . all ( Array . apply ( null , { length : 25 } ) . map ( ( ) => db . query ( query , opts ) ) )
109+ Promise . all (
110+ Array . apply ( null , { length : 25 } ) . map ( ( ) => db . query ( query , opts ) )
111+ )
105112 . then ( cursors => {
106- return Promise . all ( cursors . map ( c => ( c as ArrayCursor ) . each ( ( ) => { count ++ } ) ) )
107- } ) . then ( ( ) => {
113+ return Promise . all (
114+ cursors . map ( c =>
115+ ( c as ArrayCursor ) . each ( ( ) => {
116+ count ++ ;
117+ } )
118+ )
119+ ) ;
120+ } )
121+ . then ( ( ) => {
108122 expect ( count ) . to . equal ( 25 * 1000 ) ;
109123 done ( ) ;
110- } ) . catch ( done ) ;
124+ } )
125+ . catch ( done ) ;
111126 } ) ;
112- it ( "can do writes and reads" , ( done ) => {
127+ it ( "can do writes and reads" , done => {
113128 let collection = db . collection ( cname ) ;
114129 let readQ = aql `FOR doc in ${ collection } RETURN doc` ;
115130 let writeQ = aql `FOR i in 1..1000 LET y = SLEEP(1) INSERT {forbidden: i} INTO ${ collection } ` ;
116131 const opts = { batchSize : 500 , ttl : 5 , options : { stream : true } } ;
117132
118- // 900s lock timeout + 5s ttl
133+ // 900s lock timeout + 5s ttl
119134 let readCursor = db . query ( readQ , opts ) ;
120135 let writeCursor = db . query ( writeQ , opts ) ;
121136
122137 // the read cursor should always win
123- Promise . race ( [ readCursor , writeCursor ] ) . then ( c => {
124- // therefore no document should have been written here
125- return c . every ( ( d : any ) => ! ( d . hasOwnProperty ( "forbidden" ) ) )
126- } ) . then ( isOk => {
127- expect ( isOk ) . to . equal ( true ) ;
128- done ( ) ;
129- } ) . catch ( done ) ;
138+ Promise . race ( [ readCursor , writeCursor ] )
139+ . then ( c => {
140+ // therefore no document should have been written here
141+ return c . every ( ( d : any ) => ! d . hasOwnProperty ( "forbidden" ) ) ;
142+ } )
143+ . then ( isOk => {
144+ expect ( isOk ) . to . equal ( true ) ;
145+ done ( ) ;
146+ } )
147+ . catch ( done ) ;
130148 } ) ;
131149 } ) ;
132150} ) ;
0 commit comments