summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorArun Banala <arun.banala@mongodb.com>2020-08-19 12:33:27 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-26 19:41:09 +0000
commit019fa81486e81bb6d0de3fbedd480e40b6929e23 (patch)
treea6b66d0b520d3316e47dcfc8c5ba653231a0795f /jstests
parentcef5fedff77cc1719470310bf765f358396ba017 (diff)
downloadmongo-019fa81486e81bb6d0de3fbedd480e40b6929e23.tar.gz
SERVER-47856 Use $v:2 delta oplog entries by default
Diffstat (limited to 'jstests')
-rw-r--r--jstests/change_streams/pipeline_style_updates.js198
-rw-r--r--jstests/change_streams/pipeline_style_updates_v2_oplog_entries.js6
-rw-r--r--jstests/replsets/v2_delta_oplog_entries.js6
3 files changed, 104 insertions, 106 deletions
diff --git a/jstests/change_streams/pipeline_style_updates.js b/jstests/change_streams/pipeline_style_updates.js
index 98a5ff390b3..921e039fc3b 100644
--- a/jstests/change_streams/pipeline_style_updates.js
+++ b/jstests/change_streams/pipeline_style_updates.js
@@ -13,103 +13,111 @@ load("jstests/libs/collection_drop_recreate.js"); // For assert[Drop|Create]Col
load("jstests/libs/discover_topology.js"); // For findNonConfigNodes.
load("jstests/noPassthrough/libs/server_parameter_helpers.js"); // For setParameterOnAllHosts.
-jsTestLog("Testing when $v:2 oplog entry is enabled.");
-setParameterOnAllHosts(DiscoverTopology.findNonConfigNodes(db.getMongo()),
- "internalQueryEnableLoggingV2OplogEntries",
- true);
-
-assertDropAndRecreateCollection(db, "t1");
-
-const kLargeStr = '*'.repeat(512);
-
-assert.commandWorked(db.t1.insert({
- _id: 100,
- "a": 1,
- "b": 2,
- "obj": {"a": 1, "b": 2, "str": kLargeStr},
-}));
-
-const cst = new ChangeStreamTest(db);
-const changeStreamCursor =
- cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1});
-
-function testPipelineStyleUpdate(pipeline, expectedChange, operationType) {
- assert.commandWorked(db.t1.update({_id: 100}, pipeline));
- const expected = Object.assign({
- documentKey: {_id: 100},
- ns: {db: "test", coll: "t1"},
- operationType: operationType,
- },
- expectedChange);
- cst.assertNextChangesEqual({cursor: changeStreamCursor, expectedChanges: [expected]});
-}
+const v2OplogEntriesServerParameter = "internalQueryEnableLoggingV2OplogEntries";
+const defaultOpLogMode = getParameter(db.getMongo(), v2OplogEntriesServerParameter);
+try {
+ jsTestLog("Testing when $v:2 oplog entry is enabled.");
+ setParameterOnAllHosts(
+ DiscoverTopology.findNonConfigNodes(db.getMongo()), v2OplogEntriesServerParameter, true);
-jsTestLog("Testing pipeline-based update with $set.");
-let updatePipeline = [{$set: {a: 2}}];
-let expected = {
- updateDescription: {
- updatedFields: {"a": 2},
- removedFields: [],
- truncatedArrays: [],
- },
-};
-testPipelineStyleUpdate(updatePipeline, expected, "update");
-
-jsTestLog("Testing pipeline-based update with $unset.");
-updatePipeline = [{$unset: ["a"]}];
-expected = {
- updateDescription: {
- updatedFields: {},
- removedFields: ["a"],
- truncatedArrays: [],
- },
-};
-testPipelineStyleUpdate(updatePipeline, expected, "update");
-
-jsTestLog("Testing pipeline-based update with $replaceRoot.");
-updatePipeline =
- [{$replaceRoot: {newRoot: {_id: 100, b: 2, "obj": {"a": 2, "b": 2, "str": kLargeStr}}}}];
-expected = {
- updateDescription: {
- updatedFields: {"obj.a": 2},
- removedFields: [],
- truncatedArrays: [],
- },
-};
-testPipelineStyleUpdate(updatePipeline, expected, "update");
-
-jsTestLog("Testing when $v:2 oplog entry is disabled.");
-setParameterOnAllHosts(DiscoverTopology.findNonConfigNodes(db.getMongo()),
- "internalQueryEnableLoggingV2OplogEntries",
- false);
-
-jsTestLog("Testing pipeline-based update with $set.");
-updatePipeline = [{$set: {a: 2}}];
-expected = {
- fullDocument: {
- _id: 100,
- "a": 2,
- "b": 2,
- "obj": {"a": 2, "b": 2, "str": kLargeStr},
- },
-};
-testPipelineStyleUpdate(updatePipeline, expected, "replace");
-
-jsTestLog("Testing pipeline-based update with $unset.");
-updatePipeline = [{$unset: ["a"]}];
-delete expected.fullDocument.a;
-testPipelineStyleUpdate(updatePipeline, expected, "replace");
-
-jsTestLog("Testing pipeline-based update with $replaceRoot.");
-updatePipeline = [{$replaceRoot: {newRoot: {_id: 100, "a": 1, "b": 2}}}];
-expected = {
- fullDocument: {
+ assertDropAndRecreateCollection(db, "t1");
+
+ const kLargeStr = '*'.repeat(512);
+
+ assert.commandWorked(db.t1.insert({
_id: 100,
"a": 1,
"b": 2,
- },
-};
-testPipelineStyleUpdate(updatePipeline, expected, "replace");
-
-cst.cleanUp();
+ "obj": {"a": 1, "b": 2, "str": kLargeStr},
+ }));
+
+ const cst = new ChangeStreamTest(db);
+ const changeStreamCursor =
+ cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1});
+
+ function testPipelineStyleUpdate(pipeline, expectedChange, operationType) {
+ assert.commandWorked(db.t1.update({_id: 100}, pipeline));
+ const expected = Object.assign({
+ documentKey: {_id: 100},
+ ns: {db: "test", coll: "t1"},
+ operationType: operationType,
+ },
+ expectedChange);
+ cst.assertNextChangesEqual({cursor: changeStreamCursor, expectedChanges: [expected]});
+ }
+
+ jsTestLog("Testing pipeline-based update with $set.");
+ let updatePipeline = [{$set: {a: 2}}];
+ let expected = {
+ updateDescription: {
+ updatedFields: {"a": 2},
+ removedFields: [],
+ truncatedArrays: [],
+ },
+ };
+ testPipelineStyleUpdate(updatePipeline, expected, "update");
+
+ jsTestLog("Testing pipeline-based update with $unset.");
+ updatePipeline = [{$unset: ["a"]}];
+ expected = {
+ updateDescription: {
+ updatedFields: {},
+ removedFields: ["a"],
+ truncatedArrays: [],
+ },
+ };
+ testPipelineStyleUpdate(updatePipeline, expected, "update");
+
+ jsTestLog("Testing pipeline-based update with $replaceRoot.");
+ updatePipeline =
+ [{$replaceRoot: {newRoot: {_id: 100, b: 2, "obj": {"a": 2, "b": 2, "str": kLargeStr}}}}];
+ expected = {
+ updateDescription: {
+ updatedFields: {"obj.a": 2},
+ removedFields: [],
+ truncatedArrays: [],
+ },
+ };
+ testPipelineStyleUpdate(updatePipeline, expected, "update");
+
+ jsTestLog("Testing when $v:2 oplog entry is disabled.");
+ setParameterOnAllHosts(
+ DiscoverTopology.findNonConfigNodes(db.getMongo()), v2OplogEntriesServerParameter, false);
+
+ jsTestLog("Testing pipeline-based update with $set.");
+ updatePipeline = [{$set: {a: 2}}];
+ expected = {
+ fullDocument: {
+ _id: 100,
+ "a": 2,
+ "b": 2,
+ "obj": {"a": 2, "b": 2, "str": kLargeStr},
+ },
+ };
+ testPipelineStyleUpdate(updatePipeline, expected, "replace");
+
+ jsTestLog("Testing pipeline-based update with $unset.");
+ updatePipeline = [{$unset: ["a"]}];
+ delete expected.fullDocument.a;
+ testPipelineStyleUpdate(updatePipeline, expected, "replace");
+
+ jsTestLog("Testing pipeline-based update with $replaceRoot.");
+ updatePipeline = [{$replaceRoot: {newRoot: {_id: 100, "a": 1, "b": 2}}}];
+ expected = {
+ fullDocument: {
+ _id: 100,
+ "a": 1,
+ "b": 2,
+ },
+ };
+ testPipelineStyleUpdate(updatePipeline, expected, "replace");
+
+ cst.cleanUp();
+} finally {
+ // Reset the server parameter to the original value, so that other tests running in the same
+ // suite will not be impacted.
+ setParameterOnAllHosts(DiscoverTopology.findNonConfigNodes(db.getMongo()),
+ v2OplogEntriesServerParameter,
+ defaultOpLogMode);
+}
}());
diff --git a/jstests/change_streams/pipeline_style_updates_v2_oplog_entries.js b/jstests/change_streams/pipeline_style_updates_v2_oplog_entries.js
index 735abf6fb7a..682a7d188b3 100644
--- a/jstests/change_streams/pipeline_style_updates_v2_oplog_entries.js
+++ b/jstests/change_streams/pipeline_style_updates_v2_oplog_entries.js
@@ -9,12 +9,6 @@
load("jstests/libs/change_stream_util.js"); // For ChangeStreamTest
load("jstests/libs/collection_drop_recreate.js"); // For assert[Drop|Create]Collection.
-load("jstests/libs/discover_topology.js"); // For findNonConfigNodes.
-load("jstests/noPassthrough/libs/server_parameter_helpers.js"); // For setParameterOnAllHosts.
-
-setParameterOnAllHosts(DiscoverTopology.findNonConfigNodes(db.getMongo()),
- "internalQueryEnableLoggingV2OplogEntries",
- true);
// Drop and recreate the collections to be used in this set of tests.
assertDropAndRecreateCollection(db, "t1");
diff --git a/jstests/replsets/v2_delta_oplog_entries.js b/jstests/replsets/v2_delta_oplog_entries.js
index bc26fd4e1cb..ed64bf41cdb 100644
--- a/jstests/replsets/v2_delta_oplog_entries.js
+++ b/jstests/replsets/v2_delta_oplog_entries.js
@@ -10,11 +10,7 @@
* @tags: [requires_fcv_47]
*/
(function() {
-const rst = new ReplSetTest({
- name: "v2_delta_oplog_entries",
- nodes: 2,
- nodeOptions: {setParameter: {internalQueryEnableLoggingV2OplogEntries: true}}
-});
+const rst = new ReplSetTest({name: "v2_delta_oplog_entries", nodes: 2});
rst.startSet();
rst.initiate();