summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/absent_ns_field_in_index_specs.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/absent_ns_field_in_index_specs.js')
-rw-r--r--jstests/noPassthrough/absent_ns_field_in_index_specs.js93
1 files changed, 48 insertions, 45 deletions
diff --git a/jstests/noPassthrough/absent_ns_field_in_index_specs.js b/jstests/noPassthrough/absent_ns_field_in_index_specs.js
index 07477fdd1e4..4428415e1b3 100644
--- a/jstests/noPassthrough/absent_ns_field_in_index_specs.js
+++ b/jstests/noPassthrough/absent_ns_field_in_index_specs.js
@@ -9,67 +9,70 @@
* @tags: [requires_replication, requires_persistence]
*/
(function() {
- 'use strict';
+'use strict';
- const dbName = 'test';
- const collName = 'absent_ns';
+const dbName = 'test';
+const collName = 'absent_ns';
- let replSet = new ReplSetTest({name: 'absentNsField', nodes: 2});
- replSet.startSet();
- replSet.initiate();
+let replSet = new ReplSetTest({name: 'absentNsField', nodes: 2});
+replSet.startSet();
+replSet.initiate();
- const primary = replSet.getPrimary();
- const primaryDB = primary.getDB(dbName);
- const primaryColl = primaryDB.getCollection(collName);
+const primary = replSet.getPrimary();
+const primaryDB = primary.getDB(dbName);
+const primaryColl = primaryDB.getCollection(collName);
- const secondary = replSet.getSecondary();
- const secondaryDB = secondary.getDB(dbName);
+const secondary = replSet.getSecondary();
+const secondaryDB = secondary.getDB(dbName);
- // The primary will not generate the 'ns' field for index specs, but the secondary will.
- assert.commandWorked(primary.getDB('admin').runCommand(
- {setParameter: 1, disableIndexSpecNamespaceGeneration: 1}));
+// The primary will not generate the 'ns' field for index specs, but the secondary will.
+assert.commandWorked(
+ primary.getDB('admin').runCommand({setParameter: 1, disableIndexSpecNamespaceGeneration: 1}));
- assert.commandWorked(primaryColl.insert({x: 100}));
- assert.commandWorked(primaryColl.createIndex({x: 1}));
+assert.commandWorked(primaryColl.insert({x: 100}));
+assert.commandWorked(primaryColl.createIndex({x: 1}));
- replSet.awaitReplication();
+replSet.awaitReplication();
- let specPrimary =
- assert.commandWorked(primaryDB.runCommand({listIndexes: collName})).cursor.firstBatch[1];
- let specSecondary =
- assert.commandWorked(secondaryDB.runCommand({listIndexes: collName})).cursor.firstBatch[1];
+let specPrimary =
+ assert.commandWorked(primaryDB.runCommand({listIndexes: collName})).cursor.firstBatch[1];
+let specSecondary =
+ assert.commandWorked(secondaryDB.runCommand({listIndexes: collName})).cursor.firstBatch[1];
- assert.eq(false, specPrimary.hasOwnProperty('ns'));
- assert.eq(true, specSecondary.hasOwnProperty('ns'));
- assert.eq(dbName + '.' + collName, specSecondary.ns);
+assert.eq(false, specPrimary.hasOwnProperty('ns'));
+assert.eq(true, specSecondary.hasOwnProperty('ns'));
+assert.eq(dbName + '.' + collName, specSecondary.ns);
- replSet.stopSet(/*signal=*/null, /*forRestart=*/true);
+replSet.stopSet(/*signal=*/null, /*forRestart=*/true);
- // The primaries index spec has no 'ns' field and the secondaries index spec does have the 'ns'
- // field. Restart the nodes as standalone and ensure that the primaries index spec gets updated
- // with the 'ns' field. No changes should be necessary to the secondaries index spec, but
- // verify that it still has the 'ns' field.
- const options = {dbpath: primary.dbpath, noCleanData: true};
- let conn = MongoRunner.runMongod(options);
- assert.neq(null, conn, 'mongod was unable to start up with options: ' + tojson(options));
+// The primaries index spec has no 'ns' field and the secondaries index spec does have the 'ns'
+// field. Restart the nodes as standalone and ensure that the primaries index spec gets updated
+// with the 'ns' field. No changes should be necessary to the secondaries index spec, but
+// verify that it still has the 'ns' field.
+const options = {
+ dbpath: primary.dbpath,
+ noCleanData: true
+};
+let conn = MongoRunner.runMongod(options);
+assert.neq(null, conn, 'mongod was unable to start up with options: ' + tojson(options));
- let db = conn.getDB(dbName);
- let spec = assert.commandWorked(db.runCommand({listIndexes: collName})).cursor.firstBatch[1];
+let db = conn.getDB(dbName);
+let spec = assert.commandWorked(db.runCommand({listIndexes: collName})).cursor.firstBatch[1];
- assert.eq(true, spec.hasOwnProperty('ns'));
- assert.eq(dbName + '.' + collName, spec.ns);
+assert.eq(true, spec.hasOwnProperty('ns'));
+assert.eq(dbName + '.' + collName, spec.ns);
- MongoRunner.stopMongod(conn);
+MongoRunner.stopMongod(conn);
- options.dbpath = secondary.dbpath;
- conn = MongoRunner.runMongod(options);
- assert.neq(null, conn, 'mongod was unable to start up with options: ' + tojson(options));
+options.dbpath = secondary.dbpath;
+conn = MongoRunner.runMongod(options);
+assert.neq(null, conn, 'mongod was unable to start up with options: ' + tojson(options));
- db = conn.getDB(dbName);
- spec = assert.commandWorked(db.runCommand({listIndexes: collName})).cursor.firstBatch[1];
+db = conn.getDB(dbName);
+spec = assert.commandWorked(db.runCommand({listIndexes: collName})).cursor.firstBatch[1];
- assert.eq(true, spec.hasOwnProperty('ns'));
- assert.eq(dbName + '.' + collName, spec.ns);
+assert.eq(true, spec.hasOwnProperty('ns'));
+assert.eq(dbName + '.' + collName, spec.ns);
- MongoRunner.stopMongod(conn);
+MongoRunner.stopMongod(conn);
}());