Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 192dc4f79afa0626aa9cf1ff819d00891acd7e5b 2 parents 59488fe + 4912b40
Dwight Merriman authored March 22, 2010
7  db/dbcommands.cpp
@@ -1188,12 +1188,11 @@ namespace mongo {
1188 1188
             string toNs = string( realDbName ) + "." + to;
1189 1189
             NamespaceDetails *nsd = nsdetails( fromNs.c_str() );
1190 1190
             massert( 10301 ,  "source collection " + fromNs + " does not exist", nsd );
1191  
-            long long excessSize = nsd->datasize - size * 2;
  1191
+            long long excessSize = nsd->datasize - size * 2; // datasize and extentSize can't be compared exactly, so add some padding to 'size'
1192 1192
             DiskLoc extent = nsd->firstExtent;
1193  
-            for( ; excessSize > 0 && extent != nsd->lastExtent; extent = extent.ext()->xnext ) {
  1193
+            for( ; excessSize > extent.ext()->length && extent != nsd->lastExtent; extent = extent.ext()->xnext ) {
1194 1194
                 excessSize -= extent.ext()->length;
1195  
-                if ( excessSize > 0 )
1196  
-                    log( 2 ) << "cloneCollectionAsCapped skipping extent of size " << extent.ext()->length << endl;
  1195
+                log( 2 ) << "cloneCollectionAsCapped skipping extent of size " << extent.ext()->length << endl;
1197 1196
                 log( 6 ) << "excessSize: " << excessSize << endl;
1198 1197
             }
1199 1198
             DiskLoc startLoc = extent.ext()->firstRecord;
60  jstests/repl/repl11.js
... ...
@@ -0,0 +1,60 @@
  1
+// Test repl with auth enabled
  2
+
  3
+var baseName = "jstests_repl11test";
  4
+
  5
+setAdmin = function( n ) {
  6
+    n.getDB( "admin" ).addUser( "super", "super" );
  7
+    n.getDB( "local" ).addUser( "repl", "foo" );
  8
+    n.getDB( "local" ).system.users.findOne();
  9
+}
  10
+
  11
+auth = function( n ) {
  12
+    return n.getDB( baseName ).auth( "test", "test" );
  13
+}
  14
+
  15
+// What if preexisting data on master and already set up db on slave for login?
  16
+doTest = function( signal ) {
  17
+
  18
+    rt = new ReplTest( baseName );
  19
+    
  20
+    m = rt.start( true, {}, false, true );
  21
+    m.getDB( baseName ).addUser( "test", "test" );
  22
+    setAdmin( m );
  23
+    rt.stop( true );
  24
+    
  25
+    s = rt.start( false, {}, false, true );
  26
+    setAdmin( s );
  27
+    rt.stop( false );
  28
+    
  29
+    m = rt.start( true, { auth:null }, true );
  30
+    auth( m );
  31
+    s = rt.start( false, { auth:null }, true );
  32
+    assert.soon( function() { return auth( s ); } );
  33
+    
  34
+    ma = m.getDB( baseName ).a;    
  35
+    ma.save( {} );
  36
+    sa = s.getDB( baseName ).a;
  37
+    assert.soon( function() { return 1 == sa.count(); } );
  38
+    
  39
+    rt.stop( false, signal );
  40
+    
  41
+    ma.save( {} );
  42
+    s = rt.start( false, { auth:null }, true );
  43
+    assert.soon( function() { return auth( s ); } );
  44
+    sa = s.getDB( baseName ).a;
  45
+    assert.soon( function() { return 2 == sa.count(); } );
  46
+    
  47
+    ma.save( {a:1} );
  48
+    assert.soon( function() { return 1 == sa.count( {a:1} ); } );
  49
+    
  50
+    ma.update( {a:1}, {b:2} );
  51
+    assert.soon( function() { return 1 == sa.count( {b:2} ); } );
  52
+    
  53
+    ma.remove( {b:2} );
  54
+    assert.soon( function() { return 0 == sa.count( {b:2} ); } );
  55
+    
  56
+    rt.stop();
  57
+}
  58
+
  59
+doTest( 15 ); // SIGTERM
  60
+doTest( 9 );  // SIGKILL
6  mongo.xcodeproj/project.pbxproj
@@ -471,7 +471,6 @@
471 471
 		93B4A82A0F1C0256000C862C /* pdfiletests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pdfiletests.cpp; sourceTree = "<group>"; };
472 472
 		93B9F5A7112B12440066ECD2 /* slavefromsnapshot.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = slavefromsnapshot.js; sourceTree = "<group>"; };
473 473
 		93B9F671112B3AD40066ECD2 /* copyauth.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = copyauth.js; path = auth/copyauth.js; sourceTree = "<group>"; };
474  
-		93B9F769112B6BE00066ECD2 /* slavefromsnapshot.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = slavefromsnapshot.js; sourceTree = "<group>"; };
475 474
 		93B9F76A112B6C020066ECD2 /* snapshot1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = snapshot1.js; sourceTree = "<group>"; };
476 475
 		93B9F76B112B6C1D0066ECD2 /* snapshot2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = snapshot2.js; sourceTree = "<group>"; };
477 476
 		93B9F7E6112B98710066ECD2 /* snapshot3.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = snapshot3.js; sourceTree = "<group>"; };
@@ -500,6 +499,8 @@
500 499
 		93BCE4B510F3C8DB00FA139B /* allops.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = allops.js; sourceTree = "<group>"; };
501 500
 		93BCE5A510F3F8E900FA139B /* manyclients.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = manyclients.js; sourceTree = "<group>"; };
502 501
 		93BCE5A610F3FB5200FA139B /* basicPlus.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = basicPlus.js; sourceTree = "<group>"; };
  502
+		93BDCE401157E7280097FE87 /* repl10.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl10.js; sourceTree = "<group>"; };
  503
+		93BDCE411157E7280097FE87 /* repl11.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl11.js; sourceTree = "<group>"; };
503 504
 		93BFA0E311330A8C0045D084 /* not2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = not2.js; sourceTree = "<group>"; };
504 505
 		93C38E940FA66622007D6E4A /* basictests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = basictests.cpp; sourceTree = "<group>"; };
505 506
 		93C8E6FE11457D9000F28017 /* master1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = master1.js; sourceTree = "<group>"; };
@@ -1059,11 +1060,12 @@
1059 1060
 		934BEC5010DFFA9600178102 /* repl */ = {
1060 1061
 			isa = PBXGroup;
1061 1062
 			children = (
  1063
+				93BDCE401157E7280097FE87 /* repl10.js */,
  1064
+				93BDCE411157E7280097FE87 /* repl11.js */,
1062 1065
 				93C8E6FE11457D9000F28017 /* master1.js */,
1063 1066
 				93B9F7E6112B98710066ECD2 /* snapshot3.js */,
1064 1067
 				93B9F76B112B6C1D0066ECD2 /* snapshot2.js */,
1065 1068
 				93B9F76A112B6C020066ECD2 /* snapshot1.js */,
1066  
-				93B9F769112B6BE00066ECD2 /* slavefromsnapshot.js */,
1067 1069
 				934BEC5110DFFA9600178102 /* basic1.js */,
1068 1070
 				934BEC5210DFFA9600178102 /* pair1.js */,
1069 1071
 				934BEC5310DFFA9600178102 /* pair2.js */,
22  shell/servers.js
@@ -593,7 +593,7 @@ ReplTest.prototype.getPath = function( master ){
593 593
 }
594 594
 
595 595
 
596  
-ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
  596
+ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst, norepl ){
597 597
 
598 598
     if ( ! extra )
599 599
         extra = {};
@@ -613,13 +613,15 @@ ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
613 613
     a.push( this.getPath( master ) );
614 614
     
615 615
 
616  
-    if ( master ){
617  
-        a.push( "--master" );
618  
-    }
619  
-    else {
620  
-        a.push( "--slave" );
621  
-        a.push( "--source" );
622  
-        a.push( "127.0.0.1:" + this.ports[0] );
  616
+    if ( !norepl ) {
  617
+        if ( master ){
  618
+            a.push( "--master" );
  619
+        }
  620
+        else {
  621
+            a.push( "--slave" );
  622
+            a.push( "--source" );
  623
+            a.push( "127.0.0.1:" + this.ports[0] );
  624
+        }
623 625
     }
624 626
     
625 627
     for ( var k in extra ){
@@ -632,10 +634,10 @@ ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst ){
632 634
     return a;
633 635
 }
634 636
 
635  
-ReplTest.prototype.start = function( master , options , restart ){
  637
+ReplTest.prototype.start = function( master , options , restart, norepl ){
636 638
     var lockFile = this.getPath( master ) + "/mongod.lock";
637 639
     removeFile( lockFile );
638  
-    var o = this.getOptions( master , options , restart );
  640
+    var o = this.getOptions( master , options , restart, norepl );
639 641
     if ( restart )
640 642
         return startMongoProgram.apply( null , o );
641 643
     else

0 notes on commit 192dc4f

Please sign in to comment.
Something went wrong with that request. Please try again.