Skip to content

Commit 3d0bb9c

Browse files
author
kristina
committed
stress test
1 parent 3fb6836 commit 3d0bb9c

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
package com.mongodb.framework;
3+
4+
import java.util.*;
5+
import java.net.*;
6+
7+
import com.mongodb.*;
8+
import com.mongodb.util.*;
9+
10+
public class Stress1 {
11+
12+
public static void doStuff( DBCollection c, int count ) {
13+
DBObject obj = new BasicDBObject();
14+
obj.put( "id", count );
15+
DBObject x = c.findOne( obj );
16+
x.put( "subarray", "foo" + count );
17+
c.save( x );
18+
}
19+
20+
public static void main(String[] args)
21+
throws UnknownHostException {
22+
23+
Mongo m = new Mongo( new DBAddress( "127.0.0.1:27017/driver_test_framework" ) );
24+
DBCollection c = m.getCollection( "stress1" );
25+
26+
String blah = "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" +
27+
"lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" +
28+
"lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" +
29+
"lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" +
30+
"lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" +
31+
"lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas";
32+
33+
for( int i=0; i<50000; i++ ) {
34+
DBObject foo = new BasicDBObject();
35+
foo.put( "name", "asdf"+i );
36+
foo.put( "date", new Date() );
37+
foo.put( "id", i );
38+
foo.put( "blah", blah );
39+
c.save( foo );
40+
}
41+
42+
for( int count=0; count<10000; count++ ) {
43+
doStuff( c, count );
44+
}
45+
46+
DBObject idx = new BasicDBObject();
47+
idx.put( "date", 1 );
48+
c.ensureIndex( idx );
49+
}
50+
}

src/test/com/mongodb/framework/dispatch

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ elif [[ "$1" = "capped" ]]; then
1818
# java com.mongodb.framework.Circular
1919
elif [[ "$1" = "dbs" ]]; then
2020
java com.mongodb.framework.Dbs > $2
21+
elif [[ "$1" = "stress1" ]]; then
22+
java com.mongodb.framework.Stress1
2123
#elif [[ "$1" = "admin" ]]; then
2224
# java com.mongodb.framework.Admin > $2
2325
else

0 commit comments

Comments
 (0)