summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-12-08 16:53:12 -0500
committerRamon Fernandez <ramon@mongodb.com>2016-03-03 13:34:14 -0500
commit416682206ab5230ad77c53d85ef75d2a8718a690 (patch)
treee819f06c55feed53a18c12bf7d0d46596b0b464e
parentb8a3d87501b15a881e135f45d4ef9de641b191a3 (diff)
downloadmongo-416682206ab5230ad77c53d85ef75d2a8718a690.tar.gz
SERVER-21602 Use 'cursorTimeoutMillis' flag in cursor_timeout.js
Reduces this test's execution time from ~17 minutes to <30 seconds. (cherry picked from commit 181cdbf26a32e894b53ea10dc7e719fc841727d3) (cherry picked from commit 0e5df8d9a74ccdcc0982de9af37f3287e6f1acda)
-rw-r--r--jstests/slow2/cursor_timeout.js34
1 files changed, 23 insertions, 11 deletions
diff --git a/jstests/slow2/cursor_timeout.js b/jstests/slow2/cursor_timeout.js
index 3e80e6c6fa7..d453713bb9d 100644
--- a/jstests/slow2/cursor_timeout.js
+++ b/jstests/slow2/cursor_timeout.js
@@ -1,4 +1,19 @@
-var st = new ShardingTest({ shards: 2, other: { chunkSize: 1 }});
+// Basic integration tests for the background job that periodically kills idle cursors, in both
+// mongod and mongos. This test creates the following four cursors:
+//
+// 1. A no-timeout cursor through mongos.
+// 2. A no-timeout cursor through mongod.
+// 3. A normal cursor through mongos.
+// 4. A normal cursor through mongod.
+//
+// After a period of inactivity, the test asserts that cursors #1 and #2 are still alive, and that
+// #3 and #4 have been killed.
+
+var st =
+ new ShardingTest( { shards: 2,
+ other: { chunkSize: 1,
+ shardOptions: { setParameter: "cursorTimeoutMillis=1000" },
+ mongosOptions: { setParameter: "cursorTimeoutMillis=1000" } } } );
st.stopBalancer();
var adminDB = st.admin;
@@ -20,7 +35,7 @@ for( x = 0; x < 200; x++ ){
var chunkDoc = configDB.chunks.findOne();
var chunkOwner = chunkDoc.shard;
var toShard = configDB.shards.findOne({ _id: { $ne: chunkOwner }})._id;
-var cmd = { moveChunk: coll.getFullName(), find: chunkDoc.min, to: toShard };
+var cmd = { moveChunk: coll.getFullName(), find: chunkDoc.min, to: toShard, _waitForDelete: true };
var res = adminDB.runCommand( cmd );
jsTest.log( 'move result: ' + tojson( res ));
@@ -44,21 +59,18 @@ shardedCursorWithNoTimeout.next();
cursorWithTimeout.next();
cursorWithNoTimeout.next();
-// Cursor cleanup is 10 minutes, but give a 8 min allowance --
-// NOTE: Due to inaccurate timing on non-Linux platforms, mongos tries
-// to timeout after 10 minutes but in fact is 15+ minutes;
-// SERVER-8381
-sleep( 1000 * 60 * 17 );
+// Wait until the idle cursor background job has killed the cursors that do not have the "no
+// timeout" flag set. We use the "cursorTimeoutMillis" setParameter above to reduce the amount of
+// time we need to wait here.
+sleep( 5000 );
assert.throws( function(){ shardedCursorWithTimeout.itcount(); } );
assert.throws( function(){ cursorWithTimeout.itcount(); } );
-var freshShardedItCount = coll.find().itcount();
// +1 because we already advanced once
-assert.eq( freshShardedItCount, shardedCursorWithNoTimeout.itcount() + 1 );
+assert.eq( coll.count(), shardedCursorWithNoTimeout.itcount() + 1 );
-var freshItCount = shardColl.find().itcount();
-assert.eq( freshItCount, cursorWithNoTimeout.itcount() + 1 );
+assert.eq( shardColl.count(), cursorWithNoTimeout.itcount() + 1 );
st.stop();