0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 09:06:21 +01:00

SERVER-258 group work with read only mode

This commit is contained in:
Aaron 2010-02-01 11:17:14 -08:00
parent 946d42e8e7
commit 53998ac7fc
2 changed files with 20 additions and 3 deletions

View File

@ -1136,6 +1136,7 @@ namespace mongo {
class GroupCommand : public Command {
public:
GroupCommand() : Command("group"){}
virtual bool readOnly() { return true; }
virtual bool slaveOk() { return true; }
virtual void help( stringstream &help ) const {
help << "see http://www.mongodb.org/display/DOCS/Aggregation";

View File

@ -3,8 +3,8 @@
port = allocatePorts( 1 )[ 0 ];
baseName = "jstests_auth_auth1";
m = startMongod( "--auth", "--port", port, "--dbpath", "/data/db/" + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" );
db = m.getDB( "test" );
//m = startMongod( "--auth", "--port", port, "--dbpath", "/data/db/" + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" );
//db = m.getDB( "test" );
t = db[ baseName ];
t.drop();
@ -27,9 +27,16 @@ assert.eq( 999, t.count() );
assert.eq( 999, t.find().toArray().length );
assert.eq( 999, db.eval( function() { return db[ "jstests_auth_auth1" ].count(); } ) );
db.eval( function() { db[ "jstests_auth_auth1" ].save( {i:1} ) } );
db.eval( function() { db[ "jstests_auth_auth1" ].save( {i:999} ) } );
assert.eq( 1000, db.eval( function() { return db[ "jstests_auth_auth1" ].count(); } ) );
var p = { key : { i : true } ,
reduce : function(obj,prev) { prev.count++; },
initial: { count: 0 }
};
assert.eq( 1000, t.group( p ).length );
assert( db.auth( "guest", "guest" ), "auth failed 2" );
assert.eq( 1000, t.count() );
@ -51,3 +58,12 @@ assert.eq( 1000, db.eval( function() { return db[ "jstests_auth_auth1" ].count()
assert.eq( 1000, db.eval( function() { return db[ "jstests_auth_auth1" ].find().toArray().length; } ) );
db.eval( function() { db[ "jstests_auth_auth1" ].save( {i:1} ) } );
assert.eq( 1000, db.eval( function() { return db[ "jstests_auth_auth1" ].count(); } ) );
assert.eq( 1000, t.group( p ).length );
//var p = { key : { i : true } ,
// reduce : function(obj,prev) { db.jstests_auth_auth1.save( {i:10000} ); prev.count++; },
//initial: { count: 0 }
//};
//
//assert.throws( t.group( p ) );