diff options
author | Greg Studer <greg@10gen.com> | 2012-12-27 13:53:05 -0500 |
---|---|---|
committer | Greg Studer <greg@10gen.com> | 2012-12-27 15:06:35 -0500 |
commit | c31da72e8ad5a9a40a03c5286637f58aa658e233 (patch) | |
tree | 442e08791afc8b3ef9397179e1645219b3c8fd9b /jstests | |
parent | 5baf992b906f440ce99f917d1d53767a303be7f9 (diff) | |
download | mongo-c31da72e8ad5a9a40a03c5286637f58aa658e233.tar.gz |
SERVER-8000 make sharding_balance4.js test deterministic
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/slowNightly/sharding_balance4.js | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/jstests/slowNightly/sharding_balance4.js b/jstests/slowNightly/sharding_balance4.js index 33db1db1da9..08e439e20c5 100644 --- a/jstests/slowNightly/sharding_balance4.js +++ b/jstests/slowNightly/sharding_balance4.js @@ -23,19 +23,37 @@ num = 0; counts = {} -function doUpdate( includeString ){ +// +// TODO: Rewrite to make much clearer. +// +// The core behavior of this test is to add a bunch of documents to a sharded collection, then +// incrementally update each document and make sure the counts in the document match our update +// counts while balancing occurs (doUpdate()). Every once and awhile we also check (check()) +// our counts via a query. +// +// If during a chunk migration an update is missed, we trigger an assertion and fail. +// + + +function doUpdate( includeString, optionalId ){ var up = { $inc : { x : 1 } } if ( includeString ) up["$set"] = { s : bigString }; - var myid = Random.randInt( N ) + var myid = optionalId == undefined ? Random.randInt( N ) : optionalId db.foo.update( { _id : myid } , up , true ); counts[myid] = ( counts[myid] ? counts[myid] : 0 ) + 1; return myid; } -for ( i=0; i<N*10; i++ ){ - doUpdate( true ) +// Initially update all documents from 1 to N, otherwise later checks can fail because no document +// previously existed +for ( i = 0; i < N; i++ ){ + doUpdate( true, i ) +} + +for ( i=0; i<N*9; i++ ){ + doUpdate( false ) } db.getLastError(); |