@@ -152,7 +152,7 @@ function prepareDatabaseForSuite(suite, context) {
152
152
. admin ( )
153
153
. command ( { killAllSessions : [ ] } )
154
154
. catch ( err => {
155
- if ( err . code === 11601 ) {
155
+ if ( err . code === 11601 || err . message . match ( / n o s u c h / ) ) {
156
156
return ;
157
157
}
158
158
@@ -259,17 +259,24 @@ function runTestSuiteTest(configuration, spec, context) {
259
259
260
260
spec . sessionOptions = spec . sessionOptions || { } ;
261
261
const database = client . db ( context . dbName ) ;
262
- const session0 = client . startSession (
263
- Object . assign ( { } , sessionOptions , parseSessionOptions ( spec . sessionOptions . session0 ) )
264
- ) ;
265
- const session1 = client . startSession (
266
- Object . assign ( { } , sessionOptions , parseSessionOptions ( spec . sessionOptions . session1 ) )
267
- ) ;
268
262
269
- const savedSessionData = {
270
- session0 : JSON . parse ( EJSON . stringify ( session0 . id ) ) ,
271
- session1 : JSON . parse ( EJSON . stringify ( session1 . id ) )
272
- } ;
263
+ let session0 , session1 ;
264
+ let savedSessionData ;
265
+ try {
266
+ session0 = client . startSession (
267
+ Object . assign ( { } , sessionOptions , parseSessionOptions ( spec . sessionOptions . session0 ) )
268
+ ) ;
269
+ session1 = client . startSession (
270
+ Object . assign ( { } , sessionOptions , parseSessionOptions ( spec . sessionOptions . session1 ) )
271
+ ) ;
272
+
273
+ savedSessionData = {
274
+ session0 : JSON . parse ( EJSON . stringify ( session0 . id ) ) ,
275
+ session1 : JSON . parse ( EJSON . stringify ( session1 . id ) )
276
+ } ;
277
+ } catch ( err ) {
278
+ // ignore
279
+ }
273
280
274
281
// enable to see useful APM debug information at the time of actual test run
275
282
// displayCommands = true;
@@ -292,8 +299,8 @@ function runTestSuiteTest(configuration, spec, context) {
292
299
throw err ;
293
300
} )
294
301
. then ( ( ) => {
295
- session0 . endSession ( ) ;
296
- session1 . endSession ( ) ;
302
+ if ( session0 ) session0 . endSession ( ) ;
303
+ if ( session1 ) session1 . endSession ( ) ;
297
304
298
305
return validateExpectations ( context . commandEvents , spec , savedSessionData ) ;
299
306
} ) ;
0 commit comments