summaryrefslogtreecommitdiff
path: root/jstests/replsets/id_index_replication.js
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:20:35 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-27 11:02:23 -0400
commit134a4083953270e8a11430395357fb70a29047ad (patch)
treedd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/replsets/id_index_replication.js
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/replsets/id_index_replication.js')
-rw-r--r--jstests/replsets/id_index_replication.js116
1 files changed, 57 insertions, 59 deletions
diff --git a/jstests/replsets/id_index_replication.js b/jstests/replsets/id_index_replication.js
index 764619013ea..bd693104104 100644
--- a/jstests/replsets/id_index_replication.js
+++ b/jstests/replsets/id_index_replication.js
@@ -3,77 +3,75 @@
* created on the secondary when the index spec is not included in the oplog.
*/
(function() {
- "use strict";
+"use strict";
- load("jstests/libs/get_index_helpers.js");
+load("jstests/libs/get_index_helpers.js");
- var rst = new ReplSetTest({nodes: 2});
- rst.startSet();
- var replSetConfig = rst.getReplSetConfig();
- replSetConfig.members[1].priority = 0;
- rst.initiate(replSetConfig);
+var rst = new ReplSetTest({nodes: 2});
+rst.startSet();
+var replSetConfig = rst.getReplSetConfig();
+replSetConfig.members[1].priority = 0;
+rst.initiate(replSetConfig);
- var primaryDB = rst.getPrimary().getDB("test");
- var oplogColl = rst.getPrimary().getDB("local").oplog.rs;
- var secondaryDB = rst.getSecondary().getDB("test");
+var primaryDB = rst.getPrimary().getDB("test");
+var oplogColl = rst.getPrimary().getDB("local").oplog.rs;
+var secondaryDB = rst.getSecondary().getDB("test");
- function testOplogEntryIdIndexSpec(collectionName, idIndexSpec) {
- var oplogEntry = oplogColl.findOne({op: "c", "o.create": collectionName});
- assert.neq(null, oplogEntry);
- if (idIndexSpec === null) {
- assert(!oplogEntry.o.hasOwnProperty("idIndex"), tojson(oplogEntry));
- } else {
- assert.eq(0, bsonWoCompare(idIndexSpec, oplogEntry.o.idIndex), tojson(oplogEntry));
- }
+function testOplogEntryIdIndexSpec(collectionName, idIndexSpec) {
+ var oplogEntry = oplogColl.findOne({op: "c", "o.create": collectionName});
+ assert.neq(null, oplogEntry);
+ if (idIndexSpec === null) {
+ assert(!oplogEntry.o.hasOwnProperty("idIndex"), tojson(oplogEntry));
+ } else {
+ assert.eq(0, bsonWoCompare(idIndexSpec, oplogEntry.o.idIndex), tojson(oplogEntry));
}
+}
- assert.commandWorked(primaryDB.createCollection("without_version"));
- var allIndexes = primaryDB.without_version.getIndexes();
- var spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
- assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
- assert.eq(2, spec.v, "Expected primary to build a v=2 _id index: " + tojson(spec));
- testOplogEntryIdIndexSpec("without_version", spec);
+assert.commandWorked(primaryDB.createCollection("without_version"));
+var allIndexes = primaryDB.without_version.getIndexes();
+var spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
+assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
+assert.eq(2, spec.v, "Expected primary to build a v=2 _id index: " + tojson(spec));
+testOplogEntryIdIndexSpec("without_version", spec);
- assert.commandWorked(
- primaryDB.createCollection("version_v2", {idIndex: {key: {_id: 1}, name: "_id_", v: 2}}));
- allIndexes = primaryDB.version_v2.getIndexes();
- spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
- assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
- assert.eq(2, spec.v, "Expected primary to build a v=2 _id index: " + tojson(spec));
- testOplogEntryIdIndexSpec("version_v2", spec);
+assert.commandWorked(
+ primaryDB.createCollection("version_v2", {idIndex: {key: {_id: 1}, name: "_id_", v: 2}}));
+allIndexes = primaryDB.version_v2.getIndexes();
+spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
+assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
+assert.eq(2, spec.v, "Expected primary to build a v=2 _id index: " + tojson(spec));
+testOplogEntryIdIndexSpec("version_v2", spec);
- assert.commandWorked(
- primaryDB.createCollection("version_v1", {idIndex: {key: {_id: 1}, name: "_id_", v: 1}}));
- allIndexes = primaryDB.version_v1.getIndexes();
- spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
- assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
- assert.eq(1, spec.v, "Expected primary to build a v=1 _id index: " + tojson(spec));
- testOplogEntryIdIndexSpec("version_v1", null);
+assert.commandWorked(
+ primaryDB.createCollection("version_v1", {idIndex: {key: {_id: 1}, name: "_id_", v: 1}}));
+allIndexes = primaryDB.version_v1.getIndexes();
+spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
+assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
+assert.eq(1, spec.v, "Expected primary to build a v=1 _id index: " + tojson(spec));
+testOplogEntryIdIndexSpec("version_v1", null);
- rst.awaitReplication();
+rst.awaitReplication();
- // Verify that the secondary built _id indexes with the same version as on the primary.
+// Verify that the secondary built _id indexes with the same version as on the primary.
- allIndexes = secondaryDB.without_version.getIndexes();
- spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
- assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
- assert.eq(
- 2,
- spec.v,
- "Expected secondary to build a v=2 _id index when explicitly requested: " + tojson(spec));
+allIndexes = secondaryDB.without_version.getIndexes();
+spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
+assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
+assert.eq(2,
+ spec.v,
+ "Expected secondary to build a v=2 _id index when explicitly requested: " + tojson(spec));
- allIndexes = secondaryDB.version_v2.getIndexes();
- spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
- assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
- assert.eq(
- 2,
- spec.v,
- "Expected secondary to build a v=2 _id index when explicitly requested: " + tojson(spec));
+allIndexes = secondaryDB.version_v2.getIndexes();
+spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
+assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
+assert.eq(2,
+ spec.v,
+ "Expected secondary to build a v=2 _id index when explicitly requested: " + tojson(spec));
- allIndexes = secondaryDB.version_v1.getIndexes();
- spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
- assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
- assert.eq(1, spec.v, "Expected secondary to implicitly build a v=1 _id index: " + tojson(spec));
+allIndexes = secondaryDB.version_v1.getIndexes();
+spec = GetIndexHelpers.findByKeyPattern(allIndexes, {_id: 1});
+assert.neq(null, spec, "_id index not found: " + tojson(allIndexes));
+assert.eq(1, spec.v, "Expected secondary to implicitly build a v=1 _id index: " + tojson(spec));
- rst.stopSet();
+rst.stopSet();
})();