summaryrefslogtreecommitdiff
path: root/jstests/parallel/insert.js
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2010-01-04 17:03:34 -0800
committerAaron <aaron@10gen.com>2010-01-04 17:03:34 -0800
commit35d800321b1b87bcd940d07aed2eeaae0c072468 (patch)
tree4c3172c9ff9559ea705f295a67e38039e7fabcd3 /jstests/parallel/insert.js
parent5864c4a8dbfd7cb705805b72702084b4922e8d8f (diff)
downloadmongo-35d800321b1b87bcd940d07aed2eeaae0c072468.tar.gz
SERVER-470 make randomization more determiniztic (wrt seed) in insert test
Diffstat (limited to 'jstests/parallel/insert.js')
-rw-r--r--jstests/parallel/insert.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/jstests/parallel/insert.js b/jstests/parallel/insert.js
index eea0d9f818b..b82c8dc3505 100644
--- a/jstests/parallel/insert.js
+++ b/jstests/parallel/insert.js
@@ -4,21 +4,24 @@ f = db.jstests_parallel_insert;
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 :(
+seed = new Date().getTime();
+print( "random seed: " + seed );
+srand( seed );
expTimeout = function( mean ) {
- return -Math.log( Math.random() ) * mean;
+ return -Math.log( rand() ) * mean;
}
-test = function( mean, me ) {
+test = function() {
+ args = argumentsToArray( arguments );
+ var me = args.shift();
var m = new Mongo( db.getMongo().host );
var t = m.getDB( "test" ).jstests_parallel_insert;
- for( var i = 0; i < 1000; ++i ) {
- sleep( expTimeout( mean ) );
+ for( var i in args ) {
+ sleep( args[ i ] );
if ( i % 50 == 0 ) {
assert.eq( i, t.count( { who:me } ) );
- print( me + " " + i );
+// print( me + " " + i );
}
t.save( { i:i, who:me } );
}
@@ -26,7 +29,11 @@ test = function( mean, me ) {
argvs = new Array();
for( i = 0; i < 10; ++i ) {
- argvs.push( [ Math.random() * 20, i ] );
+ argvs.push( [ i ] );
+ var mean = rand() * 20;
+ for( j = 0; j < 1000; ++j ) {
+ argvs[ argvs.length - 1 ].push( expTimeout( mean ) );
+ }
}
assert.parallelTests( test, argvs, "one or more tests failed" );