diff options
author | Aaron <aaron@10gen.com> | 2009-12-28 13:05:11 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-12-28 13:05:11 -0800 |
commit | ad6c3d4132ab83dfe5a2df5f13725e469f6499e9 (patch) | |
tree | 45e42c7f84e156b729d24ea688a7bd840efbd75d /jstests/parallel/insert.js | |
parent | 3699192679c7aef16068d32f309c1df387a79a9e (diff) | |
download | mongo-ad6c3d4132ab83dfe5a2df5f13725e469f6499e9.tar.gz |
SERVER-470 add runParallelTests helper, improve insert test
Diffstat (limited to 'jstests/parallel/insert.js')
-rw-r--r-- | jstests/parallel/insert.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/jstests/parallel/insert.js b/jstests/parallel/insert.js new file mode 100644 index 00000000000..cc3e8c8281f --- /dev/null +++ b/jstests/parallel/insert.js @@ -0,0 +1,34 @@ +// perform inserts in parallel from several clients + +f = db.jstests_parallel_basic; +f.drop(); +f.ensureIndex( {me:1} ); + +// would be nice to configure and log a random seed so we can reproduce +// behavior. Seems like that's impossible using Math.random(), though :( + +expTimeout = function( mean ) { + return -Math.log( Math.random() ) * mean; +} + +test = function( mean, me ) { + var m = new Mongo( db.getMongo().host ); + var t = m.getDB( "test" ).jstests_parallel_basic; + for( var i = 0; i < 1000; ++i ) { + sleep( expTimeout( mean ) ); + if ( i % 50 == 0 ) { + assert.eq( i, t.count( { who:me } ) ); + print( me + " " + i ); + } + t.save( { i:i, who:me } ); + } +} + +argvs = Array(); +for( i = 0; i < 10; ++i ) { + argvs.push( [ Math.random() * 20, i ] ); +} + +runParallelTests( test, argvs, "one or more tests failed" ); + +assert( f.validate().valid ); |