diff options
author | Jason Carey <jcarey@argv.me> | 2019-03-05 12:32:07 -0500 |
---|---|---|
committer | Jason Carey <jcarey@argv.me> | 2019-03-06 11:54:28 -0500 |
commit | 39b7722f44e2124ad46c19f95d4059985e7d4132 (patch) | |
tree | 7ac6fa40c1a693cd302e4701c76584013d57c7ba /src/mongo/db/operation_context_test.cpp | |
parent | 5926b6e06fec4f37e13740dc2eef8b5c7a806138 (diff) | |
download | mongo-39b7722f44e2124ad46c19f95d4059985e7d4132.tar.gz |
SERVER-38175 invariant on markKill w extra info
The OperationContext class accepts an ErrorCodes::Error for markKilled()
and deadline-setting methods. This error code may be converted to a
Status object on checkForInterruptNoAssert() or
waitForConditionOrInterruptNoAssertUntil() call. When the error code is
one that is associated with an ErrorExtraInfo object, Status
construction will fail as we expect Status construction to either
include a subclass of ErrorExtraInfo or a BSONObj from which it can be
serialized.
Until a use case comes up, add an invariant to prevent passing an error
code with extra info
Diffstat (limited to 'src/mongo/db/operation_context_test.cpp')
-rw-r--r-- | src/mongo/db/operation_context_test.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/operation_context_test.cpp b/src/mongo/db/operation_context_test.cpp index 8195a57cf26..998084a74b3 100644 --- a/src/mongo/db/operation_context_test.cpp +++ b/src/mongo/db/operation_context_test.cpp @@ -140,6 +140,22 @@ DEATH_TEST(OperationContextTest, SettingTransactionNumberWithoutSessionIdShouldC opCtx->setTxnNumber(5); } +DEATH_TEST(OperationContextTest, CallingMarkKillWithExtraInfoCrashes, "invariant") { + auto serviceCtx = ServiceContext::make(); + auto client = serviceCtx->makeClient("OperationContextTest"); + auto opCtx = client->makeOperationContext(); + + opCtx->markKilled(ErrorCodes::ForTestingErrorExtraInfo); +} + +DEATH_TEST(OperationContextTest, CallingSetDeadlineWithExtraInfoCrashes, "invariant") { + auto serviceCtx = ServiceContext::make(); + auto client = serviceCtx->makeClient("OperationContextTest"); + auto opCtx = client->makeOperationContext(); + + opCtx->setDeadlineByDate(Date_t::now(), ErrorCodes::ForTestingErrorExtraInfo); +} + TEST(OperationContextTest, OpCtxGroup) { OperationContextGroup group1; ASSERT_TRUE(group1.isEmpty()); |