@@ -1730,6 +1730,68 @@ describe('Cursor', function () {
1730
1730
}
1731
1731
} ) ;
1732
1732
1733
+ it ( 'removes session wheen cloning a find cursor' , function ( done ) {
1734
+ const configuration = this . configuration ;
1735
+ const client = configuration . newClient ( configuration . writeConcernMax ( ) , { maxPoolSize : 1 } ) ;
1736
+ client . connect ( ( err , client ) => {
1737
+ expect ( err ) . to . not . exist ;
1738
+
1739
+ const db = client . db ( configuration . db ) ;
1740
+ db . createCollection ( 'clone_find_cursor_session' , ( err , collection ) => {
1741
+ expect ( err ) . to . not . exist ;
1742
+
1743
+ collection . insertOne ( { a : 1 } , configuration . writeConcernMax ( ) , err => {
1744
+ expect ( err ) . to . not . exist ;
1745
+
1746
+ const cursor = collection . find ( ) ;
1747
+ const clonedCursor = cursor . clone ( ) ;
1748
+ cursor . toArray ( err => {
1749
+ expect ( err ) . to . not . exist ;
1750
+ clonedCursor . toArray ( err => {
1751
+ expect ( err ) . to . not . exist ;
1752
+ client . close ( ) ;
1753
+ done ( ) ;
1754
+ } ) ;
1755
+ } ) ;
1756
+ } ) ;
1757
+ } ) ;
1758
+ } ) ;
1759
+ } ) ;
1760
+
1761
+ it ( 'removes session wheen cloning an aggregation cursor' , {
1762
+ metadata : {
1763
+ requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] }
1764
+ } ,
1765
+
1766
+ test : function ( done ) {
1767
+ const configuration = this . configuration ;
1768
+ const client = configuration . newClient ( configuration . writeConcernMax ( ) , { maxPoolSize : 1 } ) ;
1769
+ client . connect ( ( err , client ) => {
1770
+ expect ( err ) . to . not . exist ;
1771
+
1772
+ const db = client . db ( configuration . db ) ;
1773
+ db . createCollection ( 'clone_aggregation_cursor_session' , ( err , collection ) => {
1774
+ expect ( err ) . to . not . exist ;
1775
+
1776
+ collection . insertOne ( { a : 1 } , configuration . writeConcernMax ( ) , err => {
1777
+ expect ( err ) . to . not . exist ;
1778
+
1779
+ const cursor = collection . aggregate ( [ { $match : { a : 1 } } ] ) ;
1780
+ const clonedCursor = cursor . clone ( ) ;
1781
+ cursor . toArray ( err => {
1782
+ expect ( err ) . to . not . exist ;
1783
+ clonedCursor . toArray ( err => {
1784
+ expect ( err ) . to . not . exist ;
1785
+ client . close ( ) ;
1786
+ done ( ) ;
1787
+ } ) ;
1788
+ } ) ;
1789
+ } ) ;
1790
+ } ) ;
1791
+ } ) ;
1792
+ }
1793
+ } ) ;
1794
+
1733
1795
it ( 'destroying a stream stops it' , {
1734
1796
// Add a tag that our runner can trigger on
1735
1797
// in this case we are setting that node needs to be higher than 0.10.X to run
0 commit comments