summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/timestamp_index_builds.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/timestamp_index_builds.js')
-rw-r--r--jstests/noPassthrough/timestamp_index_builds.js128
1 files changed, 63 insertions, 65 deletions
diff --git a/jstests/noPassthrough/timestamp_index_builds.js b/jstests/noPassthrough/timestamp_index_builds.js
index e5ffa405d45..41f5ecfb42c 100644
--- a/jstests/noPassthrough/timestamp_index_builds.js
+++ b/jstests/noPassthrough/timestamp_index_builds.js
@@ -18,84 +18,82 @@
* @tags: [requires_replication, requires_persistence, requires_majority_read_concern]
*/
(function() {
- "use strict";
+"use strict";
- const rst = new ReplSetTest({
- name: "timestampingIndexBuilds",
- nodes: 2,
- nodeOptions:
- {setParameter: {logComponentVerbosity: tojsononeline({storage: {recovery: 2}})}}
- });
- const nodes = rst.startSet();
- rst.initiate();
+const rst = new ReplSetTest({
+ name: "timestampingIndexBuilds",
+ nodes: 2,
+ nodeOptions: {setParameter: {logComponentVerbosity: tojsononeline({storage: {recovery: 2}})}}
+});
+const nodes = rst.startSet();
+rst.initiate();
- if (!rst.getPrimary().adminCommand("serverStatus").storageEngine.supportsSnapshotReadConcern) {
- // Only snapshotting storage engines require correct timestamping of index builds.
- rst.stopSet();
- return;
- }
+if (!rst.getPrimary().adminCommand("serverStatus").storageEngine.supportsSnapshotReadConcern) {
+ // Only snapshotting storage engines require correct timestamping of index builds.
+ rst.stopSet();
+ return;
+}
- function getColl(conn) {
- return conn.getDB("timestampingIndexBuild")["coll"];
- }
+function getColl(conn) {
+ return conn.getDB("timestampingIndexBuild")["coll"];
+}
- let coll = getColl(rst.getPrimary());
+let coll = getColl(rst.getPrimary());
- // Create a collection and wait for the stable timestamp to exceed its creation on both nodes.
- assert.commandWorked(
- coll.insert({}, {writeConcern: {w: "majority", wtimeout: rst.kDefaultTimeoutMS}}));
+// Create a collection and wait for the stable timestamp to exceed its creation on both nodes.
+assert.commandWorked(
+ coll.insert({}, {writeConcern: {w: "majority", wtimeout: rst.kDefaultTimeoutMS}}));
- // Wait for the stable timestamp to match the latest oplog entry on both nodes.
- rst.awaitLastOpCommitted();
+// Wait for the stable timestamp to match the latest oplog entry on both nodes.
+rst.awaitLastOpCommitted();
- // Disable snapshotting on all members of the replica set so that further operations do not
- // enter the majority snapshot.
- nodes.forEach(node => assert.commandWorked(node.adminCommand(
- {configureFailPoint: "disableSnapshotting", mode: "alwaysOn"})));
+// Disable snapshotting on all members of the replica set so that further operations do not
+// enter the majority snapshot.
+nodes.forEach(node => assert.commandWorked(node.adminCommand(
+ {configureFailPoint: "disableSnapshotting", mode: "alwaysOn"})));
- assert.commandWorked(coll.createIndexes([{foo: 1}], {background: true}));
- rst.awaitReplication();
+assert.commandWorked(coll.createIndexes([{foo: 1}], {background: true}));
+rst.awaitReplication();
- rst.stopSet(undefined, true);
+rst.stopSet(undefined, true);
- // The `disableSnapshotting` failpoint is no longer in effect. Bring up and analyze each node
- // separately. The client does not need to perform any writes from here on out.
- for (let nodeIdx = 0; nodeIdx < 2; ++nodeIdx) {
- let node = nodes[nodeIdx];
- let nodeIdentity = tojsononeline({nodeIdx: nodeIdx, dbpath: node.dbpath, port: node.port});
+// The `disableSnapshotting` failpoint is no longer in effect. Bring up and analyze each node
+// separately. The client does not need to perform any writes from here on out.
+for (let nodeIdx = 0; nodeIdx < 2; ++nodeIdx) {
+ let node = nodes[nodeIdx];
+ let nodeIdentity = tojsononeline({nodeIdx: nodeIdx, dbpath: node.dbpath, port: node.port});
- // Bringing up the node as a standalone should only find the `_id` index.
- {
- jsTestLog("Starting as a standalone. Ensure only the `_id` index exists. Node: " +
- nodeIdentity);
- let conn = rst.start(nodeIdx, {noReplSet: true, noCleanData: true});
- assert.neq(null, conn, "failed to restart node");
- assert.eq(1, getColl(conn).getIndexes().length);
- rst.stop(nodeIdx);
- }
+ // Bringing up the node as a standalone should only find the `_id` index.
+ {
+ jsTestLog("Starting as a standalone. Ensure only the `_id` index exists. Node: " +
+ nodeIdentity);
+ let conn = rst.start(nodeIdx, {noReplSet: true, noCleanData: true});
+ assert.neq(null, conn, "failed to restart node");
+ assert.eq(1, getColl(conn).getIndexes().length);
+ rst.stop(nodeIdx);
+ }
- // Bringing up the node with `--replSet` will run oplog recovery. The `foo` index will be
- // rebuilt, but not become "stable".
- {
- jsTestLog("Starting as a replica set. Both indexes should exist. Node: " +
- nodeIdentity);
- let conn = rst.start(nodeIdx, {startClean: false}, true);
- conn.setSlaveOk();
- assert.eq(2, getColl(conn).getIndexes().length);
- rst.stop(nodeIdx);
- }
+ // Bringing up the node with `--replSet` will run oplog recovery. The `foo` index will be
+ // rebuilt, but not become "stable".
+ {
+ jsTestLog("Starting as a replica set. Both indexes should exist. Node: " + nodeIdentity);
+ let conn = rst.start(nodeIdx, {startClean: false}, true);
+ conn.setSlaveOk();
+ assert.eq(2, getColl(conn).getIndexes().length);
+ rst.stop(nodeIdx);
+ }
- // Restarting the node as a standalone once again only shows the `_id` index.
- {
- jsTestLog(
- "Starting as a standalone after replication startup recovery. Ensure only the `_id` index exists. Node: " +
- nodeIdentity);
- let conn = rst.start(nodeIdx, {noReplSet: true, noCleanData: true});
- assert.neq(null, conn, "failed to restart node");
- assert.eq(1, getColl(conn).getIndexes().length);
- rst.stop(nodeIdx);
- }
+ // Restarting the node as a standalone once again only shows the `_id` index.
+ {
+ jsTestLog(
+ "Starting as a standalone after replication startup recovery. Ensure only the `_id` index exists. Node: " +
+ nodeIdentity);
+ let conn = rst.start(nodeIdx, {noReplSet: true, noCleanData: true});
+ assert.neq(null, conn, "failed to restart node");
+ assert.eq(1, getColl(conn).getIndexes().length);
+ rst.stop(nodeIdx);
}
+}
- rst.stopSet();
+rst.stopSet();
}());