summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/replica_set_tests.cpp
diff options
context:
space:
mode:
authorADAM David Alan Martin <adam.martin@10gen.com>2017-06-18 23:22:02 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2017-06-18 23:46:57 -0400
commit9abef6f25aadfd04309cb2219068097f93dc961d (patch)
treef88c7f183f201813f363d5d68c1a4a76781ca7ef /src/mongo/dbtests/replica_set_tests.cpp
parenta5f0a84c79b6ce41fef33da920c62be0ecc8f07b (diff)
downloadmongo-9abef6f25aadfd04309cb2219068097f93dc961d.tar.gz
SERVER-27244 Status usage compile-time facilities.
There are numerous places in the codebase where `mongo::Status` or `mongo::StatusWith< T >` objects are returned and never checked. Many of these are innocuous, but many of them are potentially severe bugs. This change introduces facilities to permit compile-time warning of unchecked `Status` and `StatusWith` usage on clang compilers. It introduces an `ignore` function which is useful to state that a specific "ignored status" case was intentional. It not presently an error, in clang builds, to forget to check a `Status` -- this will come in a later commit. This also introduces a `transitional_ignore` function, which allows for easy continual auditing of the codebase for current "whitelisted" unchecked-status instances. All present "ignored status" cases have been marked `transitional_ignore`.
Diffstat (limited to 'src/mongo/dbtests/replica_set_tests.cpp')
-rw-r--r--src/mongo/dbtests/replica_set_tests.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mongo/dbtests/replica_set_tests.cpp b/src/mongo/dbtests/replica_set_tests.cpp
index 91fa21f8800..e70a221fa57 100644
--- a/src/mongo/dbtests/replica_set_tests.cpp
+++ b/src/mongo/dbtests/replica_set_tests.cpp
@@ -93,14 +93,16 @@ TEST_F(ReplicaSetTest, ReplCoordExternalStateStoresLastVoteWithNewTerm) {
auto opCtx = makeOpCtx();
auto replCoordExternalState = getReplCoordExternalState();
- replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{2, 1});
+ replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{2, 1})
+ .transitional_ignore();
auto lastVote = replCoordExternalState->loadLocalLastVoteDocument(opCtx.get());
ASSERT_OK(lastVote.getStatus());
ASSERT_EQ(lastVote.getValue().getTerm(), 2);
ASSERT_EQ(lastVote.getValue().getCandidateIndex(), 1);
- replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{3, 1});
+ replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{3, 1})
+ .transitional_ignore();
lastVote = replCoordExternalState->loadLocalLastVoteDocument(opCtx.get());
ASSERT_OK(lastVote.getStatus());
@@ -112,14 +114,16 @@ TEST_F(ReplicaSetTest, ReplCoordExternalStateDoesNotStoreLastVoteWithOldTerm) {
auto opCtx = makeOpCtx();
auto replCoordExternalState = getReplCoordExternalState();
- replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{2, 1});
+ replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{2, 1})
+ .transitional_ignore();
auto lastVote = replCoordExternalState->loadLocalLastVoteDocument(opCtx.get());
ASSERT_OK(lastVote.getStatus());
ASSERT_EQ(lastVote.getValue().getTerm(), 2);
ASSERT_EQ(lastVote.getValue().getCandidateIndex(), 1);
- replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{1, 1});
+ replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{1, 1})
+ .transitional_ignore();
lastVote = replCoordExternalState->loadLocalLastVoteDocument(opCtx.get());
ASSERT_OK(lastVote.getStatus());
@@ -131,14 +135,16 @@ TEST_F(ReplicaSetTest, ReplCoordExternalStateDoesNotStoreLastVoteWithEqualTerm)
auto opCtx = makeOpCtx();
auto replCoordExternalState = getReplCoordExternalState();
- replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{2, 1});
+ replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{2, 1})
+ .transitional_ignore();
auto lastVote = replCoordExternalState->loadLocalLastVoteDocument(opCtx.get());
ASSERT_OK(lastVote.getStatus());
ASSERT_EQ(lastVote.getValue().getTerm(), 2);
ASSERT_EQ(lastVote.getValue().getCandidateIndex(), 1);
- replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{2, 2});
+ replCoordExternalState->storeLocalLastVoteDocument(opCtx.get(), repl::LastVote{2, 2})
+ .transitional_ignore();
lastVote = replCoordExternalState->loadLocalLastVoteDocument(opCtx.get());
ASSERT_OK(lastVote.getStatus());