summaryrefslogtreecommitdiff
path: root/jstests/replsets
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2015-06-16 08:06:18 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2015-06-17 13:22:36 -0400
commit7523229c8dda361a10a42e622fc04441f5011fb6 (patch)
tree9a28af37c9bc501f3c393d3b2a3cd8b8bdabecf2 /jstests/replsets
parentbdf6a4b8af528241818ce03ce2483ac3c0c2aeff (diff)
downloadmongo-7523229c8dda361a10a42e622fc04441f5011fb6.tar.gz
SERVER-18962 do not replicate metadata operations pertaining to system.profile
Diffstat (limited to 'jstests/replsets')
-rw-r--r--jstests/replsets/system_profile.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/jstests/replsets/system_profile.js b/jstests/replsets/system_profile.js
new file mode 100644
index 00000000000..592accb43b8
--- /dev/null
+++ b/jstests/replsets/system_profile.js
@@ -0,0 +1,48 @@
+// This tests that metadata commands run against the system.profile collection are not replicated
+// to the secondary.
+
+(function() {
+ "use strict";
+ var rst = new ReplSetTest({nodes: 2});
+ rst.startSet();
+ rst.initiate();
+ rst.awaitReplication();
+
+ var getLatestOp = function() {
+ return primaryDB.getSiblingDB('local').oplog.rs.find().sort({$natural: -1}).limit(1).next();
+ };
+
+ var primaryDB = rst.getPrimary().getDB('test');
+ var op = getLatestOp();
+
+ // Enable profiling on the primary
+ assert.commandWorked(primaryDB.runCommand({profile: 2}));
+ assert.eq(op, getLatestOp(), "oplog entry created when profile was enabled");
+ assert.writeOK(primaryDB.foo.insert({}));
+ op = getLatestOp();
+ assert.commandWorked(primaryDB.runCommand({profile: 0}));
+ assert.eq(op, getLatestOp(), "oplog entry created when profile was disabled");
+
+ // dropCollection
+ assert(primaryDB.system.profile.drop());
+ assert.eq(op, getLatestOp(), "oplog entry created when system.profile was dropped");
+
+ assert.commandWorked(primaryDB.createCollection("system.profile", {capped: true, size: 1000}));
+ assert.eq(op, getLatestOp(), "oplog entry created when system.profile was created");
+ assert.commandWorked(primaryDB.runCommand({profile: 2}));
+ assert.writeOK(primaryDB.foo.insert({}));
+ op = getLatestOp();
+ assert.commandWorked(primaryDB.runCommand({profile: 0}));
+
+ // emptycapped the collection
+ assert.commandWorked(primaryDB.runCommand({emptycapped: "system.profile"}));
+ assert.eq(op, getLatestOp(),
+ "oplog entry created when system.profile was emptied via emptycapped");
+ assert(primaryDB.system.profile.drop());
+
+ // convertToCapped
+ assert.commandWorked(primaryDB.createCollection("system.profile"));
+ assert.commandWorked(primaryDB.runCommand({convertToCapped: "system.profile", size: 1000}));
+ assert.eq(op, getLatestOp(), "oplog entry created when system.profile was convertedToCapped");
+ assert(primaryDB.system.profile.drop());
+})();