Skip to content

Commit a5d2cb9

Browse files
committed
NODE-493 Added test to ensure we can connect using large poolSizes
1 parent 7e966b3 commit a5d2cb9

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

lib/cursor.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ var Cursor = function(bson, ns, cmd, options, topology, topologyOptions) {
119119
// Topology options
120120
, topologyOptions: topologyOptions
121121
// Promise library
122-
, promiseLibrary: promiseLibrary
122+
, promiseLibrary: promiseLibrary
123123
// Current doc
124124
, currentDoc: null
125125
}
@@ -193,7 +193,7 @@ Cursor.prototype.hasNext = function(callback) {
193193
if(err) return reject(err);
194194
if(!doc) return resolve(false);
195195
self.s.currentDoc = doc;
196-
resolve(true);
196+
resolve(true);
197197
});
198198
});
199199
}
@@ -234,7 +234,7 @@ Cursor.prototype.next = function(callback) {
234234

235235
nextObject(self, function(err, r) {
236236
if(err) return reject(err);
237-
resolve(r);
237+
resolve(r);
238238
});
239239
});
240240
}
@@ -502,6 +502,7 @@ var nextObject = function(self, callback) {
502502
if(err && err.tailable && self.s.currentNumberOfRetries == 0) return callback(err);
503503
if(err && err.tailable && self.s.currentNumberOfRetries > 0) {
504504
self.s.currentNumberOfRetries = self.s.currentNumberOfRetries - 1;
505+
505506
return setTimeout(function() {
506507
self.nextObject(callback);
507508
}, self.s.tailableRetryInterval);
@@ -510,7 +511,7 @@ var nextObject = function(self, callback) {
510511
self.s.state = Cursor.OPEN;
511512
if(err) return handleCallback(callback, err);
512513
handleCallback(callback, null, doc);
513-
});
514+
});
514515
}
515516

516517
// Trampoline emptying the number of retrieved items
@@ -665,7 +666,7 @@ Cursor.prototype.toArray = function(callback) {
665666
return new this.s.promiseLibrary(function(resolve, reject) {
666667
toArray(self, function(err, r) {
667668
if(err) return reject(err);
668-
resolve(r);
669+
resolve(r);
669670
});
670671
});
671672
}
@@ -707,7 +708,7 @@ var toArray = function(self, callback) {
707708
})
708709
}
709710

710-
fetchDocs();
711+
fetchDocs();
711712
}
712713

713714
/**
@@ -743,7 +744,7 @@ Cursor.prototype.count = function(applySkipLimit, opts, callback) {
743744
return new this.s.promiseLibrary(function(resolve, reject) {
744745
count(self, applySkipLimit, opts, function(err, r) {
745746
if(err) return reject(err);
746-
resolve(r);
747+
resolve(r);
747748
});
748749
});
749750
};
@@ -801,7 +802,7 @@ var count = function(self, applySkipLimit, opts, callback) {
801802
});
802803

803804
// Write the initial command out
804-
connection.write(query.toBin());
805+
connection.write(query.toBin());
805806
}
806807

807808
/**
@@ -879,7 +880,7 @@ Cursor.prototype.explain = function(callback) {
879880
return new this.s.promiseLibrary(function(resolve, reject) {
880881
self._next(function(err, r) {
881882
if(err) return reject(err);
882-
resolve(r);
883+
resolve(r);
883884
});
884885
});
885886
}

test/functional/connection_tests.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ exports['Should correctly connect to server using just events'] = {
4545
}
4646
}
4747

48+
/**
49+
* @ignore
50+
*/
51+
exports['Should correctly connect to server using big connection pool'] = {
52+
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } },
53+
54+
// The actual test we wish to run
55+
test: function(configuration, test) {
56+
var db = configuration.newDbInstance({w:1}, {poolSize:500, auto_reconnect:true});
57+
db.on('open', function() {
58+
db.close();
59+
test.done();
60+
});
61+
62+
db.open();
63+
}
64+
}
65+
4866
/**
4967
* @ignore
5068
*/

test/functional/cursor_tests.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,8 +1949,11 @@ exports.shouldCloseDeadTailableCursors = {
19491949
test.ok(err != null);
19501950
});
19511951

1952+
stream.on('end', function () {
1953+
closed = true;
1954+
});
1955+
19521956
stream.on('close', function () {
1953-
// this is what we need
19541957
closed = true;
19551958
});
19561959

@@ -1963,9 +1966,11 @@ exports.shouldCloseDeadTailableCursors = {
19631966

19641967
setTimeout(function () {
19651968
db.close();
1966-
test.equal(true, closed);
1967-
db.close();
1968-
test.done();
1969+
1970+
setTimeout(function() {
1971+
test.equal(true, closed);
1972+
test.done();
1973+
}, 1000)
19691974
}, 800);
19701975
});
19711976
});

0 commit comments

Comments
 (0)