diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-03-08 17:08:37 -0500 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-03-08 17:26:32 -0500 |
commit | 730b0cd2f42b69e54c2178bf05858d13e099a274 (patch) | |
tree | 00b23be19e5b3c5e9223a38e900c58a06e0f76f5 /jstests/core/datasize2.js | |
parent | 5aa0caba3b411e1e5b5df2216808e0380389afab (diff) | |
download | mongo-730b0cd2f42b69e54c2178bf05858d13e099a274.tar.gz |
SERVER-21976 fixing mongos' routing of dataSize command to mongods: it was using the wrong database
Diffstat (limited to 'jstests/core/datasize2.js')
-rw-r--r-- | jstests/core/datasize2.js | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/jstests/core/datasize2.js b/jstests/core/datasize2.js index b189b361e44..4de0b88717a 100644 --- a/jstests/core/datasize2.js +++ b/jstests/core/datasize2.js @@ -1,27 +1,33 @@ +// +// Test dataSize command, when called on the same or different database +// than the collection being queried. +// -t = db.datasize2; -t.drop(); +(function() { +"use strict" -N = 1000; -for ( i=0; i<N; i++ ){ - t.insert( { _id : i , s : "asdasdasdasdasdasdasd" } ); -} - -c = { dataSize : "test.datasize2" , - "keyPattern" : { - "_id" : 1 - }, - "min" : { - "_id" : 0 - }, - "max" : { - "_id" : N - } - }; +var coll = db.foo; +var adminDB = db.getSiblingDB('admin'); +coll.drop(); +var N = 1000; +for (var i = 0; i < N; i++) { + coll.insert({_id: i, s: "asdasdasdasdasdasdasd"}); +} -assert.eq( N , db.runCommand( c ).numObjects , "A" ); +var dataSizeCommand = { "dataSize": "test.foo", + "keyPattern": { "_id" : 1 }, + "min": { "_id" : 0 }, + "max": { "_id" : N } }; -c.maxObjects = 100; -assert.eq( 101 , db.runCommand( c ).numObjects , "B" ); +assert.eq(N, db.runCommand(dataSizeCommand).numObjects, + "dataSize command on 'test.foo' failed when called on the 'test' DB."); +assert.eq(N, adminDB.runCommand(dataSizeCommand).numObjects, + "dataSize command on 'test.foo' failed when called on the 'admin' DB."); +dataSizeCommand.maxObjects = 100; +assert.eq(101, db.runCommand(dataSizeCommand).numObjects, + "dataSize command with max number of objects set failed on 'test' DB"); +assert.eq(101, db.runCommand(dataSizeCommand).numObjects, + "dataSize command with max number of objects set failed on 'admin' DB"); +})(); |