diff options
author | James Wahlin <james.wahlin@10gen.com> | 2016-04-21 15:55:32 -0400 |
---|---|---|
committer | James Wahlin <james.wahlin@10gen.com> | 2016-04-21 16:48:06 -0400 |
commit | dc3d30af10b6859124d1ce8790ad8e097d1f06c7 (patch) | |
tree | 4cf90aec523a535c5974007a08fcc95e0f8528bb /src/mongo/db/storage/record_store_test_updaterecord.cpp | |
parent | 1a371955e7a93f846a5ddddb19f33d6b270a3991 (diff) | |
download | mongo-dc3d30af10b6859124d1ce8790ad8e097d1f06c7.tar.gz |
SERVER-23271 Add keysInserted and keysDeleted metrics for CRUD ops
Diffstat (limited to 'src/mongo/db/storage/record_store_test_updaterecord.cpp')
-rw-r--r-- | src/mongo/db/storage/record_store_test_updaterecord.cpp | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/src/mongo/db/storage/record_store_test_updaterecord.cpp b/src/mongo/db/storage/record_store_test_updaterecord.cpp index 0d7c9433503..cd27acf9c69 100644 --- a/src/mongo/db/storage/record_store_test_updaterecord.cpp +++ b/src/mongo/db/storage/record_store_test_updaterecord.cpp @@ -77,10 +77,19 @@ TEST(RecordStoreTestHarness, UpdateRecord) { unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { WriteUnitOfWork uow(opCtx.get()); - StatusWith<RecordId> res = + Status res = rs->updateRecord(opCtx.get(), loc, data.c_str(), data.size() + 1, false, NULL); - ASSERT_OK(res.getStatus()); - loc = res.getValue(); + + if (ErrorCodes::NeedsDocumentMove == res) { + StatusWith<RecordId> newLocation = + rs->insertRecord(opCtx.get(), data.c_str(), data.size() + 1, false); + ASSERT_OK(newLocation.getStatus()); + rs->deleteRecord(opCtx.get(), loc); + loc = newLocation.getValue(); + } else { + ASSERT_OK(res); + } + uow.commit(); } } @@ -136,10 +145,19 @@ TEST(RecordStoreTestHarness, UpdateMultipleRecords) { string data = ss.str(); WriteUnitOfWork uow(opCtx.get()); - StatusWith<RecordId> res = + Status res = rs->updateRecord(opCtx.get(), locs[i], data.c_str(), data.size() + 1, false, NULL); - ASSERT_OK(res.getStatus()); - locs[i] = res.getValue(); + + if (ErrorCodes::NeedsDocumentMove == res) { + StatusWith<RecordId> newLocation = + rs->insertRecord(opCtx.get(), data.c_str(), data.size() + 1, false); + ASSERT_OK(newLocation.getStatus()); + rs->deleteRecord(opCtx.get(), locs[i]); + locs[i] = newLocation.getValue(); + } else { + ASSERT_OK(res); + } + uow.commit(); } } @@ -194,21 +212,21 @@ TEST(RecordStoreTestHarness, UpdateRecordWithMoveNotifier) { UpdateNotifierSpy umn(opCtx.get(), loc, oldData.c_str(), oldData.size()); WriteUnitOfWork uow(opCtx.get()); - StatusWith<RecordId> res = rs->updateRecord( + Status res = rs->updateRecord( opCtx.get(), loc, newData.c_str(), newData.size() + 1, false, &umn); - ASSERT_OK(res.getStatus()); - // UpdateNotifier::recordStoreGoingToMove() called only if - // the RecordId for the record changes - if (loc == res.getValue()) { - ASSERT_EQUALS(0, umn.numMoveCallbacks()); - // Only MMAP v1 is required to use the UpdateNotifier for in-place updates, - // so the number of callbacks is expected to be 0 for non-MMAP storage engines. - ASSERT_GTE(1, umn.numInPlaceCallbacks()); - } else { - ASSERT_EQUALS(1, umn.numMoveCallbacks()); + + if (ErrorCodes::NeedsDocumentMove == res) { + StatusWith<RecordId> newLocation = + rs->insertRecord(opCtx.get(), newData.c_str(), newData.size() + 1, false); + ASSERT_OK(newLocation.getStatus()); + rs->deleteRecord(opCtx.get(), loc); + loc = newLocation.getValue(); ASSERT_EQUALS(0, umn.numInPlaceCallbacks()); + } else { + ASSERT_OK(res); + ASSERT_GTE(1, umn.numInPlaceCallbacks()); } - loc = res.getValue(); + uow.commit(); } } |