summaryrefslogtreecommitdiff
path: root/jstests/slowWeekly
diff options
context:
space:
mode:
authorRichard Kreuter <richard@10gen.com>2010-08-02 16:52:00 -0400
committerRichard Kreuter <richard@10gen.com>2010-08-02 16:52:37 -0400
commit638973cfa5112518212acdb38cabe55e1c1c082e (patch)
treeb9abd44b8e7f93f4760ab6f9fcf92e33ca110ffe /jstests/slowWeekly
parentc625aa099d9404573ec47ae25cfd02230dfd8d88 (diff)
downloadmongo-638973cfa5112518212acdb38cabe55e1c1c082e.tar.gz
Move concurrency test to slowWeekly.
Diffstat (limited to 'jstests/slowWeekly')
-rw-r--r--jstests/slowWeekly/conc_update.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/jstests/slowWeekly/conc_update.js b/jstests/slowWeekly/conc_update.js
new file mode 100644
index 00000000000..299259f8224
--- /dev/null
+++ b/jstests/slowWeekly/conc_update.js
@@ -0,0 +1,46 @@
+db = db.getSisterDB("concurrency")
+db.dropDatabase();
+
+NRECORDS=5*1024*1024 // this needs to be relatively big so that
+ // the update() will take a while, but it could
+ // probably be smaller.
+
+print("loading "+NRECORDS+" documents (progress msg every 1024*1024 documents)")
+for (i=0; i<(NRECORDS); i++) {
+ db.conc.insert({x:i})
+ if ((i%(1024*1024))==0)
+ print("loaded " + i/(1024*1024) + " mibi-records")
+}
+
+print("making an index (this will take a while)")
+db.conc.ensureIndex({x:1})
+
+var c1=db.conc.count({x:{$lt:NRECORDS}})
+// this is just a flag that the child will toggle when it's done.
+db.concflag.update({}, {inprog:true}, true)
+
+updater=startParallelShell("db=db.getSisterDB('concurrency');\
+ db.conc.update({}, {$inc:{x: "+NRECORDS+"}}, false, true);\
+ print(db.getLastError());\
+ db.concflag.update({},{inprog:false})");
+
+querycount=0;
+decrements=0;
+misses=0
+while (1) {
+ if (db.concflag.findOne().inprog) {
+ c2=db.conc.count({x:{$lt:NRECORDS}})
+ print(c2)
+ querycount++;
+ if (c2<c1)
+ decrements++;
+ else
+ misses++;
+ c1 = c2;
+ } else
+ break;
+ sleep(10);
+}
+print(querycount + " queries, " + decrements + " decrements, " + misses + " misses");
+
+updater() // wait()