summaryrefslogtreecommitdiff
path: root/jstests/sharding
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2022-11-17 19:04:21 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-17 20:02:18 +0000
commit20d43f94ce5e943971904f65f8abff1e8b67521f (patch)
tree3fef7261394ad0b2078708f89df032b3ecc9d25a /jstests/sharding
parentbe0adb109bfac64bc1177b7f43eb3a4accb6d3e9 (diff)
downloadmongo-20d43f94ce5e943971904f65f8abff1e8b67521f.tar.gz
SERVER-59302 Remove support in client code for commands wrapped with $query
The shell and internal client used to upconvert commands wrapped in a "$query" or "query" to a well-formed OP_MSG. This behavior is a holdover from when OP_QUERY was supported and is no longer needed.
Diffstat (limited to 'jstests/sharding')
-rw-r--r--jstests/sharding/features2.js16
-rw-r--r--jstests/sharding/query/explain_agg_read_pref.js24
-rw-r--r--jstests/sharding/query/view_rewrite.js16
-rw-r--r--jstests/sharding/read_pref_with_hedging_mode.js20
4 files changed, 34 insertions, 42 deletions
diff --git a/jstests/sharding/features2.js b/jstests/sharding/features2.js
index 1cae75c30ae..56fed8bbce2 100644
--- a/jstests/sharding/features2.js
+++ b/jstests/sharding/features2.js
@@ -157,25 +157,9 @@ db.countaa.save({"regex": /foo/i});
assert.eq(3, db.countaa.count(), "counta1");
assert.eq(3, db.countaa.find().itcount(), "counta1");
-// hello and query-wrapped-command
let hello = db.runCommand({hello: 1});
assert(hello.isWritablePrimary);
assert.eq('isdbgrid', hello.msg);
-delete hello.localTime;
-delete hello.$clusterTime;
-delete hello.operationTime;
-
-let hello2 = db.runCommand({query: {hello: 1}});
-delete hello2.localTime;
-delete hello2.$clusterTime;
-delete hello2.operationTime;
-assert.eq(hello, hello2);
-
-hello2 = db.runCommand({$query: {hello: 1}});
-delete hello2.localTime;
-delete hello2.$clusterTime;
-delete hello2.operationTime;
-assert.eq(hello, hello2);
s.stop();
})();
diff --git a/jstests/sharding/query/explain_agg_read_pref.js b/jstests/sharding/query/explain_agg_read_pref.js
index 57e5f639b1f..1735c1a1138 100644
--- a/jstests/sharding/query/explain_agg_read_pref.js
+++ b/jstests/sharding/query/explain_agg_read_pref.js
@@ -68,9 +68,12 @@ function confirmReadPreference(primary, secondary) {
//
let comment = name + "_explain_within_query";
assert.commandWorked(mongosDB.runCommand({
- query:
- {aggregate: "coll", pipeline: [], comment: comment, cursor: {}, explain: true},
- $readPreference: {mode: pref, tags: tagSets}
+ aggregate: "coll",
+ pipeline: [],
+ comment: comment,
+ cursor: {},
+ explain: true,
+ $readPreference: {mode: pref, tags: tagSets},
}));
// Look for an operation without an exception, since the shard throws a stale config
@@ -92,16 +95,17 @@ function confirmReadPreference(primary, secondary) {
}
});
- //
- // Tests that an aggregation command wrapped in an explain with explicit
- // $queryOptions targets the correct node in the replica set given by 'target'.
- //
+ // Tests that an aggregation command wrapped in an explain with explicit $readPreference
+ // targets the correct node in the replica set given by 'target'.
comment = name + "_explain_wrapped_agg";
assert.commandWorked(mongosDB.runCommand({
- $query: {
- explain: {aggregate: "coll", pipeline: [], cursor: {}, comment: comment},
+ explain: {
+ aggregate: "coll",
+ pipeline: [],
+ cursor: {},
+ comment: comment,
},
- $readPreference: {mode: pref, tags: tagSets}
+ $readPreference: {mode: pref, tags: tagSets},
}));
// Look for an operation without an exception, since the shard throws a stale config
diff --git a/jstests/sharding/query/view_rewrite.js b/jstests/sharding/query/view_rewrite.js
index dae49dc2b0b..f105f9f2e71 100644
--- a/jstests/sharding/query/view_rewrite.js
+++ b/jstests/sharding/query/view_rewrite.js
@@ -154,7 +154,10 @@ function confirmReadPreference(shardSecondary) {
// Aggregation
assert.commandWorked(mongosDB.runCommand({
- query: {aggregate: "view", pipeline: [], comment: "agg_readPref", cursor: {}},
+ aggregate: "view",
+ pipeline: [],
+ comment: "agg_readPref",
+ cursor: {},
$readPreference: {mode: "nearest", tags: [{tag: "secondary"}]},
readConcern: {level: "local"}
}));
@@ -172,7 +175,9 @@ function confirmReadPreference(shardSecondary) {
// Find
assert.commandWorked(mongosDB.runCommand({
- query: {find: "view", comment: "find_readPref", maxTimeMS: 5 * 60 * 1000},
+ find: "view",
+ comment: "find_readPref",
+ maxTimeMS: 5 * 60 * 1000,
$readPreference: {mode: "nearest", tags: [{tag: "secondary"}]},
readConcern: {level: "local"}
}));
@@ -190,7 +195,8 @@ function confirmReadPreference(shardSecondary) {
// Count
assert.commandWorked(mongosDB.runCommand({
- query: {count: "view", comment: "count_readPref"},
+ count: "view",
+ comment: "count_readPref",
$readPreference: {mode: "nearest", tags: [{tag: "secondary"}]},
readConcern: {level: "local"}
}));
@@ -208,7 +214,9 @@ function confirmReadPreference(shardSecondary) {
// Distinct
assert.commandWorked(mongosDB.runCommand({
- query: {distinct: "view", key: "a", comment: "distinct_readPref"},
+ distinct: "view",
+ key: "a",
+ comment: "distinct_readPref",
$readPreference: {mode: "nearest", tags: [{tag: "secondary"}]},
readConcern: {level: "local"}
}));
diff --git a/jstests/sharding/read_pref_with_hedging_mode.js b/jstests/sharding/read_pref_with_hedging_mode.js
index 05c890885ee..408d93e4ca7 100644
--- a/jstests/sharding/read_pref_with_hedging_mode.js
+++ b/jstests/sharding/read_pref_with_hedging_mode.js
@@ -16,12 +16,12 @@ assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {x: 1}}));
// Test "hedge" read preference validation.
assert.commandFailedWithCode(
- testDB.runCommand({query: {count: collName}, $readPreference: {mode: "primary", hedge: {}}}),
+ testDB.runCommand({count: collName, $readPreference: {mode: "primary", hedge: {}}}),
ErrorCodes.InvalidOptions);
assert.commandFailedWithCode(
testDB.runCommand(
- {query: {count: collName}, $readPreference: {mode: "secondaryPreferred", hedge: "_1"}}),
+ {count: collName, $readPreference: {mode: "secondaryPreferred", hedge: "_1"}}),
ErrorCodes.TypeMismatch);
// Test "readHedgingMode" server parameter validation.
@@ -33,21 +33,17 @@ assert.commandWorked(st.s.adminCommand({setParameter: 1, maxTimeMSForHedgedReads
// Test hedging with maxTimeMS.
assert.commandWorked(st.s.getDB(dbName).runCommand(
- {query: {find: collName, maxTimeMS: 1000}, $readPreference: {mode: "nearest", hedge: {}}}));
+ {find: collName, maxTimeMS: 1000, $readPreference: {mode: "nearest", hedge: {}}}));
// Test hedging without maxTimeMS.
-assert.commandWorked(st.s.getDB(dbName).runCommand({
- query: {count: collName},
- $readPreference: {mode: "secondaryPreferred", hedge: {enabled: true}}
-}));
+assert.commandWorked(st.s.getDB(dbName).runCommand(
+ {count: collName, $readPreference: {mode: "secondaryPreferred", hedge: {enabled: true}}}));
// Set "readHedgingMode" to "off", expect no hedging.
st.s.adminCommand({setParameter: 1, readHedgingMode: "off"});
-assert.commandWorked(st.s.getDB(dbName).runCommand({
- query: {distinct: collName, key: "x"},
- $readPreference: {mode: "primaryPreferred", hedge: {}}
-}));
+assert.commandWorked(st.s.getDB(dbName).runCommand(
+ {distinct: collName, key: "x", $readPreference: {mode: "primaryPreferred", hedge: {}}}));
st.stop();
-})();
+})(); \ No newline at end of file