diff options
author | Aaron <aaron@10gen.com> | 2009-12-28 12:03:47 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-12-28 12:03:47 -0800 |
commit | 3699192679c7aef16068d32f309c1df387a79a9e (patch) | |
tree | 1cbac04b7e178f2dee377700f9a88399680c8fa4 /jstests/parallel/basic.js | |
parent | bffb7fd6e18c7f8ac34676600eedbbe8fa791777 (diff) | |
download | mongo-3699192679c7aef16068d32f309c1df387a79a9e.tar.gz |
SERVER-470 improve basic test
Diffstat (limited to 'jstests/parallel/basic.js')
-rw-r--r-- | jstests/parallel/basic.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/jstests/parallel/basic.js b/jstests/parallel/basic.js index eb298db9a9a..c75044453aa 100644 --- a/jstests/parallel/basic.js +++ b/jstests/parallel/basic.js @@ -3,19 +3,26 @@ 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(). +// behavior. Seems like that's impossible using Math.random(), though :( 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 ) { - assert.eq( i, t.count( { who:me } ) ); + try { + assert.eq( i, t.count( { who:me } ) ); + } catch ( e ) { + failed = true; + throw e; + } print( me + " " + i ); } t.insert( { i:i, who:me } ); @@ -24,9 +31,12 @@ test = function( mean, me ) { runners = new Array(); for( i = 0; i < 10; ++i ) { - runners.push( fork( test, Math.random() * 40, i ) ); + runners.push( fork( test, Math.random() * 20, i ) ); } runners.forEach( function( x ) { x.start() } ); runners.forEach( function( x ) { x.join() } ); +assert( !failed, "one or more threads failed" ); + +assert( f.validate().valid ); |