~ubuntu-branches/ubuntu/trusty/mongodb/trusty-proposed

« back to all changes in this revision

Viewing changes to jstests/parallel/allops.js

  • Committer: Bazaar Package Importer
  • Author(s): Antonin Kral
  • Date: 2010-01-29 19:48:45 UTC
  • Revision ID: james.westby@ubuntu.com-20100129194845-8wbmkf626fwcavc9
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// test all operations in parallel
 
2
 
 
3
f = db.jstests_parallel_allops;
 
4
f.drop();
 
5
 
 
6
Random.setRandomSeed();
 
7
 
 
8
t = new ParallelTester();
 
9
 
 
10
for( id = 0; id < 10; ++id ) {
 
11
    var g = new EventGenerator( id, "jstests_parallel_allops", Random.randInt( 20 ) );
 
12
    for( var j = 0; j < 1000; ++j ) {
 
13
        var op = Random.randInt( 3 );
 
14
        switch( op ) {
 
15
            case 0: // insert
 
16
                g.addInsert( { _id:Random.randInt( 1000 ) } );
 
17
                break;
 
18
            case 1: // remove
 
19
                g.addRemove( { _id:Random.randInt( 1000 ) } );
 
20
                break;
 
21
            case 2: // update
 
22
                g.addUpdate( {_id:{$lt:1000}}, { _id:Random.randInt( 1000 ) } );
 
23
                break;
 
24
            default:
 
25
                assert( false, "Invalid op code" );
 
26
        }
 
27
    }
 
28
    t.add( EventGenerator.dispatch, g.getEvents() );
 
29
}
 
30
 
 
31
var g = new EventGenerator( id, "jstests_parallel_allops", Random.randInt( 5 ) );
 
32
for( var j = 1000; j < 3000; ++j ) {
 
33
    g.addCheckCount( j - 1000, { _id: {$gte:1000} }, j % 100 == 0, j % 500 == 0 );
 
34
    g.addInsert( {_id:j} );
 
35
}
 
36
t.add( EventGenerator.dispatch, g.getEvents() );
 
37
 
 
38
t.run( "one or more tests failed" );
 
39
 
 
40
assert( f.validate().valid );