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 | |
parent | 3699192679c7aef16068d32f309c1df387a79a9e (diff) | |
download | mongo-ad6c3d4132ab83dfe5a2df5f13725e469f6499e9.tar.gz |
SERVER-470 add runParallelTests helper, improve insert test
Diffstat (limited to 'jstests/parallel')
-rw-r--r-- | jstests/parallel/insert.js (renamed from jstests/parallel/basic.js) | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/jstests/parallel/basic.js b/jstests/parallel/insert.js index c75044453aa..cc3e8c8281f 100644 --- a/jstests/parallel/basic.js +++ b/jstests/parallel/insert.js @@ -1,3 +1,5 @@ +// perform inserts in parallel from several clients + f = db.jstests_parallel_basic; f.drop(); f.ensureIndex( {me:1} ); @@ -9,34 +11,24 @@ expTimeout = function( mean ) { return -Math.log( Math.random() ) * mean; } -failed = false; - 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 ) { - try { - assert.eq( i, t.count( { who:me } ) ); - } catch ( e ) { - failed = true; - throw e; - } + assert.eq( i, t.count( { who:me } ) ); print( me + " " + i ); } - t.insert( { i:i, who:me } ); + t.save( { i:i, who:me } ); } } -runners = new Array(); +argvs = Array(); for( i = 0; i < 10; ++i ) { - runners.push( fork( test, Math.random() * 20, i ) ); + argvs.push( [ Math.random() * 20, i ] ); } -runners.forEach( function( x ) { x.start() } ); -runners.forEach( function( x ) { x.join() } ); - -assert( !failed, "one or more threads failed" ); +runParallelTests( test, argvs, "one or more tests failed" ); assert( f.validate().valid ); |