diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-02-26 09:11:32 -0500 |
---|---|---|
committer | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-03-20 08:26:08 -0400 |
commit | 7948bd50e4f43e0285fac0a11170871db81fff7c (patch) | |
tree | bf7187da5a18d9cfc06abb18abad55851d08b731 /src/mongo/dbtests | |
parent | d8d3d3ab1cef37bcc6f65182463b83eaf4669e17 (diff) | |
download | mongo-7948bd50e4f43e0285fac0a11170871db81fff7c.tar.gz |
SERVER-33149 createIndexes fails to report an error when index is not created with the specified name
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/indexupdatetests.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp index 489448435aa..e967bff83bc 100644 --- a/src/mongo/dbtests/indexupdatetests.cpp +++ b/src/mongo/dbtests/indexupdatetests.cpp @@ -414,14 +414,40 @@ public: } }; -class SameSpecSameOptionDifferentOrder : public ComplexIndex { +class SameSpecDifferentNameDifferentOrder : public ComplexIndex { public: void run() { - // Exactly the same specs with the existing one, only - // specified in a different order than the original. + // Exactly the same specs with the existing one, only specified in a different order than + // the original. This will throw an IndexOptionsConflict as the index already exists under + // another name. + ASSERT_EQUALS(ErrorCodes::IndexOptionsConflict, + createIndex("unittests", + BSON("name" + << "super2" + << "ns" + << _ns + << "expireAfterSeconds" + << 3600 + << "sparse" + << true + << "unique" + << 1 + << "key" + << BSON("superIdx" + << "2d") + << "v" + << static_cast<int>(kIndexVersion)))); + } +}; + +class SameSpecSameNameDifferentOrder : public ComplexIndex { +public: + void run() { + // Exactly the same specs with the existing one, only specified in a different order than + // the original, but with the same name. ASSERT_OK(createIndex("unittests", BSON("name" - << "super2" + << "super" << "ns" << _ns << "expireAfterSeconds" @@ -705,7 +731,8 @@ public: add<SameSpecDifferentOption>(); add<SameSpecSameOptions>(); add<DifferentSpecSameName>(); - add<SameSpecSameOptionDifferentOrder>(); + add<SameSpecDifferentNameDifferentOrder>(); + add<SameSpecSameNameDifferentOrder>(); add<SameSpecDifferentUnique>(); add<SameSpecDifferentSparse>(); add<SameSpecDifferentTTL>(); |