@@ -32,6 +32,10 @@ const oracledb = require('oracledb');
32
32
const should = require ( 'should' ) ;
33
33
const dbconfig = require ( './dbconfig.js' ) ;
34
34
35
+ function sleep ( ms ) {
36
+ return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
37
+ }
38
+
35
39
describe ( '170. poolDrain.js' , ( ) => {
36
40
before ( function ( ) {
37
41
if ( process . versions . modules < 57 ) this . skip ( ) ;
@@ -59,17 +63,22 @@ describe('170. poolDrain.js', () => {
59
63
err . message ,
60
64
"NJS-064: connection pool is closing"
61
65
) ;
66
+ } finally {
67
+ await sleep ( 6000 ) ;
62
68
}
63
69
} ) ; // 170.1
64
70
65
71
it ( '170.2 close pool without force flag (will give out an error ), and prevent new connections' , async ( ) => {
72
+ let pool ;
66
73
try {
67
- let pool = await oracledb . createPool ( settings ) ;
74
+ pool = await oracledb . createPool ( settings ) ;
68
75
await pool . getConnection ( ) ;
69
76
await pool . close ( ) ;
70
77
} catch ( err ) {
71
78
should . exist ( err ) ;
72
79
( err . message ) . should . startWith ( 'ORA-24422:' ) ;
80
+ } finally {
81
+ await pool . close ( 0 ) ;
73
82
}
74
83
} ) ; // 170.2
75
84
@@ -83,6 +92,8 @@ describe('170. poolDrain.js', () => {
83
92
should . strictEqual ( pool . status , oracledb . POOL_STATUS_DRAINING ) ;
84
93
} catch ( err ) {
85
94
should . not . exist ( err ) ;
95
+ } finally {
96
+ await sleep ( 3000 ) ;
86
97
}
87
98
} ) ; // 170.3
88
99
@@ -178,6 +189,8 @@ describe('170. poolDrain.js', () => {
178
189
pool_2 . close ( drainTime ) ;
179
190
} catch ( err ) {
180
191
should . not . exist ( err ) ;
192
+ } finally {
193
+ await sleep ( 3000 ) ;
181
194
}
182
195
} ) ; // 170.9
183
196
@@ -215,8 +228,9 @@ describe('170. poolDrain.js', () => {
215
228
} ) ;
216
229
217
230
it ( '170.12 drainTime = -3' , async ( ) => {
231
+ let pool ;
218
232
try {
219
- let pool = await oracledb . createPool ( settings ) ;
233
+ pool = await oracledb . createPool ( settings ) ;
220
234
221
235
await pool . getConnection ( ) ;
222
236
await pool . getConnection ( ) ;
@@ -228,12 +242,15 @@ describe('170. poolDrain.js', () => {
228
242
} catch ( err ) {
229
243
should . exist ( err ) ;
230
244
should . strictEqual ( err . message , "NJS-005: invalid value for parameter 1" ) ;
245
+ } finally {
246
+ await pool . close ( 0 ) ;
231
247
}
232
248
} ) ;
233
249
234
250
it ( '170.13 drainTime = NaN' , async ( ) => {
251
+ let pool ;
235
252
try {
236
- let pool = await oracledb . createPool ( settings ) ;
253
+ pool = await oracledb . createPool ( settings ) ;
237
254
238
255
await pool . getConnection ( ) ;
239
256
await pool . getConnection ( ) ;
@@ -245,6 +262,8 @@ describe('170. poolDrain.js', () => {
245
262
} catch ( err ) {
246
263
should . exist ( err ) ;
247
264
should . strictEqual ( err . message , "NJS-005: invalid value for parameter 1" ) ;
265
+ } finally {
266
+ await pool . close ( 0 ) ;
248
267
}
249
268
} ) ;
250
269
@@ -268,6 +287,8 @@ describe('170. poolDrain.js', () => {
268
287
pool_2 . close ( 1 ) ;
269
288
} catch ( err ) {
270
289
should . not . exist ( err ) ;
290
+ } finally {
291
+ await sleep ( 4000 ) ;
271
292
}
272
293
} ) ;
273
294
@@ -297,6 +318,8 @@ describe('170. poolDrain.js', () => {
297
318
pool_2 . close ( 1 ) ;
298
319
} catch ( err ) {
299
320
should . not . exist ( err ) ;
321
+ } finally {
322
+ await sleep ( 4000 ) ;
300
323
}
301
324
} ) ;
302
325
0 commit comments