summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2020-07-15 15:08:01 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-15 20:55:41 +0000
commit539174781bb60161004d0e6b65321cb8d2de5452 (patch)
tree06dca4359efb7f1bd01ce270bf33cf785de8788b
parent0182fc92421d426f77236d5ca071b545e0551188 (diff)
downloadmongo-539174781bb60161004d0e6b65321cb8d2de5452.tar.gz
SERVER-49531 add profile.js for implicit system.profile collection creation testing
-rw-r--r--jstests/replsets/profile.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/jstests/replsets/profile.js b/jstests/replsets/profile.js
new file mode 100644
index 00000000000..caa5d7f8871
--- /dev/null
+++ b/jstests/replsets/profile.js
@@ -0,0 +1,31 @@
+// Confirm that implicitly created profile collections are successful and do not trigger assertions.
+// In order to implicitly create a profile collection with a read, we must set up the server with
+// some data to read without the profiler being active.
+// @tags: [requires_persistence]
+(function() {
+"use strict";
+let rst = new ReplSetTest({nodes: {n0: {profile: "0"}}});
+rst.startSet();
+rst.initiate();
+let primary = rst.getPrimary();
+let primaryDB = primary.getDB('test');
+
+assert.commandWorked(primaryDB.foo.insert({_id: 1}));
+
+const nodeId = rst.getNodeId(primary);
+rst.stop(nodeId);
+rst.start(nodeId, {profile: "2"}, true /* preserves data directory */);
+rst.awaitReplication();
+primary = rst.getPrimary();
+primaryDB = primary.getDB('test');
+
+let oldAssertCounts = primaryDB.serverStatus().asserts;
+assert.eq(0, primaryDB.system.profile.count());
+assert.eq([{_id: 1}], primaryDB.foo.aggregate([]).toArray());
+let newAssertCounts = primaryDB.serverStatus().asserts;
+assert.eq(oldAssertCounts, newAssertCounts);
+// Should have 2 entries, one for the count command and one for the aggregate command.
+assert.eq(2, primaryDB.system.profile.count());
+
+rst.stopSet();
+})();