summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorEddie Louie <eddie.louie@mongodb.com>2017-03-23 14:07:50 -0400
committerEddie Louie <eddie.louie@mongodb.com>2017-03-23 14:07:50 -0400
commit9fc1ecd711851cccee04fe14caf88db0c6523090 (patch)
tree9fe1653635dd12da022fff31555ab237af1cc4e0 /jstests
parentfb956b3b0a48c9b8376575c6adb971a4e0593292 (diff)
downloadmongo-9fc1ecd711851cccee04fe14caf88db0c6523090.tar.gz
SERVER-26315 Override DBCollection.prototype.drop to re-shard collections that are dropped
This reverts commit fb956b3b0a48c9b8376575c6adb971a4e0593292.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/aggregation/bugs/ifnull.js5
-rw-r--r--jstests/aggregation/bugs/server21632.js5
-rw-r--r--jstests/aggregation/bugs/server22093.js5
-rw-r--r--jstests/aggregation/bugs/server3253.js4
-rw-r--r--jstests/aggregation/bugs/server6192_server6193.js5
-rw-r--r--jstests/aggregation/expressions/collation_expressions.js3
-rw-r--r--jstests/aggregation/sources/bucket/collation_bucket.js3
-rw-r--r--jstests/aggregation/sources/bucketauto/collation_bucketauto.js3
-rw-r--r--jstests/aggregation/sources/facet/inner_graphlookup.js4
-rw-r--r--jstests/aggregation/sources/facet/inner_lookup.js4
-rw-r--r--jstests/aggregation/sources/geonear/collation_geonear.js3
-rw-r--r--jstests/aggregation/sources/graphLookup/airports.js4
-rw-r--r--jstests/aggregation/sources/graphLookup/basic.js4
-rw-r--r--jstests/aggregation/sources/graphLookup/collation_graphlookup.js4
-rw-r--r--jstests/aggregation/sources/graphLookup/error.js4
-rw-r--r--jstests/aggregation/sources/graphLookup/filter.js4
-rw-r--r--jstests/aggregation/sources/graphLookup/nested_objects.js4
-rw-r--r--jstests/aggregation/sources/graphLookup/socialite.js4
-rw-r--r--jstests/aggregation/sources/group/collation_group.js3
-rw-r--r--jstests/aggregation/sources/lookup/collation_lookup.js3
-rw-r--r--jstests/aggregation/sources/match/collation_match.js3
-rw-r--r--jstests/aggregation/sources/redact/collation_redact.js3
-rw-r--r--jstests/core/agg_hint.js4
-rw-r--r--jstests/core/and2.js5
-rw-r--r--jstests/core/autoid.js5
-rw-r--r--jstests/core/batch_write_collation_estsize.js5
-rw-r--r--jstests/core/batch_write_command_delete.js5
-rw-r--r--jstests/core/batch_write_command_insert.js4
-rw-r--r--jstests/core/batch_write_command_update.js5
-rw-r--r--jstests/core/bench_test1.js3
-rw-r--r--jstests/core/bulk_api_ordered.js4
-rw-r--r--jstests/core/bulk_api_unordered.js5
-rw-r--r--jstests/core/bulk_insert_capped.js4
-rw-r--r--jstests/core/collation.js4
-rw-r--r--jstests/core/collation_update.js4
-rw-r--r--jstests/core/collmod.js4
-rw-r--r--jstests/core/collmod_bad_spec.js4
-rw-r--r--jstests/core/commands_namespace_parsing.js5
-rw-r--r--jstests/core/count11.js4
-rw-r--r--jstests/core/coveredIndex1.js4
-rw-r--r--jstests/core/coveredIndex2.js5
-rw-r--r--jstests/core/covered_index_compound_1.js5
-rw-r--r--jstests/core/covered_index_simple_1.js5
-rw-r--r--jstests/core/covered_index_simple_2.js5
-rw-r--r--jstests/core/covered_index_simple_3.js5
-rw-r--r--jstests/core/covered_index_sort_1.js5
-rw-r--r--jstests/core/covered_index_sort_3.js5
-rw-r--r--jstests/core/covered_multikey.js5
-rw-r--r--jstests/core/create_collection.js4
-rw-r--r--jstests/core/crud_api.js5
-rw-r--r--jstests/core/datasize2.js4
-rw-r--r--jstests/core/doc_validation.js4
-rw-r--r--jstests/core/doc_validation_invalid_validators.js4
-rw-r--r--jstests/core/doc_validation_options.js4
-rw-r--r--jstests/core/drop.js4
-rw-r--r--jstests/core/drop_index.js3
-rw-r--r--jstests/core/ensure_sorted.js5
-rw-r--r--jstests/core/eval2.js3
-rw-r--r--jstests/core/eval3.js3
-rw-r--r--jstests/core/eval4.js3
-rw-r--r--jstests/core/eval_mr.js4
-rw-r--r--jstests/core/evald.js4
-rw-r--r--jstests/core/explain_agg_write_concern.js4
-rw-r--r--jstests/core/explain_distinct.js4
-rw-r--r--jstests/core/explain_find_and_modify.js4
-rw-r--r--jstests/core/explain_missing_collection.js4
-rw-r--r--jstests/core/explain_multi_plan.js5
-rw-r--r--jstests/core/explain_shell_helpers.js4
-rw-r--r--jstests/core/explain_upsert.js5
-rw-r--r--jstests/core/filemd5.js23
-rw-r--r--jstests/core/find_and_modify.js5
-rw-r--r--jstests/core/find_and_modify2.js5
-rw-r--r--jstests/core/find_and_modify3.js5
-rw-r--r--jstests/core/find_and_modify4.js5
-rw-r--r--jstests/core/find_and_modify_concurrent_update.js5
-rw-r--r--jstests/core/find_and_modify_empty_coll.js5
-rw-r--r--jstests/core/find_and_modify_empty_update.js5
-rw-r--r--jstests/core/find_and_modify_server6254.js4
-rw-r--r--jstests/core/find_and_modify_server6582.js4
-rw-r--r--jstests/core/find_and_modify_server6588.js4
-rw-r--r--jstests/core/find_and_modify_server6659.js4
-rw-r--r--jstests/core/find_and_modify_server6865.js5
-rw-r--r--jstests/core/find_and_modify_server6909.js5
-rw-r--r--jstests/core/find_and_modify_server6993.js4
-rw-r--r--jstests/core/find_and_modify_server7660.js4
-rw-r--r--jstests/core/find_and_modify_where.js4
-rw-r--r--jstests/core/fts1.js4
-rw-r--r--jstests/core/fts_blogwild.js4
-rw-r--r--jstests/core/fts_explain.js4
-rw-r--r--jstests/core/fts_index.js4
-rw-r--r--jstests/core/fts_index2.js4
-rw-r--r--jstests/core/fts_index3.js5
-rw-r--r--jstests/core/geo1.js3
-rw-r--r--jstests/core/geo10.js4
-rw-r--r--jstests/core/geo2.js3
-rw-r--r--jstests/core/geo3.js3
-rw-r--r--jstests/core/geo6.js3
-rw-r--r--jstests/core/geo9.js3
-rw-r--r--jstests/core/geo_array0.js4
-rw-r--r--jstests/core/geo_array2.js4
-rw-r--r--jstests/core/geo_borders.js4
-rw-r--r--jstests/core/geo_center_sphere2.js4
-rw-r--r--jstests/core/geo_distinct.js4
-rw-r--r--jstests/core/geo_exactfetch.js4
-rw-r--r--jstests/core/geo_group.js4
-rw-r--r--jstests/core/geo_max.js4
-rw-r--r--jstests/core/geo_mindistance.js4
-rw-r--r--jstests/core/geo_mindistance_boundaries.js4
-rw-r--r--jstests/core/geo_multinest0.js4
-rw-r--r--jstests/core/geo_multinest1.js4
-rw-r--r--jstests/core/geo_near_random1.js4
-rw-r--r--jstests/core/geo_near_random2.js4
-rw-r--r--jstests/core/geo_or.js4
-rw-r--r--jstests/core/geo_queryoptimizer.js3
-rw-r--r--jstests/core/geo_regex0.js4
-rw-r--r--jstests/core/geo_s2dedupnear.js4
-rw-r--r--jstests/core/geo_s2disjoint_holes.js4
-rw-r--r--jstests/core/geo_s2index.js4
-rw-r--r--jstests/core/geo_s2indexversion1.js4
-rw-r--r--jstests/core/geo_s2meridian.js4
-rw-r--r--jstests/core/geo_s2near.js4
-rw-r--r--jstests/core/geo_s2nearComplex.js4
-rw-r--r--jstests/core/geo_s2near_equator_opposite.js4
-rw-r--r--jstests/core/geo_s2nearcorrect.js4
-rw-r--r--jstests/core/geo_s2nongeoarray.js4
-rw-r--r--jstests/core/geo_s2nonstring.js4
-rw-r--r--jstests/core/geo_s2nopoints.js4
-rw-r--r--jstests/core/geo_small_large.js4
-rw-r--r--jstests/core/geo_sort1.js3
-rw-r--r--jstests/core/geo_uniqueDocs2.js4
-rw-r--r--jstests/core/geo_update.js5
-rw-r--r--jstests/core/geo_update_dedup.js4
-rw-r--r--jstests/core/geoa.js3
-rw-r--r--jstests/core/geoc.js3
-rw-r--r--jstests/core/geof.js4
-rw-r--r--jstests/core/getmore_cmd_maxtimems.js4
-rw-r--r--jstests/core/getmore_invalidation.js5
-rw-r--r--jstests/core/group1.js4
-rw-r--r--jstests/core/group2.js4
-rw-r--r--jstests/core/group3.js4
-rw-r--r--jstests/core/group4.js3
-rw-r--r--jstests/core/group5.js3
-rw-r--r--jstests/core/group6.js4
-rw-r--r--jstests/core/group8.js4
-rw-r--r--jstests/core/group9.js4
-rw-r--r--jstests/core/hashindex1.js4
-rw-r--r--jstests/core/in5.js3
-rw-r--r--jstests/core/inc-SERVER-7446.js5
-rw-r--r--jstests/core/inc3.js4
-rw-r--r--jstests/core/index3.js4
-rw-r--r--jstests/core/index4.js4
-rw-r--r--jstests/core/index8.js4
-rw-r--r--jstests/core/index9.js4
-rw-r--r--jstests/core/index_arr1.js4
-rw-r--r--jstests/core/index_big1.js4
-rw-r--r--jstests/core/index_bigkeys.js3
-rw-r--r--jstests/core/index_decimal.js5
-rw-r--r--jstests/core/index_dropdups_ignore.js4
-rw-r--r--jstests/core/index_filter_commands.js4
-rw-r--r--jstests/core/index_id_options.js4
-rw-r--r--jstests/core/index_many.js4
-rw-r--r--jstests/core/index_many2.js3
-rw-r--r--jstests/core/index_multiple_compatibility.js4
-rw-r--r--jstests/core/index_partial_create_drop.js4
-rw-r--r--jstests/core/index_partial_read_ops.js4
-rw-r--r--jstests/core/index_sparse1.js3
-rw-r--r--jstests/core/index_sparse2.js4
-rw-r--r--jstests/core/index_stats.js5
-rw-r--r--jstests/core/index_type_change.js5
-rw-r--r--jstests/core/indexa.js4
-rw-r--r--jstests/core/indexapi.js3
-rw-r--r--jstests/core/indexb.js4
-rw-r--r--jstests/core/indexes_multiple_commands.js4
-rw-r--r--jstests/core/insert2.js4
-rw-r--r--jstests/core/insert_id_undefined.js4
-rw-r--r--jstests/core/js3.js3
-rw-r--r--jstests/core/js9.js4
-rw-r--r--jstests/core/list_collections1.js4
-rw-r--r--jstests/core/list_indexes.js4
-rw-r--r--jstests/core/list_indexes_invalid.js68
-rw-r--r--jstests/core/list_indexes_invalidation.js4
-rw-r--r--jstests/core/mr2.js4
-rw-r--r--jstests/core/mr_bigobject_replace.js4
-rw-r--r--jstests/core/mr_errorhandling.js3
-rw-r--r--jstests/core/mr_killop.js5
-rw-r--r--jstests/core/mr_merge.js3
-rw-r--r--jstests/core/mr_merge2.js3
-rw-r--r--jstests/core/mr_outreduce.js3
-rw-r--r--jstests/core/mr_outreduce2.js3
-rw-r--r--jstests/core/mr_sort.js3
-rw-r--r--jstests/core/multikey_geonear.js4
-rw-r--r--jstests/core/or4.js4
-rw-r--r--jstests/core/projection_dotted_paths.js4
-rw-r--r--jstests/core/pull.js5
-rw-r--r--jstests/core/pull2.js4
-rw-r--r--jstests/core/pull_or.js4
-rw-r--r--jstests/core/pull_remove1.js4
-rw-r--r--jstests/core/pullall.js5
-rw-r--r--jstests/core/pullall2.js4
-rw-r--r--jstests/core/pushall.js5
-rw-r--r--jstests/core/remove8.js3
-rw-r--r--jstests/core/remove_justone.js4
-rw-r--r--jstests/core/return_key.js5
-rw-r--r--jstests/core/server1470.js4
-rw-r--r--jstests/core/set3.js4
-rw-r--r--jstests/core/set4.js4
-rw-r--r--jstests/core/set5.js4
-rw-r--r--jstests/core/set6.js4
-rw-r--r--jstests/core/set7.js5
-rw-r--r--jstests/core/set_type_change.js5
-rw-r--r--jstests/core/shell_writeconcern.js5
-rw-r--r--jstests/core/sortg.js4
-rw-r--r--jstests/core/splitvector.js4
-rw-r--r--jstests/core/uniqueness.js4
-rw-r--r--jstests/core/unset2.js5
-rw-r--r--jstests/core/update2.js5
-rw-r--r--jstests/core/update3.js5
-rw-r--r--jstests/core/update5.js4
-rw-r--r--jstests/core/update6.js4
-rw-r--r--jstests/core/update7.js4
-rw-r--r--jstests/core/update_addToSet.js4
-rw-r--r--jstests/core/update_arraymatch1.js4
-rw-r--r--jstests/core/update_arraymatch4.js4
-rw-r--r--jstests/core/update_arraymatch6.js5
-rw-r--r--jstests/core/update_arraymatch7.js5
-rw-r--r--jstests/core/update_arraymatch8.js5
-rw-r--r--jstests/core/update_bit_examples.js5
-rw-r--r--jstests/core/update_blank1.js4
-rw-r--r--jstests/core/update_currentdate_examples.js5
-rw-r--r--jstests/core/update_dbref.js5
-rw-r--r--jstests/core/update_mul_examples.js5
-rw-r--r--jstests/core/updatea.js4
-rw-r--r--jstests/core/updateb.js4
-rw-r--r--jstests/core/updated.js4
-rw-r--r--jstests/core/updatee.js5
-rw-r--r--jstests/core/updateg.js5
-rw-r--r--jstests/core/updateh.js5
-rw-r--r--jstests/core/updatei.js5
-rw-r--r--jstests/core/updatek.js5
-rw-r--r--jstests/core/updatem.js5
-rw-r--r--jstests/core/upsert_and.js5
-rw-r--r--jstests/core/upsert_fields.js5
-rw-r--r--jstests/core/upsert_shell.js5
-rw-r--r--jstests/core/verify_update_mods.js5
-rw-r--r--jstests/core/write_result.js5
-rw-r--r--jstests/libs/override_methods/implicitly_shard_accessed_collections.js44
246 files changed, 1080 insertions, 58 deletions
diff --git a/jstests/aggregation/bugs/ifnull.js b/jstests/aggregation/bugs/ifnull.js
index 8967ffe7ab7..e99fcc88d26 100644
--- a/jstests/aggregation/bugs/ifnull.js
+++ b/jstests/aggregation/bugs/ifnull.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// $ifNull returns the result of the first expression if not null or undefined, otherwise of the
// second expression.
load('jstests/aggregation/extras/utils.js');
diff --git a/jstests/aggregation/bugs/server21632.js b/jstests/aggregation/bugs/server21632.js
index c99834c6f73..944ca114ab6 100644
--- a/jstests/aggregation/bugs/server21632.js
+++ b/jstests/aggregation/bugs/server21632.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because the coll.stats() output from a mongod when
+// run against a sharded collection is wrapped in a "shards" object with keys for each shard.
+// @tags: [assumes_unsharded_collection]
+
// This test is designed to stress $sample, and any optimizations a storage engine might provide.
//
// A $sample stage as the first stage in a pipeline should ideally have a uniform distribution, so
@@ -26,6 +30,7 @@
// as a supported file type. (See: WT-2403 for details on forthcoming changes)
var storageEngine = jsTest.options().storageEngine || "wiredTiger";
+
if (storageEngine == "wiredTiger" && coll.stats().wiredTiger.type == 'lsm') {
return;
}
diff --git a/jstests/aggregation/bugs/server22093.js b/jstests/aggregation/bugs/server22093.js
index ff8fda9c666..b47d268cfa4 100644
--- a/jstests/aggregation/bugs/server22093.js
+++ b/jstests/aggregation/bugs/server22093.js
@@ -2,9 +2,12 @@
// from the input documents will tell the query planner to use a count scan, which is faster than an
// index scan. In this test file, we check this behavior through explain().
//
+// Cannot implicitly shard accessed collections because the explain output from a mongod when run
+// against a sharded collection is wrapped in a "shards" object with keys for each shard.
+//
// This test assumes that an initial $match will be absorbed by the query system, which will not
// happen if the $match is wrapped within a $facet stage.
-// @tags: [do_not_wrap_aggregations_in_facets]
+// @tags: [do_not_wrap_aggregations_in_facets,assumes_unsharded_collection]
load('jstests/libs/analyze_plan.js');
(function() {
diff --git a/jstests/aggregation/bugs/server3253.js b/jstests/aggregation/bugs/server3253.js
index 774712ecb2f..dcff3da3033 100644
--- a/jstests/aggregation/bugs/server3253.js
+++ b/jstests/aggregation/bugs/server3253.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for output collection of aggregation pipeline.
+// @tags: [assumes_unsharded_collection]
+
// server-3253 Unsharded support for $out
load('jstests/aggregation/extras/utils.js');
diff --git a/jstests/aggregation/bugs/server6192_server6193.js b/jstests/aggregation/bugs/server6192_server6193.js
index 8a3a5eb04ee..9b74bdb3b4d 100644
--- a/jstests/aggregation/bugs/server6192_server6193.js
+++ b/jstests/aggregation/bugs/server6192_server6193.js
@@ -1,9 +1,12 @@
// test short-circuiting of $and and $or in
// $project stages to a $const boolean
//
+// Cannot implicitly shard accessed collections because the explain output from a mongod when run
+// against a sharded collection is wrapped in a "shards" object with keys for each shard.
+//
// This test makes assumptions about how the explain output will be formatted, so cannot be
// transformed to be put inside a $facet stage.
-// @tags: [do_not_wrap_aggregations_in_facets]
+// @tags: [do_not_wrap_aggregations_in_facets,assumes_unsharded_collection]
var t = db.jstests_aggregation_server6192;
t.drop();
diff --git a/jstests/aggregation/expressions/collation_expressions.js b/jstests/aggregation/expressions/collation_expressions.js
index 99b6cb30105..93f2ada0197 100644
--- a/jstests/aggregation/expressions/collation_expressions.js
+++ b/jstests/aggregation/expressions/collation_expressions.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that expressions which make can make string comparisons respect the collation.
(function() {
"use strict";
diff --git a/jstests/aggregation/sources/bucket/collation_bucket.js b/jstests/aggregation/sources/bucket/collation_bucket.js
index b21ae778569..45f15402499 100644
--- a/jstests/aggregation/sources/bucket/collation_bucket.js
+++ b/jstests/aggregation/sources/bucket/collation_bucket.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that the $bucket stage defines and sorts buckets according to the collation.
(function() {
"use strict";
diff --git a/jstests/aggregation/sources/bucketauto/collation_bucketauto.js b/jstests/aggregation/sources/bucketauto/collation_bucketauto.js
index ded4ee1316d..4aafa6ea511 100644
--- a/jstests/aggregation/sources/bucketauto/collation_bucketauto.js
+++ b/jstests/aggregation/sources/bucketauto/collation_bucketauto.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that the $bucketAuto stage defines and sorts buckets according to the collation.
(function() {
"use strict";
diff --git a/jstests/aggregation/sources/facet/inner_graphlookup.js b/jstests/aggregation/sources/facet/inner_graphlookup.js
index 42d10149240..870bb975a8a 100644
--- a/jstests/aggregation/sources/facet/inner_graphlookup.js
+++ b/jstests/aggregation/sources/facet/inner_graphlookup.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
/**
* Tests that using a $graphLookup stage inside of a $facet stage will yield the same results as
* using the $graphLookup stage outside of the $facet stage.
diff --git a/jstests/aggregation/sources/facet/inner_lookup.js b/jstests/aggregation/sources/facet/inner_lookup.js
index f4890324b65..c53bfa2b48e 100644
--- a/jstests/aggregation/sources/facet/inner_lookup.js
+++ b/jstests/aggregation/sources/facet/inner_lookup.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
/**
* Tests that using a $lookup stage inside of a $facet stage will yield the same results as using
* the $lookup stage outside of the $facet stage.
diff --git a/jstests/aggregation/sources/geonear/collation_geonear.js b/jstests/aggregation/sources/geonear/collation_geonear.js
index 38a20d847b7..076e0a8bea8 100644
--- a/jstests/aggregation/sources/geonear/collation_geonear.js
+++ b/jstests/aggregation/sources/geonear/collation_geonear.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that the $geoNear stage's query predicate respects the collation.
(function() {
"use strict";
diff --git a/jstests/aggregation/sources/graphLookup/airports.js b/jstests/aggregation/sources/graphLookup/airports.js
index 71a38e268b8..9254fd992fa 100644
--- a/jstests/aggregation/sources/graphLookup/airports.js
+++ b/jstests/aggregation/sources/graphLookup/airports.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
// In MongoDB 3.4, $graphLookup was introduced. In this file, we test some complex graphs.
(function() {
diff --git a/jstests/aggregation/sources/graphLookup/basic.js b/jstests/aggregation/sources/graphLookup/basic.js
index 63b2a63f95a..c0bcb1a8a53 100644
--- a/jstests/aggregation/sources/graphLookup/basic.js
+++ b/jstests/aggregation/sources/graphLookup/basic.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
// In MongoDB 3.4, $graphLookup was introduced. In this file, we test basic behavior and correctness
// of the stage.
diff --git a/jstests/aggregation/sources/graphLookup/collation_graphlookup.js b/jstests/aggregation/sources/graphLookup/collation_graphlookup.js
index 833b2f2d771..7b457289cc6 100644
--- a/jstests/aggregation/sources/graphLookup/collation_graphlookup.js
+++ b/jstests/aggregation/sources/graphLookup/collation_graphlookup.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
/**
* Tests that the $graphLookup stage respects the collation when matching between the
* 'connectFromField' and the 'connectToField'. $graphLookup should use the collation
diff --git a/jstests/aggregation/sources/graphLookup/error.js b/jstests/aggregation/sources/graphLookup/error.js
index a686fb30945..6e050105782 100644
--- a/jstests/aggregation/sources/graphLookup/error.js
+++ b/jstests/aggregation/sources/graphLookup/error.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
// In MongoDB 3.4, $graphLookup was introduced. In this file, we test the error cases.
load("jstests/aggregation/extras/utils.js"); // For "assertErrorCode".
diff --git a/jstests/aggregation/sources/graphLookup/filter.js b/jstests/aggregation/sources/graphLookup/filter.js
index edf1deda331..15ff6d4a4ae 100644
--- a/jstests/aggregation/sources/graphLookup/filter.js
+++ b/jstests/aggregation/sources/graphLookup/filter.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
// In SERVER-24714, the 'restrictSearchWithMatch' option was added to $graphLookup. In this file,
// we test the functionality and correctness of the option.
diff --git a/jstests/aggregation/sources/graphLookup/nested_objects.js b/jstests/aggregation/sources/graphLookup/nested_objects.js
index b2e3f5ac59a..d40cced2ac4 100644
--- a/jstests/aggregation/sources/graphLookup/nested_objects.js
+++ b/jstests/aggregation/sources/graphLookup/nested_objects.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
// In MongoDB 3.4, $graphLookup was introduced. In this file, we test the behavior of graphLookup
// when the 'connectToField' is a nested array, or when the 'connectFromField' is a nested array.
diff --git a/jstests/aggregation/sources/graphLookup/socialite.js b/jstests/aggregation/sources/graphLookup/socialite.js
index 6efe2672540..228c0f56c0e 100644
--- a/jstests/aggregation/sources/graphLookup/socialite.js
+++ b/jstests/aggregation/sources/graphLookup/socialite.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for target collection of $lookup and $graphLookup.
+// @tags: [assumes_unsharded_collection]
+
// In MongoDB 3.4, $graphLookup was introduced. In this file, we test $graphLookup as applied to the
// Socialite schema example available here: https://github.com/mongodb-labs/socialite
diff --git a/jstests/aggregation/sources/group/collation_group.js b/jstests/aggregation/sources/group/collation_group.js
index 4bf02ee5c97..c4977900078 100644
--- a/jstests/aggregation/sources/group/collation_group.js
+++ b/jstests/aggregation/sources/group/collation_group.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that the $group stage and all accumulators respect the collation.
(function() {
"use strict";
diff --git a/jstests/aggregation/sources/lookup/collation_lookup.js b/jstests/aggregation/sources/lookup/collation_lookup.js
index cf1b742c367..89a0b21c038 100644
--- a/jstests/aggregation/sources/lookup/collation_lookup.js
+++ b/jstests/aggregation/sources/lookup/collation_lookup.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
/**
* Tests that the $lookup stage respects the collation.
*
diff --git a/jstests/aggregation/sources/match/collation_match.js b/jstests/aggregation/sources/match/collation_match.js
index 7136e03f9da..bc9456898f9 100644
--- a/jstests/aggregation/sources/match/collation_match.js
+++ b/jstests/aggregation/sources/match/collation_match.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that the $match stage respects the collation.
(function() {
"use strict";
diff --git a/jstests/aggregation/sources/redact/collation_redact.js b/jstests/aggregation/sources/redact/collation_redact.js
index d990c78959a..36304e9a7f2 100644
--- a/jstests/aggregation/sources/redact/collation_redact.js
+++ b/jstests/aggregation/sources/redact/collation_redact.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that the $redact stage respects the collation.
(function() {
"use strict";
diff --git a/jstests/core/agg_hint.js b/jstests/core/agg_hint.js
index a73e2593936..e578448d4d6 100644
--- a/jstests/core/agg_hint.js
+++ b/jstests/core/agg_hint.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Confirms correct behavior for hinted aggregation execution. This includes tests for scenarios
// where agg execution differs from query. It also includes confirmation that hint works for find
// command against views, which is converted to a hinted aggregation on execution.
diff --git a/jstests/core/and2.js b/jstests/core/and2.js
index a794268130b..5a946c2cb76 100644
--- a/jstests/core/and2.js
+++ b/jstests/core/and2.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Test dollar sign operator with $and SERVER-1089
t = db.jstests_and2;
diff --git a/jstests/core/autoid.js b/jstests/core/autoid.js
index f4707e5fe65..679b109fcc5 100644
--- a/jstests/core/autoid.js
+++ b/jstests/core/autoid.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
f = db.jstests_autoid;
f.drop();
diff --git a/jstests/core/batch_write_collation_estsize.js b/jstests/core/batch_write_collation_estsize.js
index 944b2094696..594517da9f9 100644
--- a/jstests/core/batch_write_collation_estsize.js
+++ b/jstests/core/batch_write_collation_estsize.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Tests that the update and delete batch write operations account for the size of the collation
// specification in the write operation document.
diff --git a/jstests/core/batch_write_command_delete.js b/jstests/core/batch_write_command_delete.js
index 232fa1839a1..b11b4f192d2 100644
--- a/jstests/core/batch_write_command_delete.js
+++ b/jstests/core/batch_write_command_delete.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
//
// Ensures that mongod respects the batch write protocols for delete
//
diff --git a/jstests/core/batch_write_command_insert.js b/jstests/core/batch_write_command_insert.js
index afbe0eed0ff..0997109736b 100644
--- a/jstests/core/batch_write_command_insert.js
+++ b/jstests/core/batch_write_command_insert.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of not being able to create unique index
+// using hashed shard key pattern.
+// @tags: [cannot_create_unique_index_when_using_hashed_shard_key]
+
//
// Ensures that mongod respects the batch write protocol for inserts
//
diff --git a/jstests/core/batch_write_command_update.js b/jstests/core/batch_write_command_update.js
index ead2275399c..3ac6201cce5 100644
--- a/jstests/core/batch_write_command_update.js
+++ b/jstests/core/batch_write_command_update.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
//
// Ensures that mongod respects the batch write protocols for updates
//
diff --git a/jstests/core/bench_test1.js b/jstests/core/bench_test1.js
index d29a0d577e7..2f35be513fc 100644
--- a/jstests/core/bench_test1.js
+++ b/jstests/core/bench_test1.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
t = db.bench_test1;
t.drop();
diff --git a/jstests/core/bulk_api_ordered.js b/jstests/core/bulk_api_ordered.js
index a880cdb630e..4efdd7c319b 100644
--- a/jstests/core/bulk_api_ordered.js
+++ b/jstests/core/bulk_api_ordered.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
var collectionName = "bulk_api_ordered";
var coll = db.getCollection(collectionName);
diff --git a/jstests/core/bulk_api_unordered.js b/jstests/core/bulk_api_unordered.js
index 6720e644e47..8e2ca7a7157 100644
--- a/jstests/core/bulk_api_unordered.js
+++ b/jstests/core/bulk_api_unordered.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
var collectionName = "bulk_api_unordered";
var coll = db.getCollection(collectionName);
coll.drop();
diff --git a/jstests/core/bulk_insert_capped.js b/jstests/core/bulk_insert_capped.js
index b7d21cee3f5..a54b94c5022 100644
--- a/jstests/core/bulk_insert_capped.js
+++ b/jstests/core/bulk_insert_capped.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// SERVER-21488 Test that multi inserts into capped collections don't cause corruption.
// Note: this file must have a name that starts with "bulk" so it gets run by bulk_gle_passthrough.
(function() {
diff --git a/jstests/core/collation.js b/jstests/core/collation.js
index 51bec0f8bce..f73ea604650 100644
--- a/jstests/core/collation.js
+++ b/jstests/core/collation.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Integration tests for the collation feature.
(function() {
'use strict';
diff --git a/jstests/core/collation_update.js b/jstests/core/collation_update.js
index 15d205c9984..a48e9c85d1a 100644
--- a/jstests/core/collation_update.js
+++ b/jstests/core/collation_update.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Integration tests for collation-aware updates.
(function() {
'use strict';
diff --git a/jstests/core/collmod.js b/jstests/core/collmod.js
index 16f9694560c..8ed2ee503e4 100644
--- a/jstests/core/collmod.js
+++ b/jstests/core/collmod.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Basic js tests for the collMod command.
// Test setting the usePowerOf2Sizes flag, and modifying TTL indexes.
diff --git a/jstests/core/collmod_bad_spec.js b/jstests/core/collmod_bad_spec.js
index ccce81fd4b1..0402a248f30 100644
--- a/jstests/core/collmod_bad_spec.js
+++ b/jstests/core/collmod_bad_spec.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// This is a regression test for SERVER-21545.
//
// Tests that a collMod with a bad specification does not cause any changes, and does not crash the
diff --git a/jstests/core/commands_namespace_parsing.js b/jstests/core/commands_namespace_parsing.js
index c5e6cd3a285..9f5fd2ffe26 100644
--- a/jstests/core/commands_namespace_parsing.js
+++ b/jstests/core/commands_namespace_parsing.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because the error response from the shard about
+// using the empty string as the out collection name is converted to an error and no longer retains
+// the "code" property.
+// @tags: [assumes_unsharded_collection]
+
// This file tests that commands namespace parsing rejects embedded null bytes.
// Note that for each command, a properly formatted command object must be passed to the helper
// function, regardless of the namespace used in the command object.
diff --git a/jstests/core/count11.js b/jstests/core/count11.js
index aeda1e4b1cf..1a9c89f3357 100644
--- a/jstests/core/count11.js
+++ b/jstests/core/count11.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// SERVER-8514: Test the count command returns an error to the user when given an invalid query
// predicate, even when the collection doesn't exist.
diff --git a/jstests/core/coveredIndex1.js b/jstests/core/coveredIndex1.js
index 328c53ba0bc..1e982f0a8ea 100644
--- a/jstests/core/coveredIndex1.js
+++ b/jstests/core/coveredIndex1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
t = db["jstests_coveredIndex1"];
t.drop();
diff --git a/jstests/core/coveredIndex2.js b/jstests/core/coveredIndex2.js
index f7b542008f3..058b739fba2 100644
--- a/jstests/core/coveredIndex2.js
+++ b/jstests/core/coveredIndex2.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
t = db["jstests_coveredIndex2"];
t.drop();
diff --git a/jstests/core/covered_index_compound_1.js b/jstests/core/covered_index_compound_1.js
index 45f17fd7d44..ba2c9b6ecc5 100644
--- a/jstests/core/covered_index_compound_1.js
+++ b/jstests/core/covered_index_compound_1.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
// Compound index covered query tests
// Include helpers for analyzing explain output.
diff --git a/jstests/core/covered_index_simple_1.js b/jstests/core/covered_index_simple_1.js
index 3827ef4acfc..b9e33f650dd 100644
--- a/jstests/core/covered_index_simple_1.js
+++ b/jstests/core/covered_index_simple_1.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
// Simple covered index query test
// Include helpers for analyzing explain output.
diff --git a/jstests/core/covered_index_simple_2.js b/jstests/core/covered_index_simple_2.js
index 0c947849703..0974ee0eb50 100644
--- a/jstests/core/covered_index_simple_2.js
+++ b/jstests/core/covered_index_simple_2.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
// Simple covered index query test with unique index
// Include helpers for analyzing explain output.
diff --git a/jstests/core/covered_index_simple_3.js b/jstests/core/covered_index_simple_3.js
index e445396c4c8..7d021a17ca8 100644
--- a/jstests/core/covered_index_simple_3.js
+++ b/jstests/core/covered_index_simple_3.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
// Simple covered index query test with a unique sparse index
// Include helpers for analyzing explain output.
diff --git a/jstests/core/covered_index_sort_1.js b/jstests/core/covered_index_sort_1.js
index a5984a34f19..a65cc415ea4 100644
--- a/jstests/core/covered_index_sort_1.js
+++ b/jstests/core/covered_index_sort_1.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
// Simple covered index query test with sort
// Include helpers for analyzing explain output.
diff --git a/jstests/core/covered_index_sort_3.js b/jstests/core/covered_index_sort_3.js
index 1c98fb69be4..b93b25f02a3 100644
--- a/jstests/core/covered_index_sort_3.js
+++ b/jstests/core/covered_index_sort_3.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
// Compound index covered query tests with sort
// Include helpers for analyzing explain output.
diff --git a/jstests/core/covered_multikey.js b/jstests/core/covered_multikey.js
index ebffcafbe23..db1aaf9c525 100644
--- a/jstests/core/covered_multikey.js
+++ b/jstests/core/covered_multikey.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
/**
* Test covering behavior for queries over a multikey index.
*/
diff --git a/jstests/core/create_collection.js b/jstests/core/create_collection.js
index 2af8bc721a2..2ebbd4c0335 100644
--- a/jstests/core/create_collection.js
+++ b/jstests/core/create_collection.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Tests for the "create" command.
(function() {
"use strict";
diff --git a/jstests/core/crud_api.js b/jstests/core/crud_api.js
index c9dbfb40c85..abf40389a43 100644
--- a/jstests/core/crud_api.js
+++ b/jstests/core/crud_api.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
(function() {
"use strict";
diff --git a/jstests/core/datasize2.js b/jstests/core/datasize2.js
index eb79b12a6c4..a64bb62c287 100644
--- a/jstests/core/datasize2.js
+++ b/jstests/core/datasize2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because the "dataSize" command returns an
+// "keyPattern must equal shard key" error response.
+// @tags: [assumes_unsharded_collection]
+
//
// Test dataSize command, when called on the same or different database
// than the collection being queried.
diff --git a/jstests/core/doc_validation.js b/jstests/core/doc_validation.js
index a30763869e7..7a3dc5f038d 100644
--- a/jstests/core/doc_validation.js
+++ b/jstests/core/doc_validation.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test basic inserts and updates with document validation.
(function() {
"use strict";
diff --git a/jstests/core/doc_validation_invalid_validators.js b/jstests/core/doc_validation_invalid_validators.js
index b78b31c0977..45cfa7c2cf4 100644
--- a/jstests/core/doc_validation_invalid_validators.js
+++ b/jstests/core/doc_validation_invalid_validators.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Verify invalid validator statements won't work and that we
// can't create validated collections on restricted databases.
(function() {
diff --git a/jstests/core/doc_validation_options.js b/jstests/core/doc_validation_options.js
index 8a96685e48f..8e4f34c3602 100644
--- a/jstests/core/doc_validation_options.js
+++ b/jstests/core/doc_validation_options.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
(function() {
"use strict";
diff --git a/jstests/core/drop.js b/jstests/core/drop.js
index 22ed97ad805..789c87bf227 100644
--- a/jstests/core/drop.js
+++ b/jstests/core/drop.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
var coll = db.jstests_drop;
coll.drop();
diff --git a/jstests/core/drop_index.js b/jstests/core/drop_index.js
index f2e99baa8f8..cf333cf738c 100644
--- a/jstests/core/drop_index.js
+++ b/jstests/core/drop_index.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
t = db.dropIndex;
t.drop();
diff --git a/jstests/core/ensure_sorted.js b/jstests/core/ensure_sorted.js
index c3d8f075f5d..13c48708aff 100644
--- a/jstests/core/ensure_sorted.js
+++ b/jstests/core/ensure_sorted.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// SERVER-17011 Tests whether queries which specify sort and batch size can generate results out of
// order due to the ntoreturn hack. The EnsureSortedStage should solve this problem.
(function() {
diff --git a/jstests/core/eval2.js b/jstests/core/eval2.js
index 598314a6c5b..6c0fc1f58e9 100644
--- a/jstests/core/eval2.js
+++ b/jstests/core/eval2.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
t = db.eval2;
t.drop();
diff --git a/jstests/core/eval3.js b/jstests/core/eval3.js
index c4f8be21056..8cdd3723977 100644
--- a/jstests/core/eval3.js
+++ b/jstests/core/eval3.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// from db.eval.
+// @tags: [assumes_unsharded_collection]
t = db.eval3;
t.drop();
diff --git a/jstests/core/eval4.js b/jstests/core/eval4.js
index 0d120b393de..b67aa4b4445 100644
--- a/jstests/core/eval4.js
+++ b/jstests/core/eval4.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// from db.eval.
+// @tags: [assumes_unsharded_collection]
t = db.eval4;
t.drop();
diff --git a/jstests/core/eval_mr.js b/jstests/core/eval_mr.js
index 4a3dc8dad6c..04de66affb0 100644
--- a/jstests/core/eval_mr.js
+++ b/jstests/core/eval_mr.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: Cannot output to a
+// non-sharded collection because sharded collection exists already.
+// @tags: [assumes_unsharded_collection]
+
// Test that the eval command can't be used to invoke the mapReduce command. SERVER-17889.
(function() {
"use strict";
diff --git a/jstests/core/evald.js b/jstests/core/evald.js
index 8049d2ba8ae..bc381d7314c 100644
--- a/jstests/core/evald.js
+++ b/jstests/core/evald.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// from db.eval.
+// @tags: [assumes_unsharded_collection]
+
t = db.jstests_evald;
t.drop();
diff --git a/jstests/core/explain_agg_write_concern.js b/jstests/core/explain_agg_write_concern.js
index 3a70040a525..7a73bee79cf 100644
--- a/jstests/core/explain_agg_write_concern.js
+++ b/jstests/core/explain_agg_write_concern.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// for output collection of aggregation pipeline.
+// @tags: [assumes_unsharded_collection]
+
/**
* Tests related to the aggregate commands behavior with writeConcern and writeConcern + explain.
*/
diff --git a/jstests/core/explain_distinct.js b/jstests/core/explain_distinct.js
index 6fd0a012205..4cc9eab4eab 100644
--- a/jstests/core/explain_distinct.js
+++ b/jstests/core/explain_distinct.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
/**
* This test ensures that explain on the distinct command works.
*/
diff --git a/jstests/core/explain_find_and_modify.js b/jstests/core/explain_find_and_modify.js
index 1d30486ecb4..3c061084962 100644
--- a/jstests/core/explain_find_and_modify.js
+++ b/jstests/core/explain_find_and_modify.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
/**
* Test correctness of explaining findAndModify. Asserts the following:
*
diff --git a/jstests/core/explain_missing_collection.js b/jstests/core/explain_missing_collection.js
index 0d1eae844f8..458b15c6a80 100644
--- a/jstests/core/explain_missing_collection.js
+++ b/jstests/core/explain_missing_collection.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
+
// Test explain of various operations against a non-existent collection
(function() {
var missingColl = db.explain_null_collection;
diff --git a/jstests/core/explain_multi_plan.js b/jstests/core/explain_multi_plan.js
index 693237d9edc..a41a4f0e67b 100644
--- a/jstests/core/explain_multi_plan.js
+++ b/jstests/core/explain_multi_plan.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
/**
* Tests running explain on a variety of explainable commands (find, update, remove, etc.) when
* there are multiple plans available. This is a regression test for SERVER-20849 and SERVER-21376.
diff --git a/jstests/core/explain_shell_helpers.js b/jstests/core/explain_shell_helpers.js
index b5f50437304..cfeb9451567 100644
--- a/jstests/core/explain_shell_helpers.js
+++ b/jstests/core/explain_shell_helpers.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because the explain output from a mongod when run
+// against a sharded collection is wrapped in a "shards" object with keys for each shard.
+// @tags: [assumes_unsharded_collection]
+
// Tests for the .explain() shell helper, which provides syntactic sugar for the explain command.
var t = db.jstests_explain_helpers;
diff --git a/jstests/core/explain_upsert.js b/jstests/core/explain_upsert.js
index 1ac254291f1..aab8758366a 100644
--- a/jstests/core/explain_upsert.js
+++ b/jstests/core/explain_upsert.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Test explain for {upsert: true} updates.
var t = db.jstests_explain_upsert;
diff --git a/jstests/core/filemd5.js b/jstests/core/filemd5.js
index b43dccf7036..cbcdfe6b3dc 100644
--- a/jstests/core/filemd5.js
+++ b/jstests/core/filemd5.js
@@ -1,10 +1,13 @@
-
-db.fs.chunks.drop();
-db.fs.chunks.insert({files_id: 1, n: 0, data: new BinData(0, "test")});
-
-x = db.runCommand({"filemd5": 1, "root": "fs"});
-assert(!x.ok, tojson(x));
-
-db.fs.chunks.ensureIndex({files_id: 1, n: 1});
-x = db.runCommand({"filemd5": 1, "root": "fs"});
-assert(x.ok, tojson(x));
+// Cannot implicitly shard accessed collections because of following error: GridFS fs.chunks
+// collection must be sharded on either {files_id:1} or {files_id:1, n:1}
+// @tags: [assumes_unsharded_collection]
+
+db.fs.chunks.drop();
+db.fs.chunks.insert({files_id: 1, n: 0, data: new BinData(0, "test")});
+
+x = db.runCommand({"filemd5": 1, "root": "fs"});
+assert(!x.ok, tojson(x));
+
+db.fs.chunks.ensureIndex({files_id: 1, n: 1});
+x = db.runCommand({"filemd5": 1, "root": "fs"});
+assert(x.ok, tojson(x));
diff --git a/jstests/core/find_and_modify.js b/jstests/core/find_and_modify.js
index 394b618f109..e86ba4eec31 100644
--- a/jstests/core/find_and_modify.js
+++ b/jstests/core/find_and_modify.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
t = db.find_and_modify;
t.drop();
diff --git a/jstests/core/find_and_modify2.js b/jstests/core/find_and_modify2.js
index e9bc8f5b23a..a73dcb5fda5 100644
--- a/jstests/core/find_and_modify2.js
+++ b/jstests/core/find_and_modify2.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
t = db.find_and_modify2;
t.drop();
diff --git a/jstests/core/find_and_modify3.js b/jstests/core/find_and_modify3.js
index a1a88aeecb5..3f8fc22d98d 100644
--- a/jstests/core/find_and_modify3.js
+++ b/jstests/core/find_and_modify3.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
t = db.find_and_modify3;
t.drop();
diff --git a/jstests/core/find_and_modify4.js b/jstests/core/find_and_modify4.js
index b6be565b70a..0c6942ab055 100644
--- a/jstests/core/find_and_modify4.js
+++ b/jstests/core/find_and_modify4.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
t = db.find_and_modify4;
t.drop();
diff --git a/jstests/core/find_and_modify_concurrent_update.js b/jstests/core/find_and_modify_concurrent_update.js
index 3986ac62ea9..ead81732ecc 100644
--- a/jstests/core/find_and_modify_concurrent_update.js
+++ b/jstests/core/find_and_modify_concurrent_update.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Ensures that find and modify will not apply an update to a document which, due to a concurrent
// modification, no longer matches the query predicate.
(function() {
diff --git a/jstests/core/find_and_modify_empty_coll.js b/jstests/core/find_and_modify_empty_coll.js
index 2d3a2ee8ffd..7325d73583e 100644
--- a/jstests/core/find_and_modify_empty_coll.js
+++ b/jstests/core/find_and_modify_empty_coll.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
/**
* Test that findAndModify works against a non-existent collection.
*/
diff --git a/jstests/core/find_and_modify_empty_update.js b/jstests/core/find_and_modify_empty_update.js
index ccfb1a8201f..a9b8cb55b34 100644
--- a/jstests/core/find_and_modify_empty_update.js
+++ b/jstests/core/find_and_modify_empty_update.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Test passing update:{} to findAndModify. SERVER-13883.
var coll = db.find_and_modify_empty_update;
diff --git a/jstests/core/find_and_modify_server6254.js b/jstests/core/find_and_modify_server6254.js
index c2bfa3628a1..1eca30e31a9 100644
--- a/jstests/core/find_and_modify_server6254.js
+++ b/jstests/core/find_and_modify_server6254.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.find_and_modify_server6254;
t.drop();
diff --git a/jstests/core/find_and_modify_server6582.js b/jstests/core/find_and_modify_server6582.js
index 79a0b31d4ed..7ad8aebee76 100644
--- a/jstests/core/find_and_modify_server6582.js
+++ b/jstests/core/find_and_modify_server6582.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.find_and_modify_server6582;
diff --git a/jstests/core/find_and_modify_server6588.js b/jstests/core/find_and_modify_server6588.js
index 9c546daba72..197c892ca67 100644
--- a/jstests/core/find_and_modify_server6588.js
+++ b/jstests/core/find_and_modify_server6588.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.find_and_modify_sever6588;
diff --git a/jstests/core/find_and_modify_server6659.js b/jstests/core/find_and_modify_server6659.js
index 6b3f958c0e0..029a32d6a49 100644
--- a/jstests/core/find_and_modify_server6659.js
+++ b/jstests/core/find_and_modify_server6659.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.find_and_modify_server6659;
t.drop();
diff --git a/jstests/core/find_and_modify_server6865.js b/jstests/core/find_and_modify_server6865.js
index 3583da42412..98e5b28ee47 100644
--- a/jstests/core/find_and_modify_server6865.js
+++ b/jstests/core/find_and_modify_server6865.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
/**
* Test that projection with a positional operator works with findAndModify
* when remove=true or new=false, but not when new=true.
diff --git a/jstests/core/find_and_modify_server6909.js b/jstests/core/find_and_modify_server6909.js
index 8e807e0c893..c74e342822b 100644
--- a/jstests/core/find_and_modify_server6909.js
+++ b/jstests/core/find_and_modify_server6909.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
c = db.find_and_modify_server6906;
c.drop();
diff --git a/jstests/core/find_and_modify_server6993.js b/jstests/core/find_and_modify_server6993.js
index bf8ed52c9c7..4d9b169700d 100644
--- a/jstests/core/find_and_modify_server6993.js
+++ b/jstests/core/find_and_modify_server6993.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
c = db.find_and_modify_server6993;
c.drop();
diff --git a/jstests/core/find_and_modify_server7660.js b/jstests/core/find_and_modify_server7660.js
index d344d773dca..7973279ddcf 100644
--- a/jstests/core/find_and_modify_server7660.js
+++ b/jstests/core/find_and_modify_server7660.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.find_and_modify_server7660;
t.drop();
diff --git a/jstests/core/find_and_modify_where.js b/jstests/core/find_and_modify_where.js
index e3d5604559a..f4977c6565e 100644
--- a/jstests/core/find_and_modify_where.js
+++ b/jstests/core/find_and_modify_where.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.find_and_modify_where;
t.drop();
diff --git a/jstests/core/fts1.js b/jstests/core/fts1.js
index 23364b2ecb7..5f507733b05 100644
--- a/jstests/core/fts1.js
+++ b/jstests/core/fts1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
load("jstests/libs/fts.js");
t = db.text1;
diff --git a/jstests/core/fts_blogwild.js b/jstests/core/fts_blogwild.js
index 377e4529f3e..82cb594bab6 100644
--- a/jstests/core/fts_blogwild.js
+++ b/jstests/core/fts_blogwild.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
t = db.text_blogwild;
t.drop();
diff --git a/jstests/core/fts_explain.js b/jstests/core/fts_explain.js
index 225be626d2c..b8c507f1a60 100644
--- a/jstests/core/fts_explain.js
+++ b/jstests/core/fts_explain.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// Test $text explain. SERVER-12037.
var coll = db.fts_explain;
diff --git a/jstests/core/fts_index.js b/jstests/core/fts_index.js
index ab953a88624..45ed68ce6c6 100644
--- a/jstests/core/fts_index.js
+++ b/jstests/core/fts_index.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that:
// 1. Text indexes properly validate the index spec used to create them.
// 2. Text indexes properly enforce a schema on the language_override field.
diff --git a/jstests/core/fts_index2.js b/jstests/core/fts_index2.js
index fa0129acc5c..ecae5edb3a8 100644
--- a/jstests/core/fts_index2.js
+++ b/jstests/core/fts_index2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because renameCollection command not supported
+// on sharded collections.
+// @tags: [assumes_unsharded_collection]
+
// Test that collections with text indexes can be renamed. SERVER-14027.
var coll1 = db.fts_index2;
diff --git a/jstests/core/fts_index3.js b/jstests/core/fts_index3.js
index bb94704eaf9..1a700b3ed7b 100644
--- a/jstests/core/fts_index3.js
+++ b/jstests/core/fts_index3.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Test that updates to fields in a text-indexed document are correctly reflected in the text index.
var coll = db.fts_index3;
diff --git a/jstests/core/geo1.js b/jstests/core/geo1.js
index 724ae31a3ce..c33a5f8919c 100644
--- a/jstests/core/geo1.js
+++ b/jstests/core/geo1.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
t = db.geo1;
t.drop();
diff --git a/jstests/core/geo10.js b/jstests/core/geo10.js
index 640ae67e594..9b0fb42c2b5 100644
--- a/jstests/core/geo10.js
+++ b/jstests/core/geo10.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// Test for SERVER-2746
coll = db.geo10;
diff --git a/jstests/core/geo2.js b/jstests/core/geo2.js
index 0b7e91c18bc..f4e8a5bbd54 100644
--- a/jstests/core/geo2.js
+++ b/jstests/core/geo2.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
t = db.geo2;
t.drop();
diff --git a/jstests/core/geo3.js b/jstests/core/geo3.js
index feb93b783cb..e12ffb6184e 100644
--- a/jstests/core/geo3.js
+++ b/jstests/core/geo3.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
t = db.geo3;
t.drop();
diff --git a/jstests/core/geo6.js b/jstests/core/geo6.js
index 3d681fe9b7e..6cd1ce460f3 100644
--- a/jstests/core/geo6.js
+++ b/jstests/core/geo6.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
t = db.geo6;
t.drop();
diff --git a/jstests/core/geo9.js b/jstests/core/geo9.js
index 7419615818e..598de3d2dc1 100644
--- a/jstests/core/geo9.js
+++ b/jstests/core/geo9.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
t = db.geo9;
t.drop();
diff --git a/jstests/core/geo_array0.js b/jstests/core/geo_array0.js
index 42b9c758e45..3b74e42e533 100644
--- a/jstests/core/geo_array0.js
+++ b/jstests/core/geo_array0.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// Make sure the very basics of geo arrays are sane by creating a few multi location docs
t = db.geoarray;
diff --git a/jstests/core/geo_array2.js b/jstests/core/geo_array2.js
index 6195e038de3..58d1f989a17 100644
--- a/jstests/core/geo_array2.js
+++ b/jstests/core/geo_array2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Check the semantics of near calls with multiple locations
t = db.geoarray2;
diff --git a/jstests/core/geo_borders.js b/jstests/core/geo_borders.js
index f8a94d997dd..f110d58ec00 100644
--- a/jstests/core/geo_borders.js
+++ b/jstests/core/geo_borders.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
t = db.borders;
t.drop();
diff --git a/jstests/core/geo_center_sphere2.js b/jstests/core/geo_center_sphere2.js
index 79c69de1ab4..d5216509fdd 100644
--- a/jstests/core/geo_center_sphere2.js
+++ b/jstests/core/geo_center_sphere2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
//
// Tests the error handling of spherical queries
// along with multi-location documents.
diff --git a/jstests/core/geo_distinct.js b/jstests/core/geo_distinct.js
index 33ea7dd3461..4dcc7a7f35f 100644
--- a/jstests/core/geo_distinct.js
+++ b/jstests/core/geo_distinct.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Tests distinct with geospatial field values.
// 1. Test distinct with geo values for 'key' (SERVER-2135)
// 2. Test distinct with geo predicates for 'query' (SERVER-13769)
diff --git a/jstests/core/geo_exactfetch.js b/jstests/core/geo_exactfetch.js
index 4af4032045f..ed117786fb2 100644
--- a/jstests/core/geo_exactfetch.js
+++ b/jstests/core/geo_exactfetch.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// SERVER-7322
t = db.geo_exactfetch;
t.drop();
diff --git a/jstests/core/geo_group.js b/jstests/core/geo_group.js
index 34ecc2c3a84..3ce3d63ef0c 100644
--- a/jstests/core/geo_group.js
+++ b/jstests/core/geo_group.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
t = db.geo_group;
t.drop();
diff --git a/jstests/core/geo_max.js b/jstests/core/geo_max.js
index 03771ea34d4..d8c41781bf8 100644
--- a/jstests/core/geo_max.js
+++ b/jstests/core/geo_max.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Test where points are on _max (180)
// Using GeoNearRandom because this test needs a lot of points in the index.
// If there aren't enough points the test passes even if the code is broken.
diff --git a/jstests/core/geo_mindistance.js b/jstests/core/geo_mindistance.js
index 4bbb77db9bf..43efd499939 100644
--- a/jstests/core/geo_mindistance.js
+++ b/jstests/core/geo_mindistance.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
/* Test $minDistance option for $near and $nearSphere queries, and geoNear
* command. SERVER-9395.
*/
diff --git a/jstests/core/geo_mindistance_boundaries.js b/jstests/core/geo_mindistance_boundaries.js
index 7e97732dfd1..8de431a6b14 100644
--- a/jstests/core/geo_mindistance_boundaries.js
+++ b/jstests/core/geo_mindistance_boundaries.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
/* Test boundary conditions for $minDistance option for $near and $nearSphere
* queries. SERVER-9395.
*/
diff --git a/jstests/core/geo_multinest0.js b/jstests/core/geo_multinest0.js
index 30b66b4adbb..f59e61c037f 100644
--- a/jstests/core/geo_multinest0.js
+++ b/jstests/core/geo_multinest0.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// Make sure nesting of location arrays also works.
t = db.geonest;
diff --git a/jstests/core/geo_multinest1.js b/jstests/core/geo_multinest1.js
index 78e4c38e49b..fc3e0d2d4d4 100644
--- a/jstests/core/geo_multinest1.js
+++ b/jstests/core/geo_multinest1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// Test distance queries with interleaved distances
t = db.multinest;
diff --git a/jstests/core/geo_near_random1.js b/jstests/core/geo_near_random1.js
index 1e7f2bb587d..e0fb816447f 100644
--- a/jstests/core/geo_near_random1.js
+++ b/jstests/core/geo_near_random1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// this tests all points
load("jstests/libs/geo_near_random.js");
diff --git a/jstests/core/geo_near_random2.js b/jstests/core/geo_near_random2.js
index 0cbf374446d..e742c4a639e 100644
--- a/jstests/core/geo_near_random2.js
+++ b/jstests/core/geo_near_random2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// this tests 1% of all points
load("jstests/libs/geo_near_random.js");
diff --git a/jstests/core/geo_or.js b/jstests/core/geo_or.js
index 1324d581be8..4d953dbf9de 100644
--- a/jstests/core/geo_or.js
+++ b/jstests/core/geo_or.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// multiple geo clauses with $or
t = db.geoor;
diff --git a/jstests/core/geo_queryoptimizer.js b/jstests/core/geo_queryoptimizer.js
index af55507ff86..e8aad815761 100644
--- a/jstests/core/geo_queryoptimizer.js
+++ b/jstests/core/geo_queryoptimizer.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
t = db.geo_qo1;
t.drop();
diff --git a/jstests/core/geo_regex0.js b/jstests/core/geo_regex0.js
index 1add7f4e0c3..4584192e15f 100644
--- a/jstests/core/geo_regex0.js
+++ b/jstests/core/geo_regex0.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// From SERVER-2247
// Tests to make sure regex works with geo indices
diff --git a/jstests/core/geo_s2dedupnear.js b/jstests/core/geo_s2dedupnear.js
index 21378893720..e1f624f7553 100644
--- a/jstests/core/geo_s2dedupnear.js
+++ b/jstests/core/geo_s2dedupnear.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Make sure that we don't return several of the same result due to faulty
// assumptions about the btree cursor. That is, don't return duplicate results.
t = db.geo_s2dedupnear;
diff --git a/jstests/core/geo_s2disjoint_holes.js b/jstests/core/geo_s2disjoint_holes.js
index f7731b416e4..0b088434b36 100644
--- a/jstests/core/geo_s2disjoint_holes.js
+++ b/jstests/core/geo_s2disjoint_holes.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
//
// We should prohibit polygons with holes not bounded by their exterior shells.
//
diff --git a/jstests/core/geo_s2index.js b/jstests/core/geo_s2index.js
index 99c3852aae9..65bf5953661 100644
--- a/jstests/core/geo_s2index.js
+++ b/jstests/core/geo_s2index.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
t = db.geo_s2index;
t.drop();
diff --git a/jstests/core/geo_s2indexversion1.js b/jstests/core/geo_s2indexversion1.js
index 4fa58bb589f..d9797a67505 100644
--- a/jstests/core/geo_s2indexversion1.js
+++ b/jstests/core/geo_s2indexversion1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Tests 2dsphere index option "2dsphereIndexVersion". Verifies that GeoJSON objects that are new
// in version 2 are not allowed in version 1.
diff --git a/jstests/core/geo_s2meridian.js b/jstests/core/geo_s2meridian.js
index 583b426845c..e404241e118 100644
--- a/jstests/core/geo_s2meridian.js
+++ b/jstests/core/geo_s2meridian.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
t = db.geo_s2meridian;
t.drop();
t.ensureIndex({geo: "2dsphere"});
diff --git a/jstests/core/geo_s2near.js b/jstests/core/geo_s2near.js
index f8bacf350b4..75572483144 100644
--- a/jstests/core/geo_s2near.js
+++ b/jstests/core/geo_s2near.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Test 2dsphere near search, called via find and geoNear.
t = db.geo_s2near;
t.drop();
diff --git a/jstests/core/geo_s2nearComplex.js b/jstests/core/geo_s2nearComplex.js
index bf9c76ffde4..b8c34c16310 100644
--- a/jstests/core/geo_s2nearComplex.js
+++ b/jstests/core/geo_s2nearComplex.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
var t = db.get_s2nearcomplex;
t.drop();
t.ensureIndex({geo: "2dsphere"});
diff --git a/jstests/core/geo_s2near_equator_opposite.js b/jstests/core/geo_s2near_equator_opposite.js
index 754c27e523d..378a8d89854 100644
--- a/jstests/core/geo_s2near_equator_opposite.js
+++ b/jstests/core/geo_s2near_equator_opposite.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Tests geo near with 2 points diametrically opposite to each other
// on the equator
// First reported in SERVER-11830 as a regression in 2.5
diff --git a/jstests/core/geo_s2nearcorrect.js b/jstests/core/geo_s2nearcorrect.js
index 54552a4bee5..b80bfbf5971 100644
--- a/jstests/core/geo_s2nearcorrect.js
+++ b/jstests/core/geo_s2nearcorrect.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// SERVER-9484
// A geometry may have several covers, one of which is in a search ring and the other of which is
// not. If we see the cover that's not in the search ring, we can't mark the object as 'seen' for
diff --git a/jstests/core/geo_s2nongeoarray.js b/jstests/core/geo_s2nongeoarray.js
index 4b210f8f779..ff027ee1a4f 100644
--- a/jstests/core/geo_s2nongeoarray.js
+++ b/jstests/core/geo_s2nongeoarray.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Explode arrays when indexing non-geo fields in 2dsphere, and make sure that
// we find them with queries.
t = db.geo_s2nongeoarray;
diff --git a/jstests/core/geo_s2nonstring.js b/jstests/core/geo_s2nonstring.js
index 960f0c727a8..e868ade1009 100644
--- a/jstests/core/geo_s2nonstring.js
+++ b/jstests/core/geo_s2nonstring.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Added to make sure that S2 indexing's string AND non-string keys work.
t = db.geo_s2nonstring;
t.drop();
diff --git a/jstests/core/geo_s2nopoints.js b/jstests/core/geo_s2nopoints.js
index 0d2afdb1672..1a92b546764 100644
--- a/jstests/core/geo_s2nopoints.js
+++ b/jstests/core/geo_s2nopoints.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// See SERVER-7794.
t = db.geo_s2nopoints;
t.drop();
diff --git a/jstests/core/geo_small_large.js b/jstests/core/geo_small_large.js
index 549f00369a2..4bdd90da371 100644
--- a/jstests/core/geo_small_large.js
+++ b/jstests/core/geo_small_large.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// SERVER-2386, general geo-indexing using very large and very small bounds
load("jstests/libs/geo_near_random.js");
diff --git a/jstests/core/geo_sort1.js b/jstests/core/geo_sort1.js
index b7a229bb8ae..88a7971841a 100644
--- a/jstests/core/geo_sort1.js
+++ b/jstests/core/geo_sort1.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
t = db.geo_sort1;
t.drop();
diff --git a/jstests/core/geo_uniqueDocs2.js b/jstests/core/geo_uniqueDocs2.js
index 6f5ceed3478..8965a475c93 100644
--- a/jstests/core/geo_uniqueDocs2.js
+++ b/jstests/core/geo_uniqueDocs2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Additional checks for geo uniqueDocs and includeLocs SERVER-3139.
// SERVER-12120 uniqueDocs is deprecated.
// Server always returns results with implied uniqueDocs=true
diff --git a/jstests/core/geo_update.js b/jstests/core/geo_update.js
index ebe754680e9..e6ee16eee59 100644
--- a/jstests/core/geo_update.js
+++ b/jstests/core/geo_update.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Tests geo queries w/ update & upsert
// from SERVER-3428
diff --git a/jstests/core/geo_update_dedup.js b/jstests/core/geo_update_dedup.js
index a630954e8ca..da84e9879a2 100644
--- a/jstests/core/geo_update_dedup.js
+++ b/jstests/core/geo_update_dedup.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Test that updates with geo queries which match
// the same document multiple times only apply
// the update once
diff --git a/jstests/core/geoa.js b/jstests/core/geoa.js
index cd1eeaf5aaa..1c1272a6451 100644
--- a/jstests/core/geoa.js
+++ b/jstests/core/geoa.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
t = db.geoa;
t.drop();
diff --git a/jstests/core/geoc.js b/jstests/core/geoc.js
index 26e762e4978..93f3f5c374a 100644
--- a/jstests/core/geoc.js
+++ b/jstests/core/geoc.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
t = db.geoc;
t.drop();
diff --git a/jstests/core/geof.js b/jstests/core/geof.js
index 4eae803a856..ed10c6496c6 100644
--- a/jstests/core/geof.js
+++ b/jstests/core/geof.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
t = db.geof;
t.drop();
diff --git a/jstests/core/getmore_cmd_maxtimems.js b/jstests/core/getmore_cmd_maxtimems.js
index a0c82667756..9ea4a872043 100644
--- a/jstests/core/getmore_cmd_maxtimems.js
+++ b/jstests/core/getmore_cmd_maxtimems.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test attaching maxTimeMS to a getMore command.
(function() {
'use strict';
diff --git a/jstests/core/getmore_invalidation.js b/jstests/core/getmore_invalidation.js
index 5c5d06deb1c..e6d38b980df 100644
--- a/jstests/core/getmore_invalidation.js
+++ b/jstests/core/getmore_invalidation.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Tests for invalidation during a getmore. This behavior is storage-engine dependent.
// See SERVER-16675.
(function() {
diff --git a/jstests/core/group1.js b/jstests/core/group1.js
index 5e4fcdea245..579c706ee3d 100644
--- a/jstests/core/group1.js
+++ b/jstests/core/group1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
+
t = db.group1;
t.drop();
diff --git a/jstests/core/group2.js b/jstests/core/group2.js
index 1577932beca..5dc0ddce93d 100644
--- a/jstests/core/group2.js
+++ b/jstests/core/group2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
+
t = db.group2;
t.drop();
diff --git a/jstests/core/group3.js b/jstests/core/group3.js
index 134953b6649..3840e8bcbcc 100644
--- a/jstests/core/group3.js
+++ b/jstests/core/group3.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
+
t = db.group3;
t.drop();
diff --git a/jstests/core/group4.js b/jstests/core/group4.js
index 2465274c027..e2d9e9546fc 100644
--- a/jstests/core/group4.js
+++ b/jstests/core/group4.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
t = db.group4;
t.drop();
diff --git a/jstests/core/group5.js b/jstests/core/group5.js
index aa6283f73ff..2f57e110d50 100644
--- a/jstests/core/group5.js
+++ b/jstests/core/group5.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
t = db.group5;
t.drop();
diff --git a/jstests/core/group6.js b/jstests/core/group6.js
index fff2fcaafd7..77ac0355d3e 100644
--- a/jstests/core/group6.js
+++ b/jstests/core/group6.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
+
t = db.jstests_group6;
t.drop();
diff --git a/jstests/core/group8.js b/jstests/core/group8.js
index 85c8248b992..029d430103f 100644
--- a/jstests/core/group8.js
+++ b/jstests/core/group8.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
+
// Test correctness of the "keys" and and "count" fields in the group command output.
var coll = db.group8;
var result;
diff --git a/jstests/core/group9.js b/jstests/core/group9.js
index a7d9a0d128e..17cd3ae94db 100644
--- a/jstests/core/group9.js
+++ b/jstests/core/group9.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
+
(function() {
'use strict';
var t = db.group_owned;
diff --git a/jstests/core/hashindex1.js b/jstests/core/hashindex1.js
index 93986ecfd5e..2e05f9fe3da 100644
--- a/jstests/core/hashindex1.js
+++ b/jstests/core/hashindex1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
var t = db.hashindex1;
t.drop();
diff --git a/jstests/core/in5.js b/jstests/core/in5.js
index 772427365b7..69b7bad75dd 100644
--- a/jstests/core/in5.js
+++ b/jstests/core/in5.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
t = db.in5;
diff --git a/jstests/core/inc-SERVER-7446.js b/jstests/core/inc-SERVER-7446.js
index 2503df21f87..b1d5aa158d0 100644
--- a/jstests/core/inc-SERVER-7446.js
+++ b/jstests/core/inc-SERVER-7446.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
var c = db.incSERVER7446;
// A 32 bit overflow spills to 64 bits
diff --git a/jstests/core/inc3.js b/jstests/core/inc3.js
index b69a77c64cd..e24165876c6 100644
--- a/jstests/core/inc3.js
+++ b/jstests/core/inc3.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.inc3;
diff --git a/jstests/core/index3.js b/jstests/core/index3.js
index e908f1fe2c9..6ae7c4b82dd 100644
--- a/jstests/core/index3.js
+++ b/jstests/core/index3.js
@@ -1,4 +1,6 @@
-
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
t = db.index3;
t.drop();
diff --git a/jstests/core/index4.js b/jstests/core/index4.js
index 1c96ded434a..b9411a8fe37 100644
--- a/jstests/core/index4.js
+++ b/jstests/core/index4.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// index4.js
t = db.index4;
diff --git a/jstests/core/index8.js b/jstests/core/index8.js
index 6773f2d29f5..b74cbb5c708 100644
--- a/jstests/core/index8.js
+++ b/jstests/core/index8.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of not being able to create unique index
+// using hashed shard key pattern.
+// @tags: [cannot_create_unique_index_when_using_hashed_shard_key]
+
// Test key uniqueness
t = db.jstests_index8;
diff --git a/jstests/core/index9.js b/jstests/core/index9.js
index 5f31dc978aa..028578e5460 100644
--- a/jstests/core/index9.js
+++ b/jstests/core/index9.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
t = db.jstests_index9;
t.drop();
diff --git a/jstests/core/index_arr1.js b/jstests/core/index_arr1.js
index ba821bd3730..cc6f1683bd1 100644
--- a/jstests/core/index_arr1.js
+++ b/jstests/core/index_arr1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
t = db.index_arr1;
t.drop();
diff --git a/jstests/core/index_big1.js b/jstests/core/index_big1.js
index 8f600fa37bc..304656dda9a 100644
--- a/jstests/core/index_big1.js
+++ b/jstests/core/index_big1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// check where "key to big" happens
t = db.index_big1;
diff --git a/jstests/core/index_bigkeys.js b/jstests/core/index_bigkeys.js
index 564ddde2a5e..6d98859132e 100644
--- a/jstests/core/index_bigkeys.js
+++ b/jstests/core/index_bigkeys.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
t = db.bigkeysidxtest;
diff --git a/jstests/core/index_decimal.js b/jstests/core/index_decimal.js
index d9642f090d9..312ab106674 100644
--- a/jstests/core/index_decimal.js
+++ b/jstests/core/index_decimal.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
// Test indexing of decimal numbers
(function() {
'use strict';
diff --git a/jstests/core/index_dropdups_ignore.js b/jstests/core/index_dropdups_ignore.js
index 3622d800b01..af75f57a601 100644
--- a/jstests/core/index_dropdups_ignore.js
+++ b/jstests/core/index_dropdups_ignore.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of not being able to create unique index
+// using hashed shard key pattern.
+// @tags: [cannot_create_unique_index_when_using_hashed_shard_key]
+
// SERVER-14710 dropDups is ignored and stripped from the spec when building an index.
var t = db.index_dropdups_ignore;
diff --git a/jstests/core/index_filter_commands.js b/jstests/core/index_filter_commands.js
index 8684be3b2b9..d0973aacd69 100644
--- a/jstests/core/index_filter_commands.js
+++ b/jstests/core/index_filter_commands.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
/**
* Index Filter commands
*
diff --git a/jstests/core/index_id_options.js b/jstests/core/index_id_options.js
index a387c409b6d..9bbf3a2d311 100644
--- a/jstests/core/index_id_options.js
+++ b/jstests/core/index_id_options.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test creation of the _id index with various options:
// - _id indexes must have key pattern {_id: 1}.
// - The name of an _id index gets corrected to "_id_".
diff --git a/jstests/core/index_many.js b/jstests/core/index_many.js
index f2daa8c9fcf..3fae520fe81 100644
--- a/jstests/core/index_many.js
+++ b/jstests/core/index_many.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because renameCollection command not supported
+// on sharded collections.
+// @tags: [assumes_unsharded_collection]
+
/* test using lots of indexes on one collection */
t = db.many;
diff --git a/jstests/core/index_many2.js b/jstests/core/index_many2.js
index 87e99898b1f..c7f993e35e5 100644
--- a/jstests/core/index_many2.js
+++ b/jstests/core/index_many2.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
t = db.index_many2;
t.drop();
diff --git a/jstests/core/index_multiple_compatibility.js b/jstests/core/index_multiple_compatibility.js
index 6544c4c7cbf..15f47d773e0 100644
--- a/jstests/core/index_multiple_compatibility.js
+++ b/jstests/core/index_multiple_compatibility.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of not being able to create unique index
+// using hashed shard key pattern.
+// @tags: [cannot_create_unique_index_when_using_hashed_shard_key]
+
// Test that multiple indexes behave correctly together.
(function() {
'use strict';
diff --git a/jstests/core/index_partial_create_drop.js b/jstests/core/index_partial_create_drop.js
index 1c8552804b3..5875093c706 100644
--- a/jstests/core/index_partial_create_drop.js
+++ b/jstests/core/index_partial_create_drop.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// Test partial index creation and drops.
(function() {
diff --git a/jstests/core/index_partial_read_ops.js b/jstests/core/index_partial_read_ops.js
index 42f77486c17..bef51700b27 100644
--- a/jstests/core/index_partial_read_ops.js
+++ b/jstests/core/index_partial_read_ops.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because the explain output from a mongod when run
+// against a sharded collection is wrapped in a "shards" object with keys for each shard.
+// @tags: [assumes_unsharded_collection]
+
// Read ops tests for partial indexes.
// Include helpers for analyzing explain output.
diff --git a/jstests/core/index_sparse1.js b/jstests/core/index_sparse1.js
index d71c3c1dbfe..49decd3783c 100644
--- a/jstests/core/index_sparse1.js
+++ b/jstests/core/index_sparse1.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
t = db.index_sparse1;
t.drop();
diff --git a/jstests/core/index_sparse2.js b/jstests/core/index_sparse2.js
index 702bb8cd5f8..0cb72567e57 100644
--- a/jstests/core/index_sparse2.js
+++ b/jstests/core/index_sparse2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
t = db.index_sparse2;
t.drop();
diff --git a/jstests/core/index_stats.js b/jstests/core/index_stats.js
index b912543bcb9..b8187e76de2 100644
--- a/jstests/core/index_stats.js
+++ b/jstests/core/index_stats.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
(function() {
"use strict";
diff --git a/jstests/core/index_type_change.js b/jstests/core/index_type_change.js
index 0c95828ae57..37e1d4c06e3 100644
--- a/jstests/core/index_type_change.js
+++ b/jstests/core/index_type_change.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
/**
* Tests that replacing a document with an equivalent document with different types for the fields
* will update the index entries associated with that document.
diff --git a/jstests/core/indexa.js b/jstests/core/indexa.js
index be86c9acf54..33ffaa4bf78 100644
--- a/jstests/core/indexa.js
+++ b/jstests/core/indexa.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// unique index constraint test for updates
// case where object doesn't grow tested here
diff --git a/jstests/core/indexapi.js b/jstests/core/indexapi.js
index 2df9709171d..3153519501a 100644
--- a/jstests/core/indexapi.js
+++ b/jstests/core/indexapi.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of not being able to create unique index
+// using hashed shard key pattern.
+// @tags: [cannot_create_unique_index_when_using_hashed_shard_key]
t = db.indexapi;
t.drop();
diff --git a/jstests/core/indexb.js b/jstests/core/indexb.js
index 1262c621ba9..c852ff083f4 100644
--- a/jstests/core/indexb.js
+++ b/jstests/core/indexb.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of not being able to create unique index
+// using hashed shard key pattern.
+// @tags: [cannot_create_unique_index_when_using_hashed_shard_key]
+
// unique index test for a case where the object grows
// and must move
diff --git a/jstests/core/indexes_multiple_commands.js b/jstests/core/indexes_multiple_commands.js
index 5396f5e6b2e..fe27c3a93a2 100644
--- a/jstests/core/indexes_multiple_commands.js
+++ b/jstests/core/indexes_multiple_commands.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Test that commands behave correctly under the presence of multiple indexes with the same key
// pattern.
(function() {
diff --git a/jstests/core/insert2.js b/jstests/core/insert2.js
index f01fd153d0c..5da0fc5b7f5 100644
--- a/jstests/core/insert2.js
+++ b/jstests/core/insert2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Create a new connection object so it won't affect the global connection when we modify
// it's settings.
var conn = new Mongo(db.getMongo().host);
diff --git a/jstests/core/insert_id_undefined.js b/jstests/core/insert_id_undefined.js
index 874d6c0228c..5dc2c9a6862 100644
--- a/jstests/core/insert_id_undefined.js
+++ b/jstests/core/insert_id_undefined.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// ensure a document with _id undefined cannot be saved
t = db.insert_id_undefined;
t.drop();
diff --git a/jstests/core/js3.js b/jstests/core/js3.js
index 4d46c25bbf7..7a612a1bdee 100644
--- a/jstests/core/js3.js
+++ b/jstests/core/js3.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// from db.eval.
+// @tags: [assumes_unsharded_collection]
t = db.jstests_js3;
diff --git a/jstests/core/js9.js b/jstests/core/js9.js
index 515fa883aea..808ae9a0998 100644
--- a/jstests/core/js9.js
+++ b/jstests/core/js9.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// from db.eval.
+// @tags: [assumes_unsharded_collection]
+
c = db.jstests_js9;
c.drop();
diff --git a/jstests/core/list_collections1.js b/jstests/core/list_collections1.js
index c8c3f92fbc9..2aeb9ec9fbd 100644
--- a/jstests/core/list_collections1.js
+++ b/jstests/core/list_collections1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Basic functional tests for the listCollections command.
//
// Note that storage engines are allowed to advertise internal collections to the user (in
diff --git a/jstests/core/list_indexes.js b/jstests/core/list_indexes.js
index de0f4473980..90abc0f4c62 100644
--- a/jstests/core/list_indexes.js
+++ b/jstests/core/list_indexes.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
// Basic functional tests for the listIndexes command.
(function() {
diff --git a/jstests/core/list_indexes_invalid.js b/jstests/core/list_indexes_invalid.js
index 0e9c5ffa88c..43d64a594c2 100644
--- a/jstests/core/list_indexes_invalid.js
+++ b/jstests/core/list_indexes_invalid.js
@@ -1,32 +1,36 @@
-// Test for invalid values of "cursor" and "cursor.batchSize".
-
-var coll = db.list_indexes_invalid;
-coll.drop();
-
-assert.commandWorked(coll.getDB().createCollection(coll.getName()));
-assert.commandWorked(coll.ensureIndex({a: 1}, {unique: true}));
-
-assert.throws(function() {
- getListIndexesCursor(coll, {cursor: 0});
-});
-assert.throws(function() {
- getListIndexesCursor(coll, {cursor: 'x'});
-});
-assert.throws(function() {
- getListIndexesCursor(coll, {cursor: []});
-});
-assert.throws(function() {
- getListIndexesCursor(coll, {cursor: {foo: 1}});
-});
-assert.throws(function() {
- getListIndexesCursor(coll, {cursor: {batchSize: -1}});
-});
-assert.throws(function() {
- getListIndexesCursor(coll, {cursor: {batchSize: 'x'}});
-});
-assert.throws(function() {
- getListIndexesCursor(coll, {cursor: {batchSize: {}}});
-});
-assert.throws(function() {
- getListIndexesCursor(coll, {cursor: {batchSize: 2, foo: 1}});
-});
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
+
+// Test for invalid values of "cursor" and "cursor.batchSize".
+
+var coll = db.list_indexes_invalid;
+coll.drop();
+
+assert.commandWorked(coll.getDB().createCollection(coll.getName()));
+assert.commandWorked(coll.ensureIndex({a: 1}, {unique: true}));
+
+assert.throws(function() {
+ getListIndexesCursor(coll, {cursor: 0});
+});
+assert.throws(function() {
+ getListIndexesCursor(coll, {cursor: 'x'});
+});
+assert.throws(function() {
+ getListIndexesCursor(coll, {cursor: []});
+});
+assert.throws(function() {
+ getListIndexesCursor(coll, {cursor: {foo: 1}});
+});
+assert.throws(function() {
+ getListIndexesCursor(coll, {cursor: {batchSize: -1}});
+});
+assert.throws(function() {
+ getListIndexesCursor(coll, {cursor: {batchSize: 'x'}});
+});
+assert.throws(function() {
+ getListIndexesCursor(coll, {cursor: {batchSize: {}}});
+});
+assert.throws(function() {
+ getListIndexesCursor(coll, {cursor: {batchSize: 2, foo: 1}});
+});
diff --git a/jstests/core/list_indexes_invalidation.js b/jstests/core/list_indexes_invalidation.js
index b8cbe5eb134..c9500ebd5e0 100644
--- a/jstests/core/list_indexes_invalidation.js
+++ b/jstests/core/list_indexes_invalidation.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because renameCollection command not supported
+// on sharded collections.
+// @tags: [assumes_unsharded_collection]
+
// SERVER-24963/SERVER-27930 Missing invalidation for system.indexes writes
(function() {
'use strict';
diff --git a/jstests/core/mr2.js b/jstests/core/mr2.js
index 744fb916088..be17658ffd7 100644
--- a/jstests/core/mr2.js
+++ b/jstests/core/mr2.js
@@ -1,4 +1,6 @@
-
+// Cannot implicitly shard accessed collections because the "jsMode" option to the "mapReduce"
+// command cannot be used on a sharded collection.
+// @tags: [assumes_unsharded_collection]
t = db.mr2;
t.drop();
diff --git a/jstests/core/mr_bigobject_replace.js b/jstests/core/mr_bigobject_replace.js
index c30b6e5de48..da7c08c0e3a 100644
--- a/jstests/core/mr_bigobject_replace.js
+++ b/jstests/core/mr_bigobject_replace.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: Cannot output to a
+// non-sharded collection because sharded collection exists already.
+// @tags: [assumes_unsharded_collection]
+
/**
* Test that the server returns an error response for map-reduce operations that attempt to insert a
* document larger than 16MB as a result of the reduce() or finalize() functions and using the
diff --git a/jstests/core/mr_errorhandling.js b/jstests/core/mr_errorhandling.js
index d3fcdc3dcac..8da061459d2 100644
--- a/jstests/core/mr_errorhandling.js
+++ b/jstests/core/mr_errorhandling.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of collection existing when none
+// expected.
+// @tags: [assumes_no_implicit_collection_creation_after_drop]
t = db.mr_errorhandling;
t.drop();
diff --git a/jstests/core/mr_killop.js b/jstests/core/mr_killop.js
index 78e98f0bcaa..dc1a646d52d 100644
--- a/jstests/core/mr_killop.js
+++ b/jstests/core/mr_killop.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because the "query" field in the currentOp()
+// output is reported as {"mapreduce.shardedfinish": { mapreduce: "jstests_mr_killop", ... }, ... }
+// when the "finalize" option to the "mapReduce" command is used on a sharded collection.
+// @tags: [assumes_unsharded_collection]
+
// Test killop applied to m/r operations and child ops of m/r operations.
t = db.jstests_mr_killop;
diff --git a/jstests/core/mr_merge.js b/jstests/core/mr_merge.js
index 92490cdd6fd..e81e8f57b0d 100644
--- a/jstests/core/mr_merge.js
+++ b/jstests/core/mr_merge.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of following errmsg: Cannot output to a
+// non-sharded collection because sharded collection exists already.
+// @tags: [assumes_unsharded_collection]
t = db.mr_merge;
t.drop();
diff --git a/jstests/core/mr_merge2.js b/jstests/core/mr_merge2.js
index e324c124f29..db4e83377ab 100644
--- a/jstests/core/mr_merge2.js
+++ b/jstests/core/mr_merge2.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of following errmsg: Cannot output to a
+// non-sharded collection because sharded collection exists already.
+// @tags: [assumes_unsharded_collection]
t = db.mr_merge2;
t.drop();
diff --git a/jstests/core/mr_outreduce.js b/jstests/core/mr_outreduce.js
index d23b0714a51..01fcb1704ba 100644
--- a/jstests/core/mr_outreduce.js
+++ b/jstests/core/mr_outreduce.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of following errmsg: Cannot output to a
+// non-sharded collection because sharded collection exists already.
+// @tags: [assumes_unsharded_collection]
t = db.mr_outreduce;
t.drop();
diff --git a/jstests/core/mr_outreduce2.js b/jstests/core/mr_outreduce2.js
index a08b6b51527..cb9f3379d07 100644
--- a/jstests/core/mr_outreduce2.js
+++ b/jstests/core/mr_outreduce2.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because of following errmsg: Cannot output to a
+// non-sharded collection because sharded collection exists already.
+// @tags: [assumes_unsharded_collection]
normal = "mr_outreduce2";
out = normal + "_out";
diff --git a/jstests/core/mr_sort.js b/jstests/core/mr_sort.js
index b90ad3f6bf5..fe1a5a48beb 100644
--- a/jstests/core/mr_sort.js
+++ b/jstests/core/mr_sort.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because the "limit" option to the "mapReduce"
+// command cannot be used on a sharded collection.
+// @tags: [assumes_unsharded_collection]
t = db.mr_sort;
t.drop();
diff --git a/jstests/core/multikey_geonear.js b/jstests/core/multikey_geonear.js
index 6d796cb62ff..266690d0f3a 100644
--- a/jstests/core/multikey_geonear.js
+++ b/jstests/core/multikey_geonear.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of use of $near query instead of geoNear
+// command.
+// @tags: [assumes_unsharded_collection]
+
// Test that we correct return results for compound 2d and 2dsphere indices in
// both the multikey and non-multikey cases.
diff --git a/jstests/core/or4.js b/jstests/core/or4.js
index 6053295a7d1..42e770e4292 100644
--- a/jstests/core/or4.js
+++ b/jstests/core/or4.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of unsupported group operator on sharded
+// collection.
+// @tags: [assumes_unsharded_collection]
+
t = db.jstests_or4;
t.drop();
diff --git a/jstests/core/projection_dotted_paths.js b/jstests/core/projection_dotted_paths.js
index bdddbeac749..f72a6d30bd6 100644
--- a/jstests/core/projection_dotted_paths.js
+++ b/jstests/core/projection_dotted_paths.js
@@ -1,3 +1,7 @@
+// Failing due to queries on a sharded collection not able to be covered when they aren't on the
+// shard key since the document needs to be fetched in order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
/**
* Test projections with dotted field paths. Also test that such projections result in covered plans
* when appropriate.
diff --git a/jstests/core/pull.js b/jstests/core/pull.js
index d2d03e85144..612c65f9e65 100644
--- a/jstests/core/pull.js
+++ b/jstests/core/pull.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
t = db.jstests_pull;
t.drop();
diff --git a/jstests/core/pull2.js b/jstests/core/pull2.js
index 861d5164c03..bc9b1acba4b 100644
--- a/jstests/core/pull2.js
+++ b/jstests/core/pull2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.pull2;
t.drop();
diff --git a/jstests/core/pull_or.js b/jstests/core/pull_or.js
index a91d88c2c18..9ef1e091d29 100644
--- a/jstests/core/pull_or.js
+++ b/jstests/core/pull_or.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.pull_or;
t.drop();
diff --git a/jstests/core/pull_remove1.js b/jstests/core/pull_remove1.js
index 926dcbf9575..ab9368bab3b 100644
--- a/jstests/core/pull_remove1.js
+++ b/jstests/core/pull_remove1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.pull_remove1;
t.drop();
diff --git a/jstests/core/pullall.js b/jstests/core/pullall.js
index 2925a45623f..2cd0872b079 100644
--- a/jstests/core/pullall.js
+++ b/jstests/core/pullall.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
t = db.jstests_pullall;
t.drop();
diff --git a/jstests/core/pullall2.js b/jstests/core/pullall2.js
index 92d835c0dab..10e8c89caa1 100644
--- a/jstests/core/pullall2.js
+++ b/jstests/core/pullall2.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.pullall2;
t.drop();
diff --git a/jstests/core/pushall.js b/jstests/core/pushall.js
index e9d388e6f6f..bf777d8a08a 100644
--- a/jstests/core/pushall.js
+++ b/jstests/core/pushall.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
t = db.jstests_pushall;
t.drop();
diff --git a/jstests/core/remove8.js b/jstests/core/remove8.js
index 563e4708cf9..2935c9647bc 100644
--- a/jstests/core/remove8.js
+++ b/jstests/core/remove8.js
@@ -1,3 +1,6 @@
+// Cannot implicitly shard accessed collections because unsupported use of sharded collection
+// from db.eval.
+// @tags: [assumes_unsharded_collection]
t = db.remove8;
t.drop();
diff --git a/jstests/core/remove_justone.js b/jstests/core/remove_justone.js
index 04813149dfd..a8b6ba318ee 100644
--- a/jstests/core/remove_justone.js
+++ b/jstests/core/remove_justone.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.remove_justone;
t.drop();
diff --git a/jstests/core/return_key.js b/jstests/core/return_key.js
index 3692521f58c..b2442b43e6f 100644
--- a/jstests/core/return_key.js
+++ b/jstests/core/return_key.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because queries on a sharded collection are not
+// able to be covered when they aren't on the shard key since the document needs to be fetched in
+// order to apply the SHARDING_FILTER stage.
+// @tags: [assumes_unsharded_collection]
+
/**
* Tests for returnKey.
*/
diff --git a/jstests/core/server1470.js b/jstests/core/server1470.js
index 42587961665..05482017c2e 100644
--- a/jstests/core/server1470.js
+++ b/jstests/core/server1470.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.server1470;
t.drop();
diff --git a/jstests/core/set3.js b/jstests/core/set3.js
index 8f7d78d894f..4af579fa0b9 100644
--- a/jstests/core/set3.js
+++ b/jstests/core/set3.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.set3;
t.drop();
diff --git a/jstests/core/set4.js b/jstests/core/set4.js
index 989cf82b223..99c0913b977 100644
--- a/jstests/core/set4.js
+++ b/jstests/core/set4.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.set4;
t.drop();
diff --git a/jstests/core/set5.js b/jstests/core/set5.js
index dfa28b1e3e8..a848899f4af 100644
--- a/jstests/core/set5.js
+++ b/jstests/core/set5.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.set5;
t.drop();
diff --git a/jstests/core/set6.js b/jstests/core/set6.js
index bf0ece0dbf8..2f82eb40a68 100644
--- a/jstests/core/set6.js
+++ b/jstests/core/set6.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.set6;
t.drop();
diff --git a/jstests/core/set7.js b/jstests/core/set7.js
index 8aba33aee94..9e1d9c29bbc 100644
--- a/jstests/core/set7.js
+++ b/jstests/core/set7.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// test $set with array indicies
t = db.jstests_set7;
diff --git a/jstests/core/set_type_change.js b/jstests/core/set_type_change.js
index 1f24a7c953a..ede59f7bcde 100644
--- a/jstests/core/set_type_change.js
+++ b/jstests/core/set_type_change.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
/**
* Tests that using the $set update modifier to change only the type of a field will actually update
* the document, including any relevant indices.
diff --git a/jstests/core/shell_writeconcern.js b/jstests/core/shell_writeconcern.js
index f3f190061cf..9f3fc271ce2 100644
--- a/jstests/core/shell_writeconcern.js
+++ b/jstests/core/shell_writeconcern.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
"use strict";
// check that shell writeconcern work correctly
// 1.) tests that it can be set on each level and is inherited
diff --git a/jstests/core/sortg.js b/jstests/core/sortg.js
index 726fe9184a6..7cdf308444d 100644
--- a/jstests/core/sortg.js
+++ b/jstests/core/sortg.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of extra shard key index in sharded
+// collection.
+// @tags: [assumes_no_implicit_index_creation]
+
// Test that a memory exception is triggered for in memory sorts, but not for indexed sorts.
t = db.jstests_sortg;
diff --git a/jstests/core/splitvector.js b/jstests/core/splitvector.js
index 9ba62e2df83..83e653e992c 100644
--- a/jstests/core/splitvector.js
+++ b/jstests/core/splitvector.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because the "splitVector" command cannot be run
+// on a sharded collection
+// @tags: [assumes_unsharded_collection]
+
// -------------------------
// SPLITVECTOR TEST UTILS
// -------------------------
diff --git a/jstests/core/uniqueness.js b/jstests/core/uniqueness.js
index 8b919b9a6a9..e67d19dcbe6 100644
--- a/jstests/core/uniqueness.js
+++ b/jstests/core/uniqueness.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of not being able to create unique index
+// using hashed shard key pattern.
+// @tags: [cannot_create_unique_index_when_using_hashed_shard_key]
+
var res;
t = db.jstests_uniqueness;
diff --git a/jstests/core/unset2.js b/jstests/core/unset2.js
index ec2772af507..e120ae2b674 100644
--- a/jstests/core/unset2.js
+++ b/jstests/core/unset2.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
var res;
t = db.unset2;
diff --git a/jstests/core/update2.js b/jstests/core/update2.js
index 15d84c81b41..558e3c7f558 100644
--- a/jstests/core/update2.js
+++ b/jstests/core/update2.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
f = db.ed_db_update2;
f.drop();
diff --git a/jstests/core/update3.js b/jstests/core/update3.js
index 79562fe72d0..4974f8c022b 100644
--- a/jstests/core/update3.js
+++ b/jstests/core/update3.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Update with mods corner cases.
f = db.jstests_update3;
diff --git a/jstests/core/update5.js b/jstests/core/update5.js
index 3ee44d2fba0..e0fee23c7fe 100644
--- a/jstests/core/update5.js
+++ b/jstests/core/update5.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.update5;
diff --git a/jstests/core/update6.js b/jstests/core/update6.js
index 76b676260f6..efbb7c365e8 100644
--- a/jstests/core/update6.js
+++ b/jstests/core/update6.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.update6;
t.drop();
diff --git a/jstests/core/update7.js b/jstests/core/update7.js
index 9f92c3382ef..3908c0786d3 100644
--- a/jstests/core/update7.js
+++ b/jstests/core/update7.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.update7;
t.drop();
diff --git a/jstests/core/update_addToSet.js b/jstests/core/update_addToSet.js
index 05437148b2f..f7252b29586 100644
--- a/jstests/core/update_addToSet.js
+++ b/jstests/core/update_addToSet.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.update_addToSet1;
t.drop();
diff --git a/jstests/core/update_arraymatch1.js b/jstests/core/update_arraymatch1.js
index b8d78c3daee..10b7e37e451 100644
--- a/jstests/core/update_arraymatch1.js
+++ b/jstests/core/update_arraymatch1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.update_arraymatch1;
t.drop();
diff --git a/jstests/core/update_arraymatch4.js b/jstests/core/update_arraymatch4.js
index fabe07f7337..bda7de512b8 100644
--- a/jstests/core/update_arraymatch4.js
+++ b/jstests/core/update_arraymatch4.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.update_arraymatch4;
t.drop();
diff --git a/jstests/core/update_arraymatch6.js b/jstests/core/update_arraymatch6.js
index fe4b09de8a0..a32bbf3c7d7 100644
--- a/jstests/core/update_arraymatch6.js
+++ b/jstests/core/update_arraymatch6.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
var res;
t = db.jstests_update_arraymatch6;
t.drop();
diff --git a/jstests/core/update_arraymatch7.js b/jstests/core/update_arraymatch7.js
index 4c0302dbfec..3ad475f291c 100644
--- a/jstests/core/update_arraymatch7.js
+++ b/jstests/core/update_arraymatch7.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Check that the positional operator works properly when an index only match is used for the update
// query spec. SERVER-5067
diff --git a/jstests/core/update_arraymatch8.js b/jstests/core/update_arraymatch8.js
index 7e4eb59f37a..d17b837d0ee 100644
--- a/jstests/core/update_arraymatch8.js
+++ b/jstests/core/update_arraymatch8.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Checking for positional array updates with either .$ or .0 at the end
// SERVER-7511
diff --git a/jstests/core/update_bit_examples.js b/jstests/core/update_bit_examples.js
index adcf6976572..850d64ced5b 100644
--- a/jstests/core/update_bit_examples.js
+++ b/jstests/core/update_bit_examples.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Basic examples for $bit
var res;
var coll = db.update_bit;
diff --git a/jstests/core/update_blank1.js b/jstests/core/update_blank1.js
index 0777c68c745..0a42114ed1c 100644
--- a/jstests/core/update_blank1.js
+++ b/jstests/core/update_blank1.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.update_blank1;
t.drop();
diff --git a/jstests/core/update_currentdate_examples.js b/jstests/core/update_currentdate_examples.js
index 466ce96e5cc..62ee0220e7d 100644
--- a/jstests/core/update_currentdate_examples.js
+++ b/jstests/core/update_currentdate_examples.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Basic examples for $currentDate
var res;
var coll = db.update_currentdate;
diff --git a/jstests/core/update_dbref.js b/jstests/core/update_dbref.js
index 71729c203e5..3cea1415a13 100644
--- a/jstests/core/update_dbref.js
+++ b/jstests/core/update_dbref.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Test that we can update DBRefs, but not dbref fields outside a DBRef
var res;
diff --git a/jstests/core/update_mul_examples.js b/jstests/core/update_mul_examples.js
index 390ae57efd8..484c6f7456a 100644
--- a/jstests/core/update_mul_examples.js
+++ b/jstests/core/update_mul_examples.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Basic examples for $mul (multiply)
var res;
var coll = db.update_mul;
diff --git a/jstests/core/updatea.js b/jstests/core/updatea.js
index 0c7a9e1c504..dd54ed04b59 100644
--- a/jstests/core/updatea.js
+++ b/jstests/core/updatea.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
var res;
t = db.updatea;
diff --git a/jstests/core/updateb.js b/jstests/core/updateb.js
index f90ac62b6c3..1518e7f3546 100644
--- a/jstests/core/updateb.js
+++ b/jstests/core/updateb.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.updateb;
t.drop();
diff --git a/jstests/core/updated.js b/jstests/core/updated.js
index 1eaaae3b051..919d02610c7 100644
--- a/jstests/core/updated.js
+++ b/jstests/core/updated.js
@@ -1,3 +1,7 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
t = db.updated;
t.drop();
diff --git a/jstests/core/updatee.js b/jstests/core/updatee.js
index e2fac8af287..fbbcac01c9a 100644
--- a/jstests/core/updatee.js
+++ b/jstests/core/updatee.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// big numeric updates (used to overflow)
t = db.updatee;
diff --git a/jstests/core/updateg.js b/jstests/core/updateg.js
index 908df755376..8a849a0ce59 100644
--- a/jstests/core/updateg.js
+++ b/jstests/core/updateg.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// SERVER-3370 check modifiers with field name characters comparing less than '.' character.
t = db.jstests_updateg;
diff --git a/jstests/core/updateh.js b/jstests/core/updateh.js
index 91c985ac014..ea1c87582f9 100644
--- a/jstests/core/updateh.js
+++ b/jstests/core/updateh.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Disallow $ in field names
var res;
diff --git a/jstests/core/updatei.js b/jstests/core/updatei.js
index d5bc3500ab0..54979313195 100644
--- a/jstests/core/updatei.js
+++ b/jstests/core/updatei.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Test new (optional) update syntax
// SERVER-4176
t = db.updatei;
diff --git a/jstests/core/updatek.js b/jstests/core/updatek.js
index 1af9e6112e7..923b4145d1d 100644
--- a/jstests/core/updatek.js
+++ b/jstests/core/updatek.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Test modifier operations on numerically equivalent string field names. SERVER-4776
t = db.jstests_updatek;
diff --git a/jstests/core/updatem.js b/jstests/core/updatem.js
index 1346a293f66..011a33295db 100644
--- a/jstests/core/updatem.js
+++ b/jstests/core/updatem.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Tests that _id will exist in all updated docs.
t = db.jstests_updatem;
diff --git a/jstests/core/upsert_and.js b/jstests/core/upsert_and.js
index f99fd995edb..955b855d525 100644
--- a/jstests/core/upsert_and.js
+++ b/jstests/core/upsert_and.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// tests to ensure fields in $and conditions are created when using the query to do upsert
var res;
coll = db.upsert4;
diff --git a/jstests/core/upsert_fields.js b/jstests/core/upsert_fields.js
index 910ae6d3e11..311d6984ce9 100644
--- a/jstests/core/upsert_fields.js
+++ b/jstests/core/upsert_fields.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
//
// Upsert behavior tests for field extraction
//
diff --git a/jstests/core/upsert_shell.js b/jstests/core/upsert_shell.js
index 5b7ac501aef..af275d9a7b6 100644
--- a/jstests/core/upsert_shell.js
+++ b/jstests/core/upsert_shell.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// tests to make sure that the new _id is returned after the insert in the shell
var l;
t = db.upsert1;
diff --git a/jstests/core/verify_update_mods.js b/jstests/core/verify_update_mods.js
index efd0beb80cc..c20de299115 100644
--- a/jstests/core/verify_update_mods.js
+++ b/jstests/core/verify_update_mods.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
// Verify update mods exist
var res;
t = db.update_mods;
diff --git a/jstests/core/write_result.js b/jstests/core/write_result.js
index 86486089c68..17c86e7719f 100644
--- a/jstests/core/write_result.js
+++ b/jstests/core/write_result.js
@@ -1,3 +1,8 @@
+// Cannot implicitly shard accessed collections because of following errmsg: A single
+// update/delete on a sharded collection must contain an exact match on _id or contain the shard
+// key.
+// @tags: [assumes_unsharded_collection]
+
//
// Tests the behavior of single writes using write commands
//
diff --git a/jstests/libs/override_methods/implicitly_shard_accessed_collections.js b/jstests/libs/override_methods/implicitly_shard_accessed_collections.js
index 7b5189c4b33..a29f68b7323 100644
--- a/jstests/libs/override_methods/implicitly_shard_accessed_collections.js
+++ b/jstests/libs/override_methods/implicitly_shard_accessed_collections.js
@@ -4,6 +4,9 @@
*
* The DB.prototype.getCollection() function is called whenever an undefined property is accessed
* on the db object.
+ *
+ * DBCollection.prototype.drop() function will re-shard any non-blacklisted collection that is
+ * dropped in a sharded cluster.
*/
(function() {
@@ -12,6 +15,7 @@
// Save a reference to the original getCollection method in the IIFE's scope.
// This scoping allows the original method to be called by the getCollection override below.
var originalGetCollection = DB.prototype.getCollection;
+ var originalDBCollectionDrop = DBCollection.prototype.drop;
// Blacklisted namespaces that should not be sharded.
var blacklistedNamespaces = [
@@ -21,33 +25,49 @@
/\.system\./,
];
- DB.prototype.getCollection = function() {
- var dbName = this.getName();
- var collection = originalGetCollection.apply(this, arguments);
+ function shardCollection(collection) {
+ var db = collection.getDB();
+ var dbName = db.getName();
var fullName = collection.getFullName();
- // If the collection exists, there must have been a previous call to getCollection
- // where we sharded the collection so there's no need to do it again.
- if (collection.exists()) {
- return collection;
- }
-
for (var ns of blacklistedNamespaces) {
if (fullName.match(ns)) {
- return collection;
+ return;
}
}
- var res = this.adminCommand({enableSharding: dbName});
+ var res = db.adminCommand({enableSharding: dbName});
// enableSharding may only be called once for a database.
if (res.code !== ErrorCodes.AlreadyInitialized) {
assert.commandWorked(res, "enabling sharding on the '" + dbName + "' db failed");
}
- res = this.adminCommand({shardCollection: fullName, key: {_id: 'hashed'}});
+ res = db.adminCommand({shardCollection: fullName, key: {_id: 'hashed'}});
assert.commandWorked(res, "sharding '" + fullName + "' with a hashed _id key failed");
+ }
+
+ DB.prototype.getCollection = function() {
+ var collection = originalGetCollection.apply(this, arguments);
+
+ // If the collection exists, there must have been a previous call to getCollection
+ // where we sharded the collection so there's no need to do it again.
+ if (collection.exists()) {
+ return collection;
+ }
+
+ // Attempt to enable sharding on database and collection if not already done.
+ shardCollection(collection);
return collection;
};
+
+ DBCollection.prototype.drop = function() {
+ var dropResult = originalDBCollectionDrop.apply(this, arguments);
+
+ // Attempt to enable sharding on database and collection if not already done.
+ shardCollection(this);
+
+ return dropResult;
+ };
}());