summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/indexcatalogtests.cpp
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 /src/mongo/dbtests/indexcatalogtests.cpp
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 'src/mongo/dbtests/indexcatalogtests.cpp')
-rw-r--r--src/mongo/dbtests/indexcatalogtests.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/dbtests/indexcatalogtests.cpp b/src/mongo/dbtests/indexcatalogtests.cpp
index ef2f1effb81..068ede905a1 100644
--- a/src/mongo/dbtests/indexcatalogtests.cpp
+++ b/src/mongo/dbtests/indexcatalogtests.cpp
@@ -29,6 +29,9 @@
#include "mongo/dbtests/dbtests.h"
namespace IndexCatalogTests {
+namespace {
+const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2;
+} // namespace
static const char* const _ns = "unittests.indexcatalog";
@@ -135,12 +138,13 @@ public:
OldClientWriteContext ctx(&txn, _ns);
const std::string indexName = "x_1";
- ASSERT_OK(dbtests::createIndexFromSpec(&txn,
- _ns,
- BSON("name" << indexName << "ns" << _ns << "key"
- << BSON("x" << 1)
- << "expireAfterSeconds"
- << 5)));
+ ASSERT_OK(dbtests::createIndexFromSpec(
+ &txn,
+ _ns,
+ BSON("name" << indexName << "ns" << _ns << "key" << BSON("x" << 1) << "v"
+ << static_cast<int>(kIndexVersion)
+ << "expireAfterSeconds"
+ << 5)));
const IndexDescriptor* desc = _catalog->findIndexByName(&txn, indexName);
ASSERT(desc);