summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/validate_tests.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/validate_tests.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/validate_tests.cpp')
-rw-r--r--src/mongo/dbtests/validate_tests.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/mongo/dbtests/validate_tests.cpp b/src/mongo/dbtests/validate_tests.cpp
index 14da85c8844..3eb1706fbce 100644
--- a/src/mongo/dbtests/validate_tests.cpp
+++ b/src/mongo/dbtests/validate_tests.cpp
@@ -46,6 +46,10 @@ namespace ValidateTests {
using std::unique_ptr;
+namespace {
+const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2;
+} // namespace
+
static const char* const _ns = "unittests.validate_tests";
/**
@@ -175,6 +179,8 @@ public:
<< coll->ns().ns()
<< "key"
<< BSON("a" << 1)
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false));
@@ -236,6 +242,8 @@ public:
<< coll->ns().ns()
<< "key"
<< BSON("a" << 1)
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false));
@@ -369,6 +377,8 @@ public:
<< coll->ns().ns()
<< "key"
<< BSON("a.b" << 1)
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false));
@@ -433,6 +443,8 @@ public:
<< coll->ns().ns()
<< "key"
<< BSON("a" << 1)
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false
<< "sparse"
@@ -491,6 +503,8 @@ public:
<< coll->ns().ns()
<< "key"
<< BSON("a" << 1)
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false
<< "partialFilterExpression"
@@ -545,6 +559,8 @@ public:
<< "key"
<< BSON("x"
<< "2dsphere")
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false
<< "partialFilterExpression"
@@ -561,6 +577,8 @@ public:
<< "key"
<< BSON("x"
<< "2dsphere")
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false
<< "partialFilterExpression"
@@ -606,6 +624,8 @@ public:
<< coll->ns().ns()
<< "key"
<< BSON("a" << 1 << "b" << -1)
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false));
ASSERT_OK(status);
@@ -618,6 +638,8 @@ public:
<< coll->ns().ns()
<< "key"
<< BSON("a" << -1 << "b" << 1)
+ << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false));
@@ -666,7 +688,8 @@ public:
auto status = dbtests::createIndexFromSpec(
&_txn,
coll->ns().ns(),
- BSON("name" << indexName << "ns" << coll->ns().ns() << "key" << BSON("a" << 1)
+ BSON("name" << indexName << "ns" << coll->ns().ns() << "key" << BSON("a" << 1) << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false));
@@ -727,7 +750,8 @@ public:
auto status = dbtests::createIndexFromSpec(
&_txn,
coll->ns().ns(),
- BSON("name" << indexName << "ns" << coll->ns().ns() << "key" << BSON("a" << 1)
+ BSON("name" << indexName << "ns" << coll->ns().ns() << "key" << BSON("a" << 1) << "v"
+ << static_cast<int>(kIndexVersion)
<< "background"
<< false));