summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2012-03-30 21:40:45 +0200
committerAntonin Kral <a.kral@bobek.cz>2012-03-30 21:40:45 +0200
commiteaaa7b30c99b89b5483e0a372bb73fe8c8695185 (patch)
tree6c08f243b00c0f6b7a4897a236774cf484e61314 /jstests
parentba59b00736b5b8dc0f0bd46397575aaf0cd4d44f (diff)
downloadmongodb-eaaa7b30c99b89b5483e0a372bb73fe8c8695185.tar.gz
Imported Upstream version 2.0.4
Diffstat (limited to 'jstests')
-rw-r--r--jstests/getlog2.js41
-rw-r--r--jstests/sharding/shard3.js8
2 files changed, 48 insertions, 1 deletions
diff --git a/jstests/getlog2.js b/jstests/getlog2.js
new file mode 100644
index 0000000..3f8a8f8
--- /dev/null
+++ b/jstests/getlog2.js
@@ -0,0 +1,41 @@
+// tests getlog as well as slow querying logging
+
+glcol = db.getLogTest2;
+glcol.drop()
+
+contains = function(arr, func) {
+ var i = arr.length;
+ while (i--) {
+ if (func(arr[i])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// test doesn't work when talking to mongos
+if(db.isMaster().msg != "isdbgrid") {
+ // run a slow query
+ glcol.save({ "SENTINEL": 1 });
+ glcol.findOne({ "SENTINEL": 1, "$where": function() { sleep(1000); return true; } });
+
+ // run a slow update
+ glcol.update({ "SENTINEL": 1, "$where": function() { sleep(1000); return true; } }, { "x": "x" });
+
+ var resp = db.adminCommand({getLog:"global"});
+ assert( resp.ok == 1, "error executing getLog command" );
+ assert( resp.log, "no log field" );
+ assert( resp.log.length > 0 , "no log lines" );
+
+ // ensure that slow query is logged in detail
+ assert( contains(resp.log, function(v) {
+ print(v);
+ return v.indexOf(" query ") != -1 && v.indexOf("query:") != -1 && v.indexOf("SENTINEL") != -1;
+ }) );
+
+ // same, but for update
+ assert( contains(resp.log, function(v) {
+ print(v);
+ return v.indexOf(" update ") != -1 && v.indexOf("query:") != -1 && v.indexOf("SENTINEL") != -1;
+ }) );
+}
diff --git a/jstests/sharding/shard3.js b/jstests/sharding/shard3.js
index e27316e..8ee566e 100644
--- a/jstests/sharding/shard3.js
+++ b/jstests/sharding/shard3.js
@@ -61,7 +61,7 @@ function doCounts( name , total , onlyItCounts ){
}
var total = doCounts( "before wrong save" )
-secondary.save( { num : -3 } );
+secondary.save( { _id : 111 , num : -3 } );
printjson( secondary.getDB().getLastError() )
doCounts( "after wrong save" , total , true )
e = a.find().explain();
@@ -69,6 +69,12 @@ assert.eq( 3 , e.n , "ex1" )
assert.eq( 4 , e.nscanned , "ex2" )
assert.eq( 1 , e.nChunkSkips , "ex3" )
+
+// SERVER-4612
+// make sure idhack obeys chunks
+x = a.findOne( { _id : 111 } )
+assert( ! x , "idhack didn't obey chunk boundaries " + tojson(x) );
+
// --- move all to 1 ---
print( "MOVE ALL TO 1" );