summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/collation_clone_collection.js
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2016-09-14 20:49:17 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2016-09-14 20:49:17 -0400
commit8302d0735b34a16cac000e5e345722487536e5bc (patch)
treec9ef60fe493eda60feacddfd67c0ec298939c4ef /jstests/noPassthrough/collation_clone_collection.js
parent46acb1b94944bc7aa68ff6a8b3cd2d340b272c6f (diff)
downloadmongo-8302d0735b34a16cac000e5e345722487536e5bc.tar.gz
SERVER-24033 Write full index spec in oplog entry for index creation.
This ensures that the index version (aka the "v" field) is always present in the oplog entry when creating indexes on a 3.4 primary. We can therefore assume that if the "v" field isn't present in the corresponding oplog entry, then a v=1 index should be built. Changes MultiBlockIndex::init() to return the index specifications that were actually created. The "repairDatabase", "compact", "copydb", and "cloneCollection" commands no longer automatically upgrade the index version to the current default version. Instead, the only command that does so is the "reIndex" command.
Diffstat (limited to 'jstests/noPassthrough/collation_clone_collection.js')
-rw-r--r--jstests/noPassthrough/collation_clone_collection.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/jstests/noPassthrough/collation_clone_collection.js b/jstests/noPassthrough/collation_clone_collection.js
index 18bdbbe2806..1db8fec3841 100644
--- a/jstests/noPassthrough/collation_clone_collection.js
+++ b/jstests/noPassthrough/collation_clone_collection.js
@@ -24,6 +24,18 @@
sourceColl.find({_id: "foo"}).toArray(),
"query should have performed a case-insensitive match");
+ assert.commandWorked(
+ sourceColl.createIndex({withSimpleCollation: 1}, {collation: {locale: "simple"}}));
+ assert.commandWorked(sourceColl.createIndex({withDefaultCollation: 1}));
+ assert.commandWorked(
+ sourceColl.createIndex({withNonDefaultCollation: 1}, {collation: {locale: "fr"}}));
+ var sourceIndexInfos = sourceColl.getIndexes().map(function(indexInfo) {
+ // We remove the "ns" field from the index specification when comparing whether the indexes
+ // that were cloned are equivalent because they were built on a different namespace.
+ delete indexInfo.ns;
+ return indexInfo;
+ });
+
// Test that the "cloneCollection" command respects the collection-default collation.
destColl.drop();
assert.commandWorked(destColl.getDB().runCommand({
@@ -35,4 +47,19 @@
var destCollectionInfos = destColl.getDB().getCollectionInfos({name: destColl.getName()});
assert.eq(sourceCollectionInfos, destCollectionInfos);
assert.eq([{_id: "FOO"}], destColl.find({}).toArray());
+
+ var destIndexInfos = destColl.getIndexes().map(function(indexInfo) {
+ // We remove the "ns" field from the index specification when comparing whether the indexes
+ // that were cloned are equivalent because they were built on a different namespace.
+ delete indexInfo.ns;
+ return indexInfo;
+ });
+
+ assert.eq(sourceIndexInfos.length,
+ destIndexInfos.length,
+ "Number of indexes don't match; source: " + tojson(sourceIndexInfos) + ", dest: " +
+ tojson(destIndexInfos));
+ for (var i = 0; i < sourceIndexInfos.length; ++i) {
+ assert.contains(sourceIndexInfos[i], destIndexInfos);
+ }
})();