summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-12-23 16:12:11 -0500
committerEliot Horowitz <eliot@10gen.com>2009-12-23 16:12:11 -0500
commit66f302878aabe48a5b6a2c0cd496a3b258403171 (patch)
tree283f60e4227788b774587db7f9241207eb67df33 /jstests
parent9a315ce29068d4739f6b08eb20d0ba0fe66590af (diff)
parentc7587eac0b2d5e816c52dd29bc784684aababc47 (diff)
downloadmongo-66f302878aabe48a5b6a2c0cd496a3b258403171.tar.gz
Merge branch 'master' of github.com:mongodb/mongo
Diffstat (limited to 'jstests')
-rw-r--r--jstests/basic1.js4
-rw-r--r--jstests/parallel/basic.js32
-rw-r--r--jstests/parallel/shellfork.js22
-rw-r--r--jstests/type1.js2
-rw-r--r--jstests/where2.js2
5 files changed, 60 insertions, 2 deletions
diff --git a/jstests/basic1.js b/jstests/basic1.js
index ecbb0c37941..e5fa577f0b2 100644
--- a/jstests/basic1.js
+++ b/jstests/basic1.js
@@ -15,3 +15,7 @@ t.save( o );
assert.eq( 2 , t.findOne().a , "second" );
assert(t.validate().valid);
+
+// not a very good test of currentOp, but tests that it at least
+// is sort of there:
+assert( db.currentOp().inprog != null );
diff --git a/jstests/parallel/basic.js b/jstests/parallel/basic.js
new file mode 100644
index 00000000000..eb298db9a9a
--- /dev/null
+++ b/jstests/parallel/basic.js
@@ -0,0 +1,32 @@
+f = db.jstests_parallel_basic;
+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().
+
+expTimeout = function( mean ) {
+ return -Math.log( Math.random() ) * mean;
+}
+
+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 } ) );
+ print( me + " " + i );
+ }
+ t.insert( { i:i, who:me } );
+ }
+}
+
+runners = new Array();
+for( i = 0; i < 10; ++i ) {
+ runners.push( fork( test, Math.random() * 40, i ) );
+}
+
+runners.forEach( function( x ) { x.start() } );
+runners.forEach( function( x ) { x.join() } );
+
diff --git a/jstests/parallel/shellfork.js b/jstests/parallel/shellfork.js
new file mode 100644
index 00000000000..27379506ec3
--- /dev/null
+++ b/jstests/parallel/shellfork.js
@@ -0,0 +1,22 @@
+a = fork( function( a, b ) { return a / b; }, 10, 2 );
+a.start();
+b = fork( function( a, b, c ) { return a + b + c; }, 18, " is a ", "multiple of 3" );
+makeFunny = function( text ) {
+ return text + " ha ha!";
+}
+c = fork( makeFunny, "paisley" );
+c.start();
+b.start();
+b.join();
+assert.eq( 5, a.returnData() );
+assert.eq( "18 is a multiple of 3", b.returnData() );
+assert.eq( "paisley ha ha!", c.returnData() );
+
+z = fork( function( a ) {
+ var y = fork( function( a ) {
+ return a + 1; }, 5 );
+ y.start();
+ return y.returnData() + a;
+ }, 1 );
+z.start();
+assert.eq( 7, z.returnData() );
diff --git a/jstests/type1.js b/jstests/type1.js
index b9fb94f0524..94385fa5bc2 100644
--- a/jstests/type1.js
+++ b/jstests/type1.js
@@ -2,7 +2,7 @@
t = db.type1;
t.drop();
-t.save( { x : 1 } );
+t.save( { x : 1.1 } );
t.save( { x : "3" } );
t.save( { x : "asd" } );
t.save( { x : "foo" } );
diff --git a/jstests/where2.js b/jstests/where2.js
index ae7addb4402..9262b3076b3 100644
--- a/jstests/where2.js
+++ b/jstests/where2.js
@@ -1,5 +1,5 @@
-t = db.getCollection( "where1" );
+t = db.getCollection( "where2" );
t.drop();
t.save( { a : 1 } );