diff options
author | Mathias Stearn <mathias@10gen.com> | 2014-03-27 16:15:09 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2014-03-27 17:35:16 -0400 |
commit | d0a1e84ab2fa1b6aa699721b5cb9a4f8d0bf3692 (patch) | |
tree | 7a1ffc91cb6cb176c1e367ea7641ab05032c862c /jstests/noPassthrough/cursor_timeout.js | |
parent | 719134aa7985c0a697f199fc78e323d04e3a65ad (diff) | |
download | mongo-d0a1e84ab2fa1b6aa699721b5cb9a4f8d0bf3692.tar.gz |
SERVER-13391 Rename slowNightly -> noPassthroughWithMongod and slowWeekly -> noPassthrough
This better represents their purpose and the difference between them.
Diffstat (limited to 'jstests/noPassthrough/cursor_timeout.js')
-rw-r--r-- | jstests/noPassthrough/cursor_timeout.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/jstests/noPassthrough/cursor_timeout.js b/jstests/noPassthrough/cursor_timeout.js new file mode 100644 index 00000000000..3e80e6c6fa7 --- /dev/null +++ b/jstests/noPassthrough/cursor_timeout.js @@ -0,0 +1,64 @@ +var st = new ShardingTest({ shards: 2, other: { chunkSize: 1 }}); +st.stopBalancer(); + +var adminDB = st.admin; +var configDB = st.config; +var coll = st.s.getDB( 'test' ).user; + +adminDB.runCommand({ enableSharding: coll.getDB().getName() }); +adminDB.runCommand({ shardCollection: coll.getFullName(), key: { x: 1 }}); + +var data = 'c'; +for( var x = 0; x < 18; x++ ){ + data += data; +} + +for( x = 0; x < 200; x++ ){ + coll.insert({ x: x, v: data }); +} + +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 res = adminDB.runCommand( cmd ); + +jsTest.log( 'move result: ' + tojson( res )); + +var shardedCursorWithTimeout = coll.find(); +var shardedCursorWithNoTimeout = coll.find(); +shardedCursorWithNoTimeout.addOption( DBQuery.Option.noTimeout ); + +// Query directly to mongod +var shardHost = configDB.shards.findOne({ _id: chunkOwner }).host; +var mongod = new Mongo( shardHost ); +var shardColl = mongod.getCollection( coll.getFullName() ); + +var cursorWithTimeout = shardColl.find(); +var cursorWithNoTimeout = shardColl.find(); +cursorWithNoTimeout.addOption( DBQuery.Option.noTimeout ); + +shardedCursorWithTimeout.next(); +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 ); + +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 ); + +var freshItCount = shardColl.find().itcount(); +assert.eq( freshItCount, cursorWithNoTimeout.itcount() + 1 ); + +st.stop(); + |