diff options
Diffstat (limited to 'jstests/noPassthroughWithMongod/sharding_balance4.js')
-rw-r--r-- | jstests/noPassthroughWithMongod/sharding_balance4.js | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/jstests/noPassthroughWithMongod/sharding_balance4.js b/jstests/noPassthroughWithMongod/sharding_balance4.js index f1c27afa0bb..c2a3d744964 100644 --- a/jstests/noPassthroughWithMongod/sharding_balance4.js +++ b/jstests/noPassthroughWithMongod/sharding_balance4.js @@ -35,12 +35,12 @@ counts = {} // -function doUpdate( includeString, optionalId ){ +function doUpdate( bulk, includeString, optionalId ){ var up = { $inc : { x : 1 } } if ( includeString ) up["$set"] = { s : bigString }; var myid = optionalId == undefined ? Random.randInt( N ) : optionalId - db.foo.update( { _id : myid } , up , true ); + bulk.find({ _id : myid }).upsert().update( up ); counts[myid] = ( counts[myid] ? counts[myid] : 0 ) + 1; return myid; @@ -48,14 +48,15 @@ function doUpdate( includeString, optionalId ){ // Initially update all documents from 1 to N, otherwise later checks can fail because no document // previously existed +var bulk = db.foo.initializeUnorderedBulkOp(); for ( i = 0; i < N; i++ ){ - doUpdate( true, i ) + doUpdate( bulk, true, i ); } for ( i=0; i<N*9; i++ ){ - doUpdate( false ) + doUpdate( bulk, false ); } -db.getLastError(); +assert.writeOK(bulk.execute()); for ( var i=0; i<50; i++ ){ s.printChunks( "test.foo" ) @@ -109,25 +110,15 @@ function check( msg , dontAssert ){ function diff1(){ jsTest.log("Running diff1...") - - var myid = doUpdate( false ) - var le = db.getLastErrorCmd(); - - if ( le.err ) - print( "ELIOT ELIOT : " + tojson( le ) + "\t" + myid ); - - if ( ! le.updatedExisting || le.n != 1 ) { - print( "going to assert for id: " + myid + " correct count is: " + counts[myid] + " db says count is: " + tojson(db.foo.findOne( { _id : myid } )) ); - } - - assert( le.updatedExisting , "GLE diff myid: " + myid + " 1: " + tojson(le) ) - assert.eq( 1 , le.n , "GLE diff myid: " + myid + " 2: " + tojson(le) ) + bulk = db.foo.initializeUnorderedBulkOp(); + var myid = doUpdate( bulk, false ); + var res = assert.writeOK(bulk.execute()); - if ( Math.random() > .99 ){ - db.getLastError() - check( "random late check" ); // SERVER-1430 - } + assert.eq( 1, res.nModified, + "diff myid: " + myid + " 2: " + res.toString() + "\n" + + " correct count is: " + counts[myid] + + " db says count is: " + tojson(db.foo.findOne({ _id: myid })) ); var x = s.chunkCounts( "foo" ) if ( Math.random() > .999 ) |