@@ -217,6 +217,49 @@ describe('Sessions (Single)', function() {
217
217
}
218
218
} ) ;
219
219
220
+ it . only ( 'should return server sessions to the pool on `endSession`' , {
221
+ metadata : { requires : { topology : 'single' } } ,
222
+ test : function ( done ) {
223
+ let sentIsMaster = false ;
224
+ test . server . setMessageHandler ( request => {
225
+ if ( sentIsMaster ) {
226
+ request . reply ( { ok : 1 } ) ;
227
+ return ;
228
+ }
229
+
230
+ sentIsMaster = true ;
231
+ request . reply (
232
+ assign ( { } , mock . DEFAULT_ISMASTER , {
233
+ maxWireVersion : 6
234
+ } )
235
+ ) ;
236
+ } ) ;
237
+
238
+ const client = new Server ( test . server . address ( ) ) ;
239
+ const sessionPool = new ServerSessionPool ( client ) ;
240
+ const session = new ClientSession ( client , sessionPool ) ;
241
+ const clientServerSession = session . serverSession ;
242
+
243
+ client . on ( 'error' , done ) ;
244
+ client . once ( 'connect' , ( ) => {
245
+ client . command ( 'admin.$cmd' , { ping : 1 } , { session : session } , err => {
246
+ expect ( err ) . to . not . exist ;
247
+
248
+ session . endSession ( err => {
249
+ expect ( err ) . to . not . exist ;
250
+ expect ( session . hasEnded ) . to . be . true ;
251
+ expect ( sessionPool . sessions ) . to . have . length ( 1 ) ;
252
+ expect ( sessionPool . sessions [ 0 ] ) . to . eql ( clientServerSession ) ;
253
+
254
+ done ( ) ;
255
+ } ) ;
256
+ } ) ;
257
+ } ) ;
258
+
259
+ client . connect ( ) ;
260
+ }
261
+ } ) ;
262
+
220
263
it ( 'should default `logicalSessionTimeoutMinutes` to `null`' , {
221
264
metadata : { requires : { topology : 'single' } } ,
222
265
test : function ( ) {
0 commit comments