diff options
author | David Storch <david.storch@10gen.com> | 2014-05-06 19:00:56 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2014-05-06 19:00:56 -0400 |
commit | 72380726608df663a85bee24d69a20ed2ca8287d (patch) | |
tree | 735b7724ddc814fdf385d754bd7921975b5de491 /jstests/repl | |
parent | 3061ab54eb2cc642a279becfca0b93f5e17db117 (diff) | |
download | mongo-72380726608df663a85bee24d69a20ed2ca8287d.tar.gz |
Revert "SERVER-13741 Migrate remaining tests to use write commands"
This reverts commit 87dc3ae516e1d12a632dc604710661e38ed7b3dd.
Diffstat (limited to 'jstests/repl')
-rw-r--r-- | jstests/repl/basic1.js | 43 | ||||
-rw-r--r-- | jstests/repl/block1.js | 3 | ||||
-rw-r--r-- | jstests/repl/block2.js | 25 | ||||
-rw-r--r-- | jstests/repl/drop_dups.js | 24 | ||||
-rw-r--r-- | jstests/repl/master1.js | 4 | ||||
-rw-r--r-- | jstests/repl/mastermaster1.js | 55 | ||||
-rw-r--r-- | jstests/repl/mod_move.js | 37 | ||||
-rw-r--r-- | jstests/repl/repl12.js | 1 | ||||
-rw-r--r-- | jstests/repl/repl13.js | 13 | ||||
-rw-r--r-- | jstests/repl/repl17.js | 1 | ||||
-rw-r--r-- | jstests/repl/repl19.js | 3 | ||||
-rw-r--r-- | jstests/repl/repl20.js | 3 | ||||
-rw-r--r-- | jstests/repl/repl21.js | 11 | ||||
-rw-r--r-- | jstests/repl/repl5.js | 4 |
14 files changed, 166 insertions, 61 deletions
diff --git a/jstests/repl/basic1.js b/jstests/repl/basic1.js index a2ec3ceb52f..ccde8874fbd 100644 --- a/jstests/repl/basic1.js +++ b/jstests/repl/basic1.js @@ -25,7 +25,7 @@ function check( note ){ sleep( 200 ); } lastOpLogEntry = m.getDB("local").oplog.$main.find({op:{$ne:"n"}}).sort({$natural:-1}).limit(-1).next(); - note = note + tojson(am.a.find().toArray()) + " != " + tojson(as.a.find().toArray()) + note = note + tojson(am.a.find().toArray()) + " != " + tojson(as.a.find().toArray()) + "last oplog:" + tojson(lastOpLogEntry); assert.eq( x.md5 , y.md5 , note ); } @@ -44,8 +44,9 @@ check( "C" ); // ----- check features ------- // map/reduce -assert.writeOK(am.mr.insert({ tags: [ "a" ]})); -assert.writeOK(am.mr.insert({ tags: [ "a", "b" ]})); +am.mr.insert( { tags : [ "a" ] } ) +am.mr.insert( { tags : [ "a" , "b" ] } ) +am.getLastError(); check( "mr setup" ); m = function(){ @@ -86,19 +87,22 @@ block(); checkNumCollections( "MR4" ); -var t = am.rpos; -var writeOption = { writeConcern: { w: 2, wtimeout: 3000 }}; -t.insert({ _id: 1, a: [{ n: "a", c: 1 }, { n: "b", c: 1 }, { n: "c", c: 1 }], b: [ 1, 2, 3 ]}, - writeOption); + +t = am.rpos; +t.insert( { _id : 1 , a : [ { n : "a" , c : 1 } , { n : "b" , c : 1 } , { n : "c" , c : 1 } ] , b : [ 1 , 2 , 3 ] } ) +block(); check( "after pos 1 " ); -t.update({ "a.n": "b" }, { $inc: { "a.$.c": 1 }}, writeOption); +t.update( { "a.n" : "b" } , { $inc : { "a.$.c" : 1 } } ) +block(); check( "after pos 2 " ); -t.update({ b: 2 }, { $inc: { "b.$": 1 }}, writeOption); +t.update( { "b" : 2 } , { $inc : { "b.$" : 1 } } ) +block(); check( "after pos 3 " ); -t.update({ b: 3 }, { $set: { "b.$": 17 }}, writeOption); +t.update( { "b" : 3} , { $set : { "b.$" : 17 } } ) +block(); check( "after pos 4 " ); @@ -108,17 +112,23 @@ printjson( as.rpos.findOne() ) //am.getSisterDB( "local" ).getCollection( "oplog.$main" ).find().limit(10).sort( { $natural : -1 } ).forEach( printjson ) t = am.b; -var updateOption = { upsert: true, multi: false, writeConcern: { w: 2, wtimeout: 3000 }}; -t.update({ _id: "fun" }, { $inc: { "a.b.c.x": 6743 }}, updateOption); +t.update( { "_id" : "fun"}, { $inc : {"a.b.c.x" : 6743} } , true, false) +block() check( "b 1" ); -t.update({ _id: "fun" }, { $inc: { "a.b.c.x": 5 }}, updateOption); +t.update( { "_id" : "fun"}, { $inc : {"a.b.c.x" : 5} } , true, false) +block() check( "b 2" ); -t.update({ _id: "fun" }, { $inc: { "a.b.c.x": 100, "a.b.c.y": 911 }}, updateOption); +t.update( { "_id" : "fun"}, { $inc : {"a.b.c.x" : 100, "a.b.c.y" : 911} } , true, false) +block() assert.eq( { _id : "fun" , a : { b : { c : { x : 6848 , y : 911 } } } } , as.b.findOne() , "b 3" ); +//printjson( t.findOne() ) +//printjson( as.b.findOne() ) +//am.getSisterDB( "local" ).getCollection( "oplog.$main" ).find().sort( { $natural : -1 } ).limit(3).forEach( printjson ) check( "b 4" ); + // lots of indexes am.lotOfIndexes.insert( { x : 1 } ) @@ -126,8 +136,10 @@ for ( i=0; i<200; i++ ){ var idx = {} idx["x"+i] = 1; am.lotOfIndexes.ensureIndex( idx ); + am.getLastError() } + assert.soon( function(){ return am.lotOfIndexes.getIndexes().length == as.lotOfIndexes.getIndexes().length; } , "lots of indexes a" ) assert.eq( am.lotOfIndexes.getIndexes().length , as.lotOfIndexes.getIndexes().length , "lots of indexes b" ) @@ -142,8 +154,9 @@ assert.soon( function(){ z = as.mu1.findOne(); printjson( z ); return friendlyEq // profiling - this sould be last am.setProfilingLevel( 2 ) -am.foo.insert({ x: 1 }, writeOption); +am.foo.insert( { x : 1 } ) am.foo.findOne() +block(); assert.eq( 2 , am.system.profile.count() , "P1" ) assert.eq( 0 , as.system.profile.count() , "P2" ) diff --git a/jstests/repl/block1.js b/jstests/repl/block1.js index ef36c3efb34..e358ba39705 100644 --- a/jstests/repl/block1.js +++ b/jstests/repl/block1.js @@ -11,7 +11,8 @@ tm = dbm.bar; ts = dbs.bar; for ( var i=0; i<1000; i++ ){ - tm.insert({ _id: i }, { writeConcern: { w: 2 }}); + tm.insert( { _id : i } ); + dbm.runCommand( { getlasterror : 1 , w : 2 } ) assert.eq( i + 1 , ts.count() , "A" + i ); assert.eq( i + 1 , tm.count() , "B" + i ); } diff --git a/jstests/repl/block2.js b/jstests/repl/block2.js index fc35b2774c4..64e52b8a94f 100644 --- a/jstests/repl/block2.js +++ b/jstests/repl/block2.js @@ -18,14 +18,33 @@ function check( msg ){ assert.eq( tm.count() , ts.count() , "check: " + msg ); } +function worked( w , wtimeout ){ + var gle = dbm.getLastError( w , wtimeout ); + if (gle != null) { + printjson(gle); + } + return gle == null; +} + check( "A" ); -assert.writeOK(tm.insert({ x: 1 }, { writeConcern: { w: 2 }})); -assert.writeOK(tm.insert({ x: 2 }, { writeConcern: { w: 2, wtimeout: 3000 }})); +tm.save( { x : 1 } ); +assert( worked( 2 ) , "B" ); + +tm.save( { x : 2 } ); +assert( worked( 2 , 3000 ) , "C" ) rt.stop( false ); -assert.writeError(tm.insert({ x: 3 }, { writeConcern: { w: 2, wtimeout: 3000 }})); +tm.save( { x : 3 } ) assert.eq( 3 , tm.count() , "D1" ); +assert( ! worked( 2 , 3000 ) , "D2" ) + +s = rt.start( false ) +setup(); +assert( worked( 2 , 30000 ) , "E" ) rt.stop(); + + + diff --git a/jstests/repl/drop_dups.js b/jstests/repl/drop_dups.js index bd3d2820108..1b151cfb71f 100644 --- a/jstests/repl/drop_dups.js +++ b/jstests/repl/drop_dups.js @@ -4,7 +4,9 @@ var rt = new ReplTest( "drop_dups" ); m = rt.start( true ); s = rt.start( false ); -var writeOption = { writeConcern: { w: 2, wtimeout: 3000 }}; +function block(){ + am.runCommand( { getlasterror : 1 , w : 2 , wtimeout : 3000 } ) +} am = m.getDB( "foo" ); as = s.getDB( "foo" ); @@ -14,18 +16,20 @@ function run( createInBackground ) { collName = "foo" + ( createInBackground ? "B" : "F" ); am[collName].drop(); - am.blah.insert({ x: 1 }, writeOption); + am.blah.insert( { x : 1 } ) assert.soon( function(){ + block(); return as.blah.findOne(); } ); - - var bulk = am[collName].initializeUnorderedBulkOp(); - for (var i = 0; i < 10; i++) { - bulk.insert({ _id: i, x: Math.floor( i / 2 ) }); + + + for ( i=0; i<10; i++ ) { + am[collName].insert( { _id : i , x : Math.floor( i / 2 ) } ) } - assert.writeOK(bulk.execute({ w: 2, wtimeout: 3000 })); - + + block(); + am.runCommand( { "godinsert" : collName , obj : { _id : 100 , x : 20 } } ); am.runCommand( { "godinsert" : collName , obj : { _id : 101 , x : 20 } } ); @@ -39,8 +43,8 @@ function run( createInBackground ) { } am[collName].ensureIndex( { x : 1 } , { unique : true , dropDups : true , background : createInBackground } ); - am.blah.insert({ x: 1 }, writeOption); - + am.blah.insert( { x : 1 } ) + block(); assert.eq( 2 , am[collName].getIndexKeys().length , "A1 : " + createInBackground ) if (!createInBackground) { assert.eq( 2 , as[collName].getIndexKeys().length , "A2 : " + createInBackground ) diff --git a/jstests/repl/master1.js b/jstests/repl/master1.js index 49b3416d202..93bfaf7862c 100644 --- a/jstests/repl/master1.js +++ b/jstests/repl/master1.js @@ -43,9 +43,11 @@ m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} ); rt.stop( true ); m = rt.start( true, null, true ); assert.eq( op.ts.i, lastop().ts.i ); +am().save( {} ); +// The above write should cause the server to terminate assert.throws(function() { - am().save( {} ); // triggers fassert because ofclock skew + am().findOne(); }); assert.neq(0, rt.stop( true )); // fasserted diff --git a/jstests/repl/mastermaster1.js b/jstests/repl/mastermaster1.js new file mode 100644 index 00000000000..97fdc149b56 --- /dev/null +++ b/jstests/repl/mastermaster1.js @@ -0,0 +1,55 @@ +// basic testing of master/master + + +ports = allocatePorts( 2 ) + +left = startMongodTest( ports[0] , "mastermaster1left" , false , { master : "" , slave : "" , source : "127.0.0.1:" + ports[1] } ) + +x = left.getDB( "admin" ).runCommand( "ismaster" ) +assert( x.ismaster , "left: " + tojson( x ) ) + +right = startMongodTest( ports[1] , "mastermaster1right" , false , { master : "" , slave : "" , source : "127.0.0.1:" + ports[0] } ) + +x = right.getDB( "admin" ).runCommand( "ismaster" ) +assert( x.ismaster , "right: " + tojson( x ) ) + +print( "check 1" ) + + +ldb = left.getDB( "test" ) +rdb = right.getDB( "test" ) + +print( "check 2" ) + +ldb.foo.insert( { _id : 1 , x : "eliot" } ) +result = ldb.runCommand( { getlasterror : 1 , w : 2 , wtimeout : 40000 } ); +printjson(result); +rdb.foo.insert( { _id : 2 , x : "sara" } ) +result = rdb.runCommand( { getlasterror : 1 , w : 2 , wtimeout : 40000 } ) +printjson(result); + +print( "check 3" ) + +print( "left" ) +ldb.foo.find().forEach( printjsononeline ) +print( "right" ) +rdb.foo.find().forEach( printjsononeline ) + +print( "oplog" ) + +rdb.getSisterDB( "local" ).getCollection( "oplog.$main" ).find().forEach( printjsononeline ) + +/* +assert.eq( 2 , ldb.foo.count() , "B1" ) +assert.eq( 2 , rdb.foo.count() , "B2" ) +*/ + +print( "going to stop everything" ) + +for ( var i=0; i<ports.length; i++ ){ + stopMongod( ports[i] ); +} + +print( "yay" ) + + diff --git a/jstests/repl/mod_move.js b/jstests/repl/mod_move.js index 66cc00b39e5..d39e747b833 100644 --- a/jstests/repl/mod_move.js +++ b/jstests/repl/mod_move.js @@ -6,6 +6,10 @@ var rt = new ReplTest( "mod_move" ); m = rt.start( true , { oplogSize : 50 } ); +function block(){ + am.runCommand( { getlasterror : 1 , w : 2 , wtimeout : 3000 } ) +} + am = m.getDB( "foo" ); function check( note ){ @@ -27,30 +31,39 @@ function check( note ){ BIG = 100000; N = BIG * 2; -var bulk = am.a.initializeUnorderedBulkOp(); -for (var i = 0; i < BIG; i++) { - bulk.insert({ _id: i, s: 1, x: 1 }); +s : "asdasdasdasdasdasdasdadasdadasdadasdasdas" + +for ( i=0; i<BIG; i++ ) { + am.a.insert( { _id : i , s : 1 , x : 1 } ) } -for (; i < N; i++) { - bulk.insert({ _id: i, s: 1 }); +for ( ; i<N; i++ ) { + am.a.insert( { _id : i , s : 1 } ) } -for (i = 0; i < BIG; i++) { - bulk.find({ _id: i }).remove(); +for ( i=0; i<BIG; i++ ) { + am.a.remove( { _id : i } ) } -assert.writeOK(bulk.execute()); +am.getLastError(); assert.eq( BIG , am.a.count() ) assert.eq( 1 , am.a.stats().paddingFactor , "A2" ) + // start slave s = rt.start( false ); as = s.getDB( "foo" ); -bulk = am.a.initializeUnorderedBulkOp(); -for (i = N - 1; i >= BIG; i--) { - bulk.find({ _id: i }).update({ $set: { x: 1 }}); +for ( i=N-1; i>=BIG; i-- ) { + am.a.update( { _id : i } , { $set : { x : 1 } } ) + if ( i == N ) { + am.getLastError() + assert.lt( as.a.count() , BIG , "B1" ) + print( "NOW : " + as.a.count() ) + } } -assert.writeOK(bulk.execute()); check( "B" ) rt.stop(); + + + + diff --git a/jstests/repl/repl12.js b/jstests/repl/repl12.js index 4bfaf17d5d7..8db4b75e7a9 100644 --- a/jstests/repl/repl12.js +++ b/jstests/repl/repl12.js @@ -17,6 +17,7 @@ for( i = 0; i < 3; ++i ) { m.getDB( a ).c.save( {} ); a += "a"; } +m.getDB(a).getLastError(); //print("\n\n\n DB NAMES MASTER:"); //printjson(m.getDBNames()); diff --git a/jstests/repl/repl13.js b/jstests/repl/repl13.js index 78daae24c32..e8a80966dab 100644 --- a/jstests/repl/repl13.js +++ b/jstests/repl/repl13.js @@ -12,11 +12,10 @@ m = rt.start( true ); mc = m.getDB( 'd' )[ 'c' ]; // Insert some documents with a:{} fields. -var bulk = mc.initializeUnorderedBulkOp(); -for(var i = 0; i < 100000; ++i) { - bulk.insert({ _id: i, a: {}}); +for( i = 0; i < 100000; ++i ) { + mc.save( {_id:i,a:{}} ); } -assert.writeOK(bulk.execute()); +m.getDB( 'd' ).getLastError(); s = rt.start( false ); sc = s.getDB( 'd' )[ 'c' ]; @@ -27,13 +26,11 @@ assert.soon( function() { debug( sc.count() ); return sc.count() > 0; } ); // Update documents that will be cloned last with the intent that an updated version will be cloned. // This may cause an assertion when an update that was successfully applied to the original version // of a document is replayed against an updated version of the same document. -bulk = mc.initializeUnorderedBulkOp(); for( i = 99999; i >= 90000; --i ) { // If the document is cloned as {a:1}, the {$set:{'a.b':1}} modifier will uassert. - bulk.find({ _id: i }).update({ $set: { 'a.b': 1 }}); - bulk.find({ _id: i }).update({ $set: { a: 1 }}); + mc.update( {_id:i}, {$set:{'a.b':1}} ); + mc.update( {_id:i}, {$set:{a:1}} ); } -assert.writeOK(bulk.execute()); // The initial sync completes and subsequent writes succeed, in spite of any assertions that occur // when the update operations above are replicated. diff --git a/jstests/repl/repl17.js b/jstests/repl/repl17.js index c7a7be35ffc..8011d974328 100644 --- a/jstests/repl/repl17.js +++ b/jstests/repl/repl17.js @@ -11,6 +11,7 @@ md = master.getDB( 'd' ); for( i = 0; i < 1000; ++i ) { md[ ''+i ].save( {} ); } +md.getLastError(); slave = rt.start( false ); sd = slave.getDB( 'd' ); diff --git a/jstests/repl/repl19.js b/jstests/repl/repl19.js index a655d522bae..71d4335014a 100644 --- a/jstests/repl/repl19.js +++ b/jstests/repl/repl19.js @@ -13,7 +13,8 @@ for( i = 0; i < 100000; ++i ) { } targetId = 1000*1000; -assert.writeOK(mc.insert({ _id: targetId, val: [ 1, 2, 3 ] })); +mc.insert( { _id:targetId, val:[ 1, 2, 3 ] } ); +master.getDB( 'd' ).getLastError(); slave = rt.start( false ); sc = slave.getDB( 'd' )[ 'c' ]; diff --git a/jstests/repl/repl20.js b/jstests/repl/repl20.js index c30ef8d6f3c..02e50f58f1f 100644 --- a/jstests/repl/repl20.js +++ b/jstests/repl/repl20.js @@ -13,7 +13,8 @@ for( i = 0; i < 100000; ++i ) { } targetId = 1000*1000; -assert.writeOK(mc.insert({ _id: targetId, val: [ 1 ] })); +mc.insert( { _id:targetId, val:[ 1 ] } ); +master.getDB( 'd' ).getLastError(); slave = rt.start( false ); sc = slave.getDB( 'd' )[ 'c' ]; diff --git a/jstests/repl/repl21.js b/jstests/repl/repl21.js index 87c0c7fdd02..a94a4b5b779 100644 --- a/jstests/repl/repl21.js +++ b/jstests/repl/repl21.js @@ -8,14 +8,13 @@ rt = new ReplTest( "repl21tests" ); master = rt.start( true ); mc = master.getDB( 'd' )[ 'c' ]; -var bulk = mc.initializeUnorderedBulkOp(); -for(var i = 0; i < 100000; ++i) { - bulk.insert({ _id: i, z: i }); +for( i = 0; i < 100000; ++i ) { + mc.insert( { _id:i, z:i } ); } targetId = 1000*1000; -bulk.insert({ _id: targetId, val: [ 1 ] }); -assert.writeOK(bulk.execute()); +mc.insert( { _id:targetId, val:[ 1 ] } ); +master.getDB( 'd' ).getLastError(); slave = rt.start( false ); sc = slave.getDB( 'd' )[ 'c' ]; @@ -37,4 +36,4 @@ assert.soon( function() { return sc.count( { _id:'sentinel' } ) > 0; } ); assert.eq( [ 1, 3 ], mc.findOne( { _id:targetId } ).val ); assert.eq( [ 1, 3 ], sc.findOne( { _id:targetId } ).val ); -} +}
\ No newline at end of file diff --git a/jstests/repl/repl5.js b/jstests/repl/repl5.js index aeba7eb1095..eda48496656 100644 --- a/jstests/repl/repl5.js +++ b/jstests/repl/repl5.js @@ -14,10 +14,8 @@ doTest = function(signal, extraOpts) { m = rt.start( true ); ma = m.getDB( "a" ).a; - var bulk = ma.initializeUnorderedBulkOp(); for( i = 0; i < 10000; ++i ) - bulk.insert({ i: i }); - assert.writeOK(bulk.execute()); + ma.save( { i:i } ); s = rt.start(false, extraOpts); soonCountAtLeast( "a", "a", 1 ); |