summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2016-09-23 16:02:21 -0400
committerDavid Storch <david.storch@10gen.com>2016-09-23 16:07:50 -0400
commit3103bba2a6250f54af065b55763fef7e9e0b49ea (patch)
tree72019b7d2c31aff590eccd866b0956cfd41c089c
parentee11bcea348635a6ac4ce25b626df08f075101f4 (diff)
downloadmongo-3103bba2a6250f54af065b55763fef7e9e0b49ea.tar.gz
SERVER-22837 fix flakiness in jstests/sharding/cursor1.js
-rw-r--r--jstests/sharding/cursor1.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/jstests/sharding/cursor1.js b/jstests/sharding/cursor1.js
index a95648b4918..ab387870751 100644
--- a/jstests/sharding/cursor1.js
+++ b/jstests/sharding/cursor1.js
@@ -16,7 +16,7 @@
primary = s.getServer("test").getDB("test");
secondary = s.getOther(primary).getDB("test");
- numObjs = 10;
+ var numObjs = 30;
var bulk = db.foo.initializeUnorderedBulkOp();
for (i = 0; i < numObjs; i++) {
bulk.insert({_id: i});
@@ -44,26 +44,28 @@
assert.eq(numObjs, cursor2.itcount(), "c2");
assert.eq(numObjs, cursor3.itcount(), "c3");
- // test timeout
+ // Test that a cursor with a 1 second timeout eventually times out.
gc();
gc();
- cur = db.foo.find().batchSize(2);
+ var cur = db.foo.find().batchSize(2);
assert(cur.next(), "T1");
assert(cur.next(), "T2");
assert.commandWorked(s.admin.runCommand({
setParameter: 1,
- cursorTimeoutMillis: 10000 // 10 seconds.
+ cursorTimeoutMillis: 1000 // 1 second.
}));
- before = db.serverStatus().metrics.cursor;
- printjson(before);
- sleep(6000);
- assert(cur.next(), "T3");
- assert(cur.next(), "T4");
- sleep(24000);
- assert.throws(function() {
- cur.next();
- }, null, "T5");
- after = db.serverStatus().metrics.cursor;
+
+ assert.soon(function() {
+ try {
+ cur.next();
+ cur.next();
+ print("cursor still alive");
+ return false;
+ } catch (e) {
+ return true;
+ }
+ }, "cursor failed to time out", /*timeout*/ 30000, /*interval*/ 5000);
+
gc();
gc();