Skip to content

Commit

Permalink
parallel repl test
Browse files Browse the repository at this point in the history
  • Loading branch information
astaple committed Mar 23, 2010
1 parent b3ee79e commit f6ea3d7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
55 changes: 55 additions & 0 deletions jstests/parallel/repl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// test all operations in parallel

baseName = "parallel_repl"

rt = new ReplTest( baseName );

m = rt.start( true );
s = rt.start( false );

db = m.getDB( "test" );

Random.setRandomSeed();

t = new ParallelTester();

for( id = 0; id < 10; ++id ) {
var g = new EventGenerator( id, baseName, Random.randInt( 20 ) );
for( var j = 0; j < 1000; ++j ) {
var op = Random.randInt( 3 );
switch( op ) {
case 0: // insert
g.addInsert( { _id:Random.randInt( 1000 ) } );
break;
case 1: // remove
g.addRemove( { _id:Random.randInt( 1000 ) } );
break;
case 2: // update
g.addUpdate( {_id:{$lt:1000}}, {a:{$inc:5}} );
break;
default:
assert( false, "Invalid op code" );
}
}
t.add( EventGenerator.dispatch, g.getEvents() );
}

var g = new EventGenerator( id, baseName, Random.randInt( 5 ) );
for( var j = 1000; j < 3000; ++j ) {
g.addCheckCount( j - 1000, { _id: {$gte:1000} }, j % 100 == 0, j % 500 == 0 );
g.addInsert( {_id:j} );
}
t.add( EventGenerator.dispatch, g.getEvents() );

t.run( "one or more tests failed" );

assert( m.getDB( "test" )[ baseName ].validate().valid );
assert( s.getDB( "test" )[ baseName ].validate().valid );

assert.soon( function() {
mh = m.getDB( "test" ).runCommand( "dbhash" );
// printjson( mh );
sh = s.getDB( "test" ).runCommand( "dbhash" );
// printjson( sh );
return mh.md5 == sh.md5;
} );
2 changes: 2 additions & 0 deletions mongo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@
93BDCE401157E7280097FE87 /* repl10.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl10.js; sourceTree = "<group>"; };
93BDCE411157E7280097FE87 /* repl11.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl11.js; sourceTree = "<group>"; };
93BDCE92115817210097FE87 /* pair7.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = pair7.js; sourceTree = "<group>"; };
93BDCEB9115830CB0097FE87 /* repl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl.js; sourceTree = "<group>"; };
93BFA0E311330A8C0045D084 /* not2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = not2.js; sourceTree = "<group>"; };
93C38E940FA66622007D6E4A /* basictests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = basictests.cpp; sourceTree = "<group>"; };
93C8E6FE11457D9000F28017 /* master1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = master1.js; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1273,6 +1274,7 @@
93F0956F10E165E50053380C /* parallel */ = {
isa = PBXGroup;
children = (
93BDCEB9115830CB0097FE87 /* repl.js */,
93BCE5A610F3FB5200FA139B /* basicPlus.js */,
93BCE5A510F3F8E900FA139B /* manyclients.js */,
93BCE4B510F3C8DB00FA139B /* allops.js */,
Expand Down

0 comments on commit f6ea3d7

Please sign in to comment.