summaryrefslogtreecommitdiff
path: root/jstests/sharding
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding')
-rw-r--r--jstests/sharding/explainFind_stale_mongos.js5
-rw-r--r--jstests/sharding/query/collation_targeting.js20
-rw-r--r--jstests/sharding/query/collation_targeting_inherited.js10
-rw-r--r--jstests/sharding/query/comment_field_sharded.js19
-rw-r--r--jstests/sharding/query/geo_near_sort.js26
-rw-r--r--jstests/sharding/query/mongos_query_comment.js49
-rw-r--r--jstests/sharding/read_pref.js26
-rw-r--r--jstests/sharding/read_write_concern_defaults_application.js2
-rw-r--r--jstests/sharding/sharding_rs2.js1
9 files changed, 30 insertions, 128 deletions
diff --git a/jstests/sharding/explainFind_stale_mongos.js b/jstests/sharding/explainFind_stale_mongos.js
index 8e74287e520..ec3029217cb 100644
--- a/jstests/sharding/explainFind_stale_mongos.js
+++ b/jstests/sharding/explainFind_stale_mongos.js
@@ -1,6 +1,6 @@
/**
* Tests that a stale mongos does not return a stale shardVersion error to the client for explain
- * find sent using the legacy query mode (it retries on the stale shardVersion error internally).
+ * of a find command.
*/
(function() {
"use strict";
@@ -38,8 +38,7 @@ if (clusterVersionInfo.isMixedVersion) {
}
jsTest.log("Run explain find on " + ns + " from the stale mongos");
-staleMongos.getDB(dbName).getMongo().forceReadMode("legacy");
-staleMongos.getDB(dbName).getCollection(collName).find({$query: {}, $explain: true}).next();
+staleMongos.getDB(dbName).getCollection(collName).explain().find().next();
st.stop();
})();
diff --git a/jstests/sharding/query/collation_targeting.js b/jstests/sharding/query/collation_targeting.js
index 0883d18c430..8e446f745aa 100644
--- a/jstests/sharding/query/collation_targeting.js
+++ b/jstests/sharding/query/collation_targeting.js
@@ -162,12 +162,10 @@ assert.eq(1, explain.queryPlanner.winningPlan.shards.length);
// Find.
// Test a find command on strings with a non-simple collation. This should be scatter-gather.
-if (testDB.getMongo().useReadCommands()) {
- assert.eq(2, coll.find({a: "foo"}).collation(caseInsensitive).itcount());
- explain = coll.find({a: "foo"}).collation(caseInsensitive).explain();
- assert.commandWorked(explain);
- assert.eq(3, explain.queryPlanner.winningPlan.shards.length);
-}
+assert.eq(2, coll.find({a: "foo"}).collation(caseInsensitive).itcount());
+explain = coll.find({a: "foo"}).collation(caseInsensitive).explain();
+assert.commandWorked(explain);
+assert.eq(3, explain.queryPlanner.winningPlan.shards.length);
// Test a find command with a simple collation. This should be single-shard.
assert.eq(1, coll.find({a: "foo"}).itcount());
@@ -176,12 +174,10 @@ assert.commandWorked(explain);
assert.eq(1, explain.queryPlanner.winningPlan.shards.length);
// Test a find command on numbers with a non-simple collation. This should be single-shard.
-if (testDB.getMongo().useReadCommands()) {
- assert.eq(1, coll.find({a: 100}).collation(caseInsensitive).itcount());
- explain = coll.find({a: 100}).collation(caseInsensitive).explain();
- assert.commandWorked(explain);
- assert.eq(1, explain.queryPlanner.winningPlan.shards.length);
-}
+assert.eq(1, coll.find({a: 100}).collation(caseInsensitive).itcount());
+explain = coll.find({a: 100}).collation(caseInsensitive).explain();
+assert.commandWorked(explain);
+assert.eq(1, explain.queryPlanner.winningPlan.shards.length);
// FindAndModify.
diff --git a/jstests/sharding/query/collation_targeting_inherited.js b/jstests/sharding/query/collation_targeting_inherited.js
index 1ae0c4f32f4..74ac599dc62 100644
--- a/jstests/sharding/query/collation_targeting_inherited.js
+++ b/jstests/sharding/query/collation_targeting_inherited.js
@@ -187,12 +187,10 @@ assert.commandWorked(explain);
assert.eq(3, explain.queryPlanner.winningPlan.shards.length);
// Test a find command with a simple collation. This should be single-shard.
-if (testDB.getMongo().useReadCommands()) {
- assert.eq(1, collCaseInsensitive.find({a: "foo"}).collation({locale: "simple"}).itcount());
- explain = collCaseInsensitive.find({a: "foo"}).collation({locale: "simple"}).explain();
- assert.commandWorked(explain);
- assert.eq(1, explain.queryPlanner.winningPlan.shards.length);
-}
+assert.eq(1, collCaseInsensitive.find({a: "foo"}).collation({locale: "simple"}).itcount());
+explain = collCaseInsensitive.find({a: "foo"}).collation({locale: "simple"}).explain();
+assert.commandWorked(explain);
+assert.eq(1, explain.queryPlanner.winningPlan.shards.length);
// Test a find command on numbers with a non-simple collation inherited from the collection
// default. This should be single-shard.
diff --git a/jstests/sharding/query/comment_field_sharded.js b/jstests/sharding/query/comment_field_sharded.js
index 9482f6f4870..c87b8bf08a3 100644
--- a/jstests/sharding/query/comment_field_sharded.js
+++ b/jstests/sharding/query/comment_field_sharded.js
@@ -620,24 +620,5 @@ runCommentParamTest({
expectedRunningOps: 1
});
-//
-// Tests for Legacy query.
-//
-
-// Verify that $comment at top level is treated as a 'comment' field.
-const legacyComment = {
- testName: jsTestName(),
- commentField: "Legacy_find_comment"
-};
-runCommentParamTest({
- coll: shardedColl,
- expectedRunningOps: 2,
- cmdName: "find",
- commentObj: legacyComment,
- parallelFunction: `const sourceDB = db.getSiblingDB(jsTestName());
- sourceDB.getMongo().forceReadMode("legacy");
- sourceDB.coll.find({$query: {a: 1}, $comment: ${tojson(legacyComment)}});`
-});
-
st.stop();
})();
diff --git a/jstests/sharding/query/geo_near_sort.js b/jstests/sharding/query/geo_near_sort.js
index 8c3a19465c7..a283c475e18 100644
--- a/jstests/sharding/query/geo_near_sort.js
+++ b/jstests/sharding/query/geo_near_sort.js
@@ -69,21 +69,19 @@ function testSortOrders(query, indexSpec) {
assert.eq(res[0], docMinus2, tojson(res));
assert.eq(res[1], doc1, tojson(res));
- if (db.getMongo().useReadCommands()) {
- // Test a $near/$nearSphere query sorted by {a: 1} with the case-insensitive collation.
- res = coll.find(query).collation(caseInsensitive).sort({a: 1}).toArray();
- assert.eq(res.length, 4, tojson(res));
- assert.eq(res[0], doc2, tojson(res));
- assert.eq(res[1], docMinus1, tojson(res));
- assert.eq(res[2], doc1, tojson(res));
- assert.eq(res[3], docMinus2, tojson(res));
+ // Test a $near/$nearSphere query sorted by {a: 1} with the case-insensitive collation.
+ res = coll.find(query).collation(caseInsensitive).sort({a: 1}).toArray();
+ assert.eq(res.length, 4, tojson(res));
+ assert.eq(res[0], doc2, tojson(res));
+ assert.eq(res[1], docMinus1, tojson(res));
+ assert.eq(res[2], doc1, tojson(res));
+ assert.eq(res[3], docMinus2, tojson(res));
- // Test with a limit.
- res = coll.find(query).collation(caseInsensitive).sort({a: 1}).limit(2).toArray();
- assert.eq(res.length, 2, tojson(res));
- assert.eq(res[0], doc2, tojson(res));
- assert.eq(res[1], docMinus1, tojson(res));
- }
+ // Test with a limit.
+ res = coll.find(query).collation(caseInsensitive).sort({a: 1}).limit(2).toArray();
+ assert.eq(res.length, 2, tojson(res));
+ assert.eq(res[0], doc2, tojson(res));
+ assert.eq(res[1], docMinus1, tojson(res));
// Test a $near/$nearSphere query sorted by {b: 1}.
res = coll.find(query).sort({b: 1}).toArray();
diff --git a/jstests/sharding/query/mongos_query_comment.js b/jstests/sharding/query/mongos_query_comment.js
index 28fb8cb9c05..873f8017960 100644
--- a/jstests/sharding/query/mongos_query_comment.js
+++ b/jstests/sharding/query/mongos_query_comment.js
@@ -35,55 +35,6 @@ for (let i = 0; i < 5; ++i) {
assert.commandWorked(shardDB.setProfilingLevel(2));
const profiler = shardDB.system.profile;
-//
-// Set legacy read mode for the mongos and shard connections.
-//
-mongosDB.getMongo().forceReadMode("legacy");
-shardDB.getMongo().forceReadMode("legacy");
-
-// TEST CASE: A legacy string $comment meta-operator inside $query is propagated to the shards via
-// mongos but not treated as a 'comment' field.
-assert.eq(mongosColl.find({a: 1, $comment: "TEST"}).itcount(), 1);
-profilerHasSingleMatchingEntryOrThrow({
- profileDB: shardDB,
- filter: {
- op: "query",
- ns: collNS,
- "command.filter": {a: 1, $comment: "TEST"},
- "command.comment": {$exists: false}
- }
-});
-
-// TEST CASE: A legacy string $comment meta-operator is propagated to the shards via mongos.
-assert.eq(mongosColl.find({$query: {a: 1}, $comment: "TEST"}).itcount(), 1);
-profilerHasSingleMatchingEntryOrThrow(
- {profileDB: shardDB, filter: {op: "query", ns: collNS, "command.comment": "TEST"}});
-
-// TEST CASE: A legacy BSONObj $comment propagated via mongos.
-assert.eq(mongosColl.find({$query: {a: 1}, $comment: {c: 2, d: {e: "TEST"}}}).itcount(), 1);
-profilerHasSingleMatchingEntryOrThrow({
- profileDB: shardDB,
- filter: {
- op: "query",
- ns: collNS,
- "command.comment": {c: 2, d: {e: "TEST"}},
- "command.filter": {a: 1}
- }
-});
-
-// TEST CASE: Legacy BSONObj $comment when issued on the mongod.
-assert.eq(shardColl.find({$query: {a: 1}, $comment: {c: 3, d: {e: "TEST"}}}).itcount(), 1);
-profilerHasSingleMatchingEntryOrThrow({
- profileDB: shardDB,
- filter: {op: "query", ns: collNS, "command.comment": {c: 3, d: {e: "TEST"}}}
-});
-
-//
-// Revert to "commands" read mode for the find command test cases below.
-//
-mongosDB.getMongo().forceReadMode("commands");
-shardDB.getMongo().forceReadMode("commands");
-
// TEST CASE: Verify that find.comment and non-string find.filter.$comment propagate.
assert.eq(mongosColl.find({a: 1, $comment: {b: "TEST"}}).comment("TEST").itcount(), 1);
profilerHasSingleMatchingEntryOrThrow({
diff --git a/jstests/sharding/read_pref.js b/jstests/sharding/read_pref.js
index 97ca77d7556..3a0c928f92f 100644
--- a/jstests/sharding/read_pref.js
+++ b/jstests/sharding/read_pref.js
@@ -17,18 +17,11 @@ var PRI_TAG = {dc: 'ny'};
var SEC_TAGS = [{dc: 'sf', s: "1"}, {dc: 'ma', s: "2"}, {dc: 'eu', s: "3"}, {dc: 'jp', s: "4"}];
var NODES = SEC_TAGS.length + 1;
-var doTest = function(useDollarQuerySyntax) {
+var doTest = function() {
var st = new ShardingTest({shards: {rs0: {nodes: NODES, oplogSize: 10, useHostName: true}}});
var replTest = st.rs0;
var primaryNode = replTest.getPrimary();
- // The $-prefixed query syntax is only legal for compatibility mode reads, not for the
- // find/getMore commands.
- if (useDollarQuerySyntax && st.s.getDB("test").getMongo().useReadCommands()) {
- st.stop();
- return;
- }
-
var setupConf = function() {
var replConf = primaryNode.getDB('local').system.replset.findOne();
replConf.version = (replConf.version || 0) + 1;
@@ -107,19 +100,7 @@ var doTest = function(useDollarQuerySyntax) {
});
var getExplain = function(readPrefMode, readPrefTags) {
- if (useDollarQuerySyntax) {
- var readPrefObj = {mode: readPrefMode};
-
- if (readPrefTags) {
- readPrefObj.tags = readPrefTags;
- }
-
- return coll.find({$query: {}, $readPreference: readPrefObj, $explain: true})
- .limit(-1)
- .next();
- } else {
- return coll.find().readPref(readPrefMode, readPrefTags).explain("executionStats");
- }
+ return coll.find().readPref(readPrefMode, readPrefTags).explain("executionStats");
};
var getExplainServer = function(explain) {
@@ -205,6 +186,5 @@ var doTest = function(useDollarQuerySyntax) {
st.stop();
};
-doTest(false);
-doTest(true);
+doTest();
})();
diff --git a/jstests/sharding/read_write_concern_defaults_application.js b/jstests/sharding/read_write_concern_defaults_application.js
index 477ec0bee83..709ee968f32 100644
--- a/jstests/sharding/read_write_concern_defaults_application.js
+++ b/jstests/sharding/read_write_concern_defaults_application.js
@@ -855,7 +855,7 @@ function runScenario(
// Do any test-specific setup.
if (typeof (test.setUp) === "function") {
- conn._runWithForcedReadMode("commands", test.setUp);
+ test.setUp(conn);
}
// Get the command from the test case.
diff --git a/jstests/sharding/sharding_rs2.js b/jstests/sharding/sharding_rs2.js
index ea5b8a7760c..ccb38cbfe3d 100644
--- a/jstests/sharding/sharding_rs2.js
+++ b/jstests/sharding/sharding_rs2.js
@@ -204,7 +204,6 @@ assert.lte(before.query + 10, after.query, "D3");
// by shard key
m = new Mongo(s.s.name);
-m.forceWriteMode("commands");
s.printShardingStatus();