summaryrefslogtreecommitdiff
path: root/jstests/core/write/update/update_with_large_hint.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/write/update/update_with_large_hint.js')
-rw-r--r--jstests/core/write/update/update_with_large_hint.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/jstests/core/write/update/update_with_large_hint.js b/jstests/core/write/update/update_with_large_hint.js
new file mode 100644
index 00000000000..0b2521337ce
--- /dev/null
+++ b/jstests/core/write/update/update_with_large_hint.js
@@ -0,0 +1,36 @@
+// Test that write size estimation in mongos respects 'hint' field.
+// @tags: [
+// requires_sharding,
+// ]
+(function() {
+"use strict";
+
+const coll = db.update_with_large_hint;
+coll.drop();
+
+const longHint = "x".repeat(1000);
+assert.commandWorked(coll.createIndex({[longHint]: 1}));
+assert.commandWorked(coll.insert({_id: 0}));
+
+assert.commandWorked(coll.runCommand("update", {
+ updates: [{q: {_id: 0}, u: {$set: {x: 1}}, hint: {[longHint]: 1}}],
+}));
+
+assert.commandWorked(coll.runCommand("delete", {
+ deletes: [{q: {_id: 0}, limit: 1, hint: {[longHint]: 1}}],
+}));
+
+assert.commandWorked(coll.dropIndexes());
+assert.commandWorked(coll.insert({_id: 0}));
+
+// Both commands should fail because hint does not correspond to the existing index.
+assert.commandFailedWithCode(coll.runCommand("update", {
+ updates: [{q: {_id: 0}, u: {$set: {x: 1}}, hint: {[longHint]: 1}}],
+}),
+ ErrorCodes.BadValue);
+
+assert.commandFailedWithCode(coll.runCommand("delete", {
+ deletes: [{q: {_id: 0}, limit: 1, hint: {[longHint]: 1}}],
+}),
+ ErrorCodes.BadValue);
+}()); \ No newline at end of file