summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2010-03-22 17:02:45 -0400
committerDwight <dmerriman@gmail.com>2010-03-22 17:02:45 -0400
commit192dc4f79afa0626aa9cf1ff819d00891acd7e5b (patch)
treeaac5f222747396a821497e102cd69740a8f99b45
parent59488feffc96d2664c635ef7ea98d1c2e79819ae (diff)
parent4912b401063f65ec79ad585e3406ca51dfd7d501 (diff)
downloadmongo-192dc4f79afa0626aa9cf1ff819d00891acd7e5b.tar.gz
Merge branch 'master' of git@github.com:mongodb/mongo
-rw-r--r--db/dbcommands.cpp7
-rw-r--r--jstests/repl/repl11.js60
-rw-r--r--mongo.xcodeproj/project.pbxproj6
-rw-r--r--shell/servers.js22
4 files changed, 79 insertions, 16 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index a8d826dc682..6d1aa5a80eb 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -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;
diff --git a/jstests/repl/repl11.js b/jstests/repl/repl11.js
new file mode 100644
index 00000000000..9341f4a215d
--- /dev/null
+++ b/jstests/repl/repl11.js
@@ -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
diff --git a/mongo.xcodeproj/project.pbxproj b/mongo.xcodeproj/project.pbxproj
index c54e9ef9ad4..268f8ac65b6 100644
--- a/mongo.xcodeproj/project.pbxproj
+++ b/mongo.xcodeproj/project.pbxproj
@@ -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 */,
diff --git a/shell/servers.js b/shell/servers.js
index 79d01a4aaaf..f681263cf0e 100644
--- a/shell/servers.js
+++ b/shell/servers.js
@@ -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