summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2017-12-08 09:49:08 -0500
committerDaniel Gottlieb <daniel.gottlieb@mongodb.com>2017-12-10 20:06:40 -0500
commit66aa9020a1710991863bdf2c329402326871558d (patch)
tree22177801a7b124f508a1822f222930cc220e429e /src/mongo/dbtests
parent38cf9e8f43033d0fab3dc716a727626c66d4412e (diff)
downloadmongo-66aa9020a1710991863bdf2c329402326871558d.tar.gz
SERVER-31304: Refactor away SnapshotName.
(cherry picked from commit 470c30273c479c5ab139de0d38e016f95c589c49)
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/storage_timestamp_tests.cpp43
1 files changed, 18 insertions, 25 deletions
diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp
index c6ba60584dc..7e15647cf05 100644
--- a/src/mongo/dbtests/storage_timestamp_tests.cpp
+++ b/src/mongo/dbtests/storage_timestamp_tests.cpp
@@ -31,6 +31,7 @@
#include <cstdint>
#include "mongo/bson/simple_bsonobj_comparator.h"
+#include "mongo/bson/timestamp.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/index_create.h"
@@ -107,7 +108,7 @@ public:
*/
void reset(NamespaceString nss) const {
::mongo::writeConflictRetry(_opCtx, "deleteAll", nss.ns(), [&] {
- invariant(_opCtx->recoveryUnit()->selectSnapshot(SnapshotName::min()).isOK());
+ invariant(_opCtx->recoveryUnit()->selectSnapshot(Timestamp::min()).isOK());
AutoGetCollection collRaii(_opCtx, nss, LockMode::MODE_X);
if (collRaii.getCollection()) {
@@ -248,8 +249,7 @@ public:
for (std::uint32_t idx = 0; idx < docsToInsert; ++idx) {
auto recoveryUnit = _opCtx->recoveryUnit();
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(
- SnapshotName(firstInsertTime.addTicks(idx).asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(firstInsertTime.addTicks(idx).asTimestamp()));
BSONObj result;
ASSERT(Helpers::getLast(_opCtx, nss.ns().c_str(), result)) << " idx is " << idx;
ASSERT_EQ(0, SimpleBSONObjComparator::kInstance.compare(result, BSON("_id" << idx)))
@@ -331,8 +331,7 @@ public:
for (std::uint32_t idx = 0; idx < docsToInsert; ++idx) {
auto recoveryUnit = _opCtx->recoveryUnit();
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(
- SnapshotName(firstInsertTime.addTicks(idx).asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(firstInsertTime.addTicks(idx).asTimestamp()));
BSONObj result;
ASSERT(Helpers::getLast(_opCtx, nss.ns().c_str(), result)) << " idx is " << idx;
ASSERT_EQ(0, SimpleBSONObjComparator::kInstance.compare(result, BSON("_id" << idx)))
@@ -364,11 +363,10 @@ public:
const LogicalTime lastInsertTime = firstInsertTime.addTicks(docsToInsert - 1);
WriteUnitOfWork wunit(_opCtx);
for (std::int32_t num = 0; num < docsToInsert; ++num) {
- insertDocument(
- autoColl.getCollection(),
- InsertStatement(BSON("_id" << num << "a" << num),
- SnapshotName(firstInsertTime.addTicks(num).asTimestamp()),
- 0LL));
+ insertDocument(autoColl.getCollection(),
+ InsertStatement(BSON("_id" << num << "a" << num),
+ firstInsertTime.addTicks(num).asTimestamp(),
+ 0LL));
}
wunit.commit();
ASSERT_EQ(docsToInsert, itCount(autoColl.getCollection()));
@@ -400,8 +398,7 @@ public:
// at each successive tick counts one less document.
auto recoveryUnit = _opCtx->recoveryUnit();
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(
- SnapshotName(lastInsertTime.addTicks(num).asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(lastInsertTime.addTicks(num).asTimestamp()));
ASSERT_EQ(docsToInsert - num, itCount(autoColl.getCollection()));
}
}
@@ -427,9 +424,8 @@ public:
// Insert one document that will go through a series of updates.
const LogicalTime insertTime = _clock->reserveTicks(1);
WriteUnitOfWork wunit(_opCtx);
- insertDocument(
- autoColl.getCollection(),
- InsertStatement(BSON("_id" << 0), SnapshotName(insertTime.asTimestamp()), 0LL));
+ insertDocument(autoColl.getCollection(),
+ InsertStatement(BSON("_id" << 0), insertTime.asTimestamp(), 0LL));
wunit.commit();
ASSERT_EQ(1, itCount(autoColl.getCollection()));
@@ -479,8 +475,7 @@ public:
// the series.
auto recoveryUnit = _opCtx->recoveryUnit();
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(
- SnapshotName(insertTime.addTicks(idx + 1).asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(insertTime.addTicks(idx + 1).asTimestamp()));
auto doc = findOne(autoColl.getCollection());
ASSERT_EQ(0, SimpleBSONObjComparator::kInstance.compare(doc, updates[idx].second))
@@ -546,7 +541,7 @@ public:
// Reading at `insertTime` should show the original document, `{_id: 0, field: 0}`.
auto recoveryUnit = _opCtx->recoveryUnit();
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(SnapshotName(insertTime.asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(insertTime.asTimestamp()));
auto doc = findOne(autoColl.getCollection());
ASSERT_EQ(0,
SimpleBSONObjComparator::kInstance.compare(doc, BSON("_id" << 0 << "field" << 0)))
@@ -555,7 +550,7 @@ public:
// Reading at `insertTime + 1` should show the second insert that got converted to an
// upsert, `{_id: 0}`.
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(SnapshotName(insertTime.addTicks(1).asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(insertTime.addTicks(1).asTimestamp()));
doc = findOne(autoColl.getCollection());
ASSERT_EQ(0, SimpleBSONObjComparator::kInstance.compare(doc, BSON("_id" << 0)))
<< "Doc: " << doc.toString() << " Expected: {_id: 0}";
@@ -604,7 +599,7 @@ public:
// Reading at `preInsertTimestamp` should not find anything.
auto recoveryUnit = _opCtx->recoveryUnit();
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(SnapshotName(preInsertTimestamp.asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(preInsertTimestamp.asTimestamp()));
ASSERT_EQ(0, itCount(autoColl.getCollection()))
<< "Should not observe a write at `preInsertTimestamp`. TS: "
<< preInsertTimestamp.asTimestamp();
@@ -612,8 +607,7 @@ public:
// Reading at `preInsertTimestamp + 1` should observe both inserts.
recoveryUnit = _opCtx->recoveryUnit();
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(
- SnapshotName(preInsertTimestamp.addTicks(1).asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(preInsertTimestamp.addTicks(1).asTimestamp()));
ASSERT_EQ(2, itCount(autoColl.getCollection()))
<< "Should observe both writes at `preInsertTimestamp + 1`. TS: "
<< preInsertTimestamp.addTicks(1).asTimestamp();
@@ -667,15 +661,14 @@ public:
// Reading at `insertTime` should not see any documents.
auto recoveryUnit = _opCtx->recoveryUnit();
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(SnapshotName(preInsertTimestamp.asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(preInsertTimestamp.asTimestamp()));
ASSERT_EQ(0, itCount(autoColl.getCollection()))
<< "Should not find any documents at `preInsertTimestamp`. TS: "
<< preInsertTimestamp.asTimestamp();
// Reading at `preInsertTimestamp + 1` should show the final state of the document.
recoveryUnit->abandonSnapshot();
- ASSERT_OK(recoveryUnit->selectSnapshot(
- SnapshotName(preInsertTimestamp.addTicks(1).asTimestamp())));
+ ASSERT_OK(recoveryUnit->selectSnapshot(preInsertTimestamp.addTicks(1).asTimestamp()));
auto doc = findOne(autoColl.getCollection());
ASSERT_EQ(0, SimpleBSONObjComparator::kInstance.compare(doc, BSON("_id" << 0)))
<< "Doc: " << doc.toString() << " Expected: {_id: 0}";