summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/ignore_notablescan.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/ignore_notablescan.js')
-rw-r--r--jstests/noPassthrough/ignore_notablescan.js106
1 files changed, 52 insertions, 54 deletions
diff --git a/jstests/noPassthrough/ignore_notablescan.js b/jstests/noPassthrough/ignore_notablescan.js
index ccdfa9ebfce..255b646f757 100644
--- a/jstests/noPassthrough/ignore_notablescan.js
+++ b/jstests/noPassthrough/ignore_notablescan.js
@@ -1,73 +1,71 @@
// Test that 'notablescan' parameter does not affect queries internal namespaces.
// @tags: [uses_transactions]
(function() {
- "use strict";
+"use strict";
- const dbName = "test";
- const collName = "coll";
+const dbName = "test";
+const collName = "coll";
- function runTests(ServerType) {
- const s = new ServerType();
+function runTests(ServerType) {
+ const s = new ServerType();
- const configDB = s.getConn().getDB("config");
- const session = s.getConn().getDB(dbName).getMongo().startSession();
- const primaryDB = session.getDatabase(dbName);
+ const configDB = s.getConn().getDB("config");
+ const session = s.getConn().getDB(dbName).getMongo().startSession();
+ const primaryDB = session.getDatabase(dbName);
- // Implicitly create the collection outside of the transaction.
- assert.writeOK(primaryDB.getCollection(collName).insert({x: 1}));
+ // Implicitly create the collection outside of the transaction.
+ assert.writeOK(primaryDB.getCollection(collName).insert({x: 1}));
- // Run a transaction so the 'config.transactions' collection is implicitly created.
- session.startTransaction();
- assert.writeOK(primaryDB.getCollection(collName).insert({x: 2}));
- assert.commandWorked(session.commitTransaction_forTesting());
+ // Run a transaction so the 'config.transactions' collection is implicitly created.
+ session.startTransaction();
+ assert.writeOK(primaryDB.getCollection(collName).insert({x: 2}));
+ assert.commandWorked(session.commitTransaction_forTesting());
- // Run a predicate query that would fail if we did not ignore the 'notablescan' flag.
- assert.eq(configDB.transactions.find({any_nonexistent_field: {$exists: true}}).itcount(),
- 0);
+ // Run a predicate query that would fail if we did not ignore the 'notablescan' flag.
+ assert.eq(configDB.transactions.find({any_nonexistent_field: {$exists: true}}).itcount(), 0);
- // Run the same query against the user created collection honoring the 'notablescan' flag.
- // This will cause the query to fail as there is no viable query plan. Unfortunately,
- // the reported query error code is the cryptic 'BadValue'.
- assert.commandFailedWithCode(
- primaryDB.runCommand(
- {find: collName, filter: {any_nonexistent_field: {$exists: true}}}),
- ErrorCodes.BadValue);
+ // Run the same query against the user created collection honoring the 'notablescan' flag.
+ // This will cause the query to fail as there is no viable query plan. Unfortunately,
+ // the reported query error code is the cryptic 'BadValue'.
+ assert.commandFailedWithCode(
+ primaryDB.runCommand({find: collName, filter: {any_nonexistent_field: {$exists: true}}}),
+ ErrorCodes.BadValue);
- s.stop();
- }
+ s.stop();
+}
- function Sharding() {
- this.st = new ShardingTest({
- shards: 2,
- config: 1,
- other: {
- shardOptions: {setParameter: {notablescan: true}},
- configOptions: {setParameter: {notablescan: true}}
- }
- });
- }
+function Sharding() {
+ this.st = new ShardingTest({
+ shards: 2,
+ config: 1,
+ other: {
+ shardOptions: {setParameter: {notablescan: true}},
+ configOptions: {setParameter: {notablescan: true}}
+ }
+ });
+}
- Sharding.prototype.stop = function() {
- this.st.stop();
- };
+Sharding.prototype.stop = function() {
+ this.st.stop();
+};
- Sharding.prototype.getConn = function() {
- return this.st.s0;
- };
+Sharding.prototype.getConn = function() {
+ return this.st.s0;
+};
- function ReplSet() {
- this.rst = new ReplSetTest({nodes: 1, nodeOptions: {setParameter: {notablescan: true}}});
- this.rst.startSet();
- this.rst.initiate();
- }
+function ReplSet() {
+ this.rst = new ReplSetTest({nodes: 1, nodeOptions: {setParameter: {notablescan: true}}});
+ this.rst.startSet();
+ this.rst.initiate();
+}
- ReplSet.prototype.stop = function() {
- this.rst.stopSet();
- };
+ReplSet.prototype.stop = function() {
+ this.rst.stopSet();
+};
- ReplSet.prototype.getConn = function() {
- return this.rst.getPrimary();
- };
+ReplSet.prototype.getConn = function() {
+ return this.rst.getPrimary();
+};
- [ReplSet, Sharding].forEach(runTests);
+[ReplSet, Sharding].forEach(runTests);
}());