summaryrefslogtreecommitdiff
path: root/jstests/multiVersion/libs/verify_collection_data.js
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2016-10-10 13:18:25 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2016-10-18 16:56:19 -0400
commit1a940972e9e1ed78adfff6f31c2907a2c860d17c (patch)
treed40fab9f27306aefc8d0504ff92cf574fb8416d2 /jstests/multiVersion/libs/verify_collection_data.js
parenta0fd9c9714cdcd6be7eae05c31a578c17ed6d780 (diff)
downloadmongo-8980ca04d3842b7dd93cce99820f3e0903aecebf.tar.gz
SERVER-26513 listCollections output should include _id index spec as idIndexr3.4.0-rc1
Diffstat (limited to 'jstests/multiVersion/libs/verify_collection_data.js')
-rw-r--r--jstests/multiVersion/libs/verify_collection_data.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/jstests/multiVersion/libs/verify_collection_data.js b/jstests/multiVersion/libs/verify_collection_data.js
index eb7cb952286..ab96a1ef29c 100644
--- a/jstests/multiVersion/libs/verify_collection_data.js
+++ b/jstests/multiVersion/libs/verify_collection_data.js
@@ -65,7 +65,7 @@ createCollectionWithData = function(db, collectionName, dataGenerator) {
// MongoDB 3.4 introduces new fields into the listCollections result document. This function
// injects expected 3.4 values into a 3.2 document to allow for object comparison.
-// TODO: Remove this check post-3.4 release.
+// TODO SERVER-26676: Remove this check post-3.4 release.
var injectExpected34FieldsIf32 = function(collectionInfo, dbVersion) {
if (dbVersion.startsWith("3.2")) {
return Object.extend({type: "collection", info: {readOnly: false}}, collectionInfo);
@@ -74,6 +74,18 @@ var injectExpected34FieldsIf32 = function(collectionInfo, dbVersion) {
return collectionInfo;
};
+// MongoDB 3.4 introduces a new field 'idIndex' into the listCollections result document. This
+// cannot be injected into the 3.2 listCollections result document because the full index spec is
+// not known. This function removes the 'idIndex' field to allow for object comparison.
+// TODO SERVER-26676: Remove this check post-3.4 release.
+var removeIdIndexField = function(collectionInfo) {
+ if (collectionInfo.hasOwnProperty("idIndex")) {
+ delete collectionInfo.idIndex;
+ }
+
+ return collectionInfo;
+};
+
// Class to save the state of a collection and later compare the current state of a collection to
// the saved state
function CollectionDataValidator() {
@@ -127,8 +139,9 @@ function CollectionDataValidator() {
// Get the metadata for this collection
var newCollectionInfo = this.getCollectionInfo(collection);
- let colInfo1 = injectExpected34FieldsIf32(_collectionInfo, _dbVersion);
- let colInfo2 = injectExpected34FieldsIf32(newCollectionInfo, dbVersionForCollection);
+ let colInfo1 = removeIdIndexField(injectExpected34FieldsIf32(_collectionInfo, _dbVersion));
+ let colInfo2 = removeIdIndexField(
+ injectExpected34FieldsIf32(newCollectionInfo, dbVersionForCollection));
assert.docEq(colInfo1, colInfo2, "collection metadata not equal");
// Get the indexes for this collection