summaryrefslogtreecommitdiff
path: root/jstests/sharding/sharded_profile.js
blob: f3ab4fdaa6d3bdf53914ac9bc6498e34bc2fdb0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Tests whether profiling can trigger stale config errors and interfere with write batches
// SERVER-13413

(function() {

var st = new ShardingTest({ shards: 1, mongos: 2 });
st.stopBalancer();

var admin = st.s0.getDB('admin');
var shards = st.s0.getCollection('config.shards').find().toArray();
var coll = st.s0.getCollection('foo.bar');

assert(admin.runCommand({ enableSharding: coll.getDB() + '' }).ok);
assert(admin.runCommand({ shardCollection: coll + '', key: { _id: 1 } }).ok);

st.printShardingStatus();

jsTest.log('Turning on profiling on ' + st.shard0);

st.shard0.getDB(coll.getDB().toString()).setProfilingLevel(2);

var profileColl = st.shard0.getDB(coll.getDB().toString()).system.profile;

var inserts = [{ _id: 0 }, { _id: 1 }, { _id: 2 }];

assert.writeOK(st.s1.getCollection(coll.toString()).insert(inserts));

printjson(profileColl.find().toArray());

for (var i = 0; i < inserts.length; i++) {
    assert.neq(null, profileColl.findOne({ 'query._id': i }));
}

st.stop();

})();