Permalink
Browse files

Merge branch 'master' of git@github.com:mongodb/mongo

  • Loading branch information...
dwight committed Mar 22, 2010
2 parents 59488fe + 4912b40 commit 192dc4f79afa0626aa9cf1ff819d00891acd7e5b
Showing with 79 additions and 16 deletions.
  1. +3 −4 db/dbcommands.cpp
  2. +60 −0 jstests/repl/repl11.js
  3. +4 −2 mongo.xcodeproj/project.pbxproj
  4. +12 −10 shell/servers.js
View
@@ -1188,12 +1188,11 @@ namespace mongo {
string toNs = string( realDbName ) + "." + to;
NamespaceDetails *nsd = nsdetails( fromNs.c_str() );
massert( 10301 , "source collection " + fromNs + " does not exist", nsd );
- long long excessSize = nsd->datasize - size * 2;
+ long long excessSize = nsd->datasize - size * 2; // datasize and extentSize can't be compared exactly, so add some padding to 'size'
DiskLoc extent = nsd->firstExtent;
- for( ; excessSize > 0 && extent != nsd->lastExtent; extent = extent.ext()->xnext ) {
+ for( ; excessSize > extent.ext()->length && extent != nsd->lastExtent; extent = extent.ext()->xnext ) {
excessSize -= extent.ext()->length;
- if ( excessSize > 0 )
- log( 2 ) << "cloneCollectionAsCapped skipping extent of size " << extent.ext()->length << endl;
+ log( 2 ) << "cloneCollectionAsCapped skipping extent of size " << extent.ext()->length << endl;
log( 6 ) << "excessSize: " << excessSize << endl;
}
DiskLoc startLoc = extent.ext()->firstRecord;
View
@@ -0,0 +1,60 @@
+// Test repl with auth enabled
+
+var baseName = "jstests_repl11test";
+
+setAdmin = function( n ) {
+ n.getDB( "admin" ).addUser( "super", "super" );
+ n.getDB( "local" ).addUser( "repl", "foo" );
+ n.getDB( "local" ).system.users.findOne();
+}
+
+auth = function( n ) {
+ return n.getDB( baseName ).auth( "test", "test" );
+}
+
+// What if preexisting data on master and already set up db on slave for login?
+doTest = function( signal ) {
+
+ rt = new ReplTest( baseName );
+
+ m = rt.start( true, {}, false, true );
+ m.getDB( baseName ).addUser( "test", "test" );
+ setAdmin( m );
+ rt.stop( true );
+
+ s = rt.start( false, {}, false, true );
+ setAdmin( s );
+ rt.stop( false );
+
+ m = rt.start( true, { auth:null }, true );
+ auth( m );
+ s = rt.start( false, { auth:null }, true );
+ assert.soon( function() { return auth( s ); } );
+
+ ma = m.getDB( baseName ).a;
+ ma.save( {} );
+ sa = s.getDB( baseName ).a;
+ assert.soon( function() { return 1 == sa.count(); } );
+
+ rt.stop( false, signal );
+
+ ma.save( {} );
+ s = rt.start( false, { auth:null }, true );
+ assert.soon( function() { return auth( s ); } );
+ sa = s.getDB( baseName ).a;
+ assert.soon( function() { return 2 == sa.count(); } );
+
+ ma.save( {a:1} );
+ assert.soon( function() { return 1 == sa.count( {a:1} ); } );
+
+ ma.update( {a:1}, {b:2} );
+ assert.soon( function() { return 1 == sa.count( {b:2} ); } );
+
+ ma.remove( {b:2} );
+ assert.soon( function() { return 0 == sa.count( {b:2} ); } );
+
+ rt.stop();
+}
+
+doTest( 15 ); // SIGTERM
+doTest( 9 ); // SIGKILL
@@ -471,7 +471,6 @@
93B4A82A0F1C0256000C862C /* pdfiletests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pdfiletests.cpp; sourceTree = "<group>"; };
93B9F5A7112B12440066ECD2 /* slavefromsnapshot.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = slavefromsnapshot.js; sourceTree = "<group>"; };
93B9F671112B3AD40066ECD2 /* copyauth.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = copyauth.js; path = auth/copyauth.js; sourceTree = "<group>"; };
- 93B9F769112B6BE00066ECD2 /* slavefromsnapshot.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = slavefromsnapshot.js; sourceTree = "<group>"; };
93B9F76A112B6C020066ECD2 /* snapshot1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = snapshot1.js; sourceTree = "<group>"; };
93B9F76B112B6C1D0066ECD2 /* snapshot2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = snapshot2.js; sourceTree = "<group>"; };
93B9F7E6112B98710066ECD2 /* snapshot3.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = snapshot3.js; sourceTree = "<group>"; };
@@ -500,6 +499,8 @@
93BCE4B510F3C8DB00FA139B /* allops.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = allops.js; sourceTree = "<group>"; };
93BCE5A510F3F8E900FA139B /* manyclients.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = manyclients.js; sourceTree = "<group>"; };
93BCE5A610F3FB5200FA139B /* basicPlus.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = basicPlus.js; sourceTree = "<group>"; };
+ 93BDCE401157E7280097FE87 /* repl10.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl10.js; sourceTree = "<group>"; };
+ 93BDCE411157E7280097FE87 /* repl11.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl11.js; sourceTree = "<group>"; };
93BFA0E311330A8C0045D084 /* not2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = not2.js; sourceTree = "<group>"; };
93C38E940FA66622007D6E4A /* basictests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = basictests.cpp; sourceTree = "<group>"; };
93C8E6FE11457D9000F28017 /* master1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = master1.js; sourceTree = "<group>"; };
@@ -1059,11 +1060,12 @@
934BEC5010DFFA9600178102 /* repl */ = {
isa = PBXGroup;
children = (
+ 93BDCE401157E7280097FE87 /* repl10.js */,
+ 93BDCE411157E7280097FE87 /* repl11.js */,
93C8E6FE11457D9000F28017 /* master1.js */,
93B9F7E6112B98710066ECD2 /* snapshot3.js */,
93B9F76B112B6C1D0066ECD2 /* snapshot2.js */,
93B9F76A112B6C020066ECD2 /* snapshot1.js */,
- 93B9F769112B6BE00066ECD2 /* slavefromsnapshot.js */,
934BEC5110DFFA9600178102 /* basic1.js */,
934BEC5210DFFA9600178102 /* pair1.js */,
934BEC5310DFFA9600178102 /* pair2.js */,
View
@@ -593,7 +593,7 @@ ReplTest.prototype.getPath = function( master ){
}
-ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
+ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst, norepl ){
if ( ! extra )
extra = {};
@@ -613,13 +613,15 @@ ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
a.push( this.getPath( master ) );
- if ( master ){
- a.push( "--master" );
- }
- else {
- a.push( "--slave" );
- a.push( "--source" );
- a.push( "127.0.0.1:" + this.ports[0] );
+ if ( !norepl ) {
+ if ( master ){
+ a.push( "--master" );
+ }
+ else {
+ a.push( "--slave" );
+ a.push( "--source" );
+ a.push( "127.0.0.1:" + this.ports[0] );
+ }
}
for ( var k in extra ){
@@ -632,10 +634,10 @@ ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
return a;
}
-ReplTest.prototype.start = function( master , options , restart ){
+ReplTest.prototype.start = function( master , options , restart, norepl ){
var lockFile = this.getPath( master ) + "/mongod.lock";
removeFile( lockFile );
- var o = this.getOptions( master , options , restart );
+ var o = this.getOptions( master , options , restart, norepl );
if ( restart )
return startMongoProgram.apply( null , o );
else

0 comments on commit 192dc4f

Please sign in to comment.