summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2020-02-24 19:34:40 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-25 01:03:52 +0000
commit60f8edf788f75ac1a32bf702aae882b409767448 (patch)
tree8349abc7fce731c8f85e5ac2ed6894e900ba1763 /src/mongo
parent383d7183532929620cf31d7f89a0a37daaea8b8e (diff)
downloadmongo-60f8edf788f75ac1a32bf702aae882b409767448.tar.gz
SERVER-46219 Unit Tests should log with json
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/base/status_test.cpp4
-rw-r--r--src/mongo/bson/mutable/mutable_bson_test.cpp12
-rw-r--r--src/mongo/db/exec/projection_executor_utils_test.cpp12
-rw-r--r--src/mongo/db/index/sort_key_generator_test.cpp6
-rw-r--r--src/mongo/db/matcher/expression_internal_expr_eq_test.cpp14
-rw-r--r--src/mongo/db/matcher/expression_leaf_test.cpp10
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_object_match_test.cpp6
-rw-r--r--src/mongo/db/op_observer_impl_test.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_facet_test.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_match_test.cpp12
-rw-r--r--src/mongo/db/pipeline/document_source_sample_test.cpp6
-rw-r--r--src/mongo/db/query/index_entry_test.cpp6
-rw-r--r--src/mongo/db/repl/oplog_buffer_collection_test.cpp39
-rw-r--r--src/mongo/db/repl/oplog_buffer_proxy_test.cpp6
-rw-r--r--src/mongo/db/repl/oplog_fetcher_test.cpp6
-rw-r--r--src/mongo/db/repl/replication_recovery_test.cpp80
-rw-r--r--src/mongo/db/repl/rollback_impl_test.cpp14
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp10
-rw-r--r--src/mongo/db/storage/kv/durable_catalog_test.cpp18
-rw-r--r--src/mongo/db/storage/kv/kv_engine_test_harness.cpp4
-rw-r--r--src/mongo/db/transaction_participant_retryable_writes_test.cpp20
-rw-r--r--src/mongo/db/update/addtoset_node_test.cpp10
-rw-r--r--src/mongo/db/update/arithmetic_node_test.cpp4
-rw-r--r--src/mongo/db/update/compare_node_test.cpp10
-rw-r--r--src/mongo/db/update/current_date_node_test.cpp4
-rw-r--r--src/mongo/db/update/pop_node_test.cpp6
-rw-r--r--src/mongo/db/update/set_node_test.cpp2
-rw-r--r--src/mongo/db/update/unset_node_test.cpp10
-rw-r--r--src/mongo/db/update/update_array_node_test.cpp6
-rw-r--r--src/mongo/db/update/update_object_node_test.cpp6
-rw-r--r--src/mongo/db/views/view_definition_test.cpp12
-rw-r--r--src/mongo/s/query/async_results_merger_test.cpp20
-rw-r--r--src/mongo/s/shard_key_pattern_test.cpp12
-rw-r--r--src/mongo/s/transaction_router_test.cpp18
-rw-r--r--src/mongo/unittest/death_test.cpp9
-rw-r--r--src/mongo/unittest/death_test.h33
-rw-r--r--src/mongo/unittest/unittest.h15
-rw-r--r--src/mongo/unittest/unittest_main.cpp12
-rw-r--r--src/mongo/unittest/unittest_test.cpp2
-rw-r--r--src/mongo/util/assert_util_test.cpp4
-rw-r--r--src/mongo/util/concurrency/thread_pool_test.cpp15
-rw-r--r--src/mongo/util/concurrency/thread_pool_test_common.cpp3
-rw-r--r--src/mongo/util/latch_analyzer_test.cpp8
-rw-r--r--src/mongo/util/signal_handlers_synchronous_test.cpp2
46 files changed, 299 insertions, 233 deletions
diff --git a/src/mongo/base/status_test.cpp b/src/mongo/base/status_test.cpp
index eeff3daae91..adb710f06d6 100644
--- a/src/mongo/base/status_test.cpp
+++ b/src/mongo/base/status_test.cpp
@@ -280,12 +280,12 @@ TEST(Transformers, ExceptionToStatus) {
ASSERT_TRUE(fromBoostExcept.reason().find("boost::exception") != std::string::npos);
}
-DEATH_TEST(ErrorExtraInfo, InvariantAllRegistered, "Invariant failure parsers::") {
+DEATH_TEST_REGEX(ErrorExtraInfo, InvariantAllRegistered, "Invariant failure.*parsers::") {
ErrorExtraInfo::invariantHaveAllParsers();
}
#ifdef MONGO_CONFIG_DEBUG_BUILD
-DEATH_TEST(ErrorExtraInfo, DassertShouldHaveExtraInfo, "Fatal Assertion 40680") {
+DEATH_TEST_REGEX(ErrorExtraInfo, DassertShouldHaveExtraInfo, "Fatal Assertion.*40680") {
Status(ErrorCodes::ForTestingErrorExtraInfo, "");
}
#else
diff --git a/src/mongo/bson/mutable/mutable_bson_test.cpp b/src/mongo/bson/mutable/mutable_bson_test.cpp
index 58a46d04ce3..7e215379cb8 100644
--- a/src/mongo/bson/mutable/mutable_bson_test.cpp
+++ b/src/mongo/bson/mutable/mutable_bson_test.cpp
@@ -545,9 +545,9 @@ TEST(ArrayAPI, SimpleNumericArray) {
ASSERT_FALSE(e1[1].ok());
}
-DEATH_TEST(ArrayAPI,
- FindFirstChildNamedOnDeserializedArray,
- "Invariant failure getType() != BSONType::Array") {
+DEATH_TEST_REGEX(ArrayAPI,
+ FindFirstChildNamedOnDeserializedArray,
+ R"#(Invariant failure.*getType\(\) != BSONType::Array)#") {
mmb::Document doc;
auto array = doc.makeElementArray("a");
auto elem0 = doc.makeElementInt("", 0);
@@ -555,9 +555,9 @@ DEATH_TEST(ArrayAPI,
array.findFirstChildNamed("0");
}
-DEATH_TEST(ArrayAPI,
- FindFirstChildNamedOnSerializedArray,
- "Invariant failure getType() != BSONType::Array") {
+DEATH_TEST_REGEX(ArrayAPI,
+ FindFirstChildNamedOnSerializedArray,
+ R"#(Invariant failure.*getType\(\) != BSONType::Array)#") {
auto obj = fromjson("{a: [0, 1]}");
mmb::Document doc(obj);
auto rootElem = doc.root();
diff --git a/src/mongo/db/exec/projection_executor_utils_test.cpp b/src/mongo/db/exec/projection_executor_utils_test.cpp
index 867a1de7704..a020620543d 100644
--- a/src/mongo/db/exec/projection_executor_utils_test.cpp
+++ b/src/mongo/db/exec/projection_executor_utils_test.cpp
@@ -217,16 +217,16 @@ TEST(ElemMatchProjection, RertursEmptyValuefItContainsNumericSubfield) {
} // namespace elem_match_projection_tests
namespace slice_projection_tests {
-DEATH_TEST(SliceProjection,
- ShouldFailIfNegativeLimitSpecifiedWithPositiveSkip,
- "Invariant failure limit >= 0") {
+DEATH_TEST_REGEX(SliceProjection,
+ ShouldFailIfNegativeLimitSpecifiedWithPositiveSkip,
+ "Invariant failure.*limit >= 0") {
auto doc = Document{fromjson("{a: [1,2,3,4]}")};
projection_executor_utils::applyFindSliceProjection(doc, "a", 1, -1);
}
-DEATH_TEST(SliceProjection,
- ShouldFailIfNegativeLimitSpecifiedWithNegativeSkip,
- "Invariant failure limit >= 0") {
+DEATH_TEST_REGEX(SliceProjection,
+ ShouldFailIfNegativeLimitSpecifiedWithNegativeSkip,
+ "Invariant failure.*limit >= 0") {
auto doc = Document{fromjson("{a: [1,2,3,4]}")};
projection_executor_utils::applyFindSliceProjection(doc, "a", -1, -1);
}
diff --git a/src/mongo/db/index/sort_key_generator_test.cpp b/src/mongo/db/index/sort_key_generator_test.cpp
index 59991cf4947..5f4834bbdce 100644
--- a/src/mongo/db/index/sort_key_generator_test.cpp
+++ b/src/mongo/db/index/sort_key_generator_test.cpp
@@ -336,9 +336,9 @@ TEST_F(SortKeyGeneratorWorkingSetTest, CanGenerateSortKeyFromWSMInIndexKeyStateW
ASSERT_VALUE_EQ(Value("1gnirts"_sd), sortKey);
}
-DEATH_TEST_F(SortKeyGeneratorWorkingSetTest,
- DeathOnAttemptToGetSortKeyFromIndexKeyWithMetadata,
- "Invariant failure !_sortHasMeta") {
+DEATH_TEST_REGEX_F(SortKeyGeneratorWorkingSetTest,
+ DeathOnAttemptToGetSortKeyFromIndexKeyWithMetadata,
+ "Invariant failure.*!_sortHasMeta") {
BSONObj pattern = fromjson("{z: {$meta: 'textScore'}}");
auto sortKeyGen = makeSortKeyGen(pattern, nullptr);
setRecordIdAndIdx(BSON("a" << 1 << "b" << 1), BSON("" << 2 << "" << 3));
diff --git a/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp b/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp
index 833d7c9451d..bd5ad2d878a 100644
--- a/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp
+++ b/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp
@@ -300,23 +300,23 @@ TEST(InternalExprEqMatchExpression, EquivalentToClone) {
ASSERT_TRUE(eq.getMatchExpression()->equivalent(clone.get()));
}
-DEATH_TEST(InternalExprEqMatchExpression,
- CannotCompareToArray,
- "Invariant failure _rhs.type() != BSONType::Array") {
+DEATH_TEST_REGEX(InternalExprEqMatchExpression,
+ CannotCompareToArray,
+ R"#(Invariant failure.*_rhs.type\(\) != BSONType::Array)#") {
auto operand = BSON("a" << BSON_ARRAY(1 << 2));
InternalExprEqMatchExpression eq(operand.firstElement().fieldNameStringData(),
operand.firstElement());
}
-DEATH_TEST(InternalExprEqMatchExpression,
- CannotCompareToUndefined,
- "Invariant failure _rhs.type() != BSONType::Undefined") {
+DEATH_TEST_REGEX(InternalExprEqMatchExpression,
+ CannotCompareToUndefined,
+ R"#(Invariant failure.*_rhs.type\(\) != BSONType::Undefined)#") {
auto operand = BSON("a" << BSONUndefined);
InternalExprEqMatchExpression eq(operand.firstElement().fieldNameStringData(),
operand.firstElement());
}
-DEATH_TEST(InternalExprEqMatchExpression, CannotCompareToMissing, "Invariant failure _rhs") {
+DEATH_TEST_REGEX(InternalExprEqMatchExpression, CannotCompareToMissing, "Invariant failure.*_rhs") {
InternalExprEqMatchExpression eq("a"_sd, BSONElement());
}
} // namespace
diff --git a/src/mongo/db/matcher/expression_leaf_test.cpp b/src/mongo/db/matcher/expression_leaf_test.cpp
index 87a7953429f..8ee1d50cb1b 100644
--- a/src/mongo/db/matcher/expression_leaf_test.cpp
+++ b/src/mongo/db/matcher/expression_leaf_test.cpp
@@ -97,7 +97,7 @@ TEST(EqOp, MatchesElement) {
ASSERT(eq.equivalent(&eq));
}
-DEATH_TEST(EqOp, InvalidEooOperand, "Invariant failure _rhs") {
+DEATH_TEST_REGEX(EqOp, InvalidEooOperand, "Invariant failure.*_rhs") {
BSONObj operand;
EqualityMatchExpression eq("", operand.firstElement());
}
@@ -265,7 +265,7 @@ TEST(LtOp, MatchesElement) {
ASSERT(!lt.matchesSingleElement(notMatchWrongType.firstElement()));
}
-DEATH_TEST(LtOp, InvalidEooOperand, "Invariant failure _rhs") {
+DEATH_TEST_REGEX(LtOp, InvalidEooOperand, "Invariant failure.*_rhs") {
BSONObj operand;
LTMatchExpression lt("", operand.firstElement());
}
@@ -386,7 +386,7 @@ TEST(LteOp, MatchesElement) {
ASSERT(!lte.matchesSingleElement(notMatchWrongType.firstElement()));
}
-DEATH_TEST(LteOp, InvalidEooOperand, "Invariant failure _rhs") {
+DEATH_TEST_REGEX(LteOp, InvalidEooOperand, "Invariant failure.*_rhs") {
BSONObj operand;
LTEMatchExpression lte("", operand.firstElement());
}
@@ -487,7 +487,7 @@ TEST(LteOp, ElemMatchKey) {
ASSERT_EQUALS("1", details.elemMatchKey());
}
-DEATH_TEST(GtOp, InvalidEooOperand, "Invariant failure _rhs") {
+DEATH_TEST_REGEX(GtOp, InvalidEooOperand, "Invariant failure.*_rhs") {
BSONObj operand;
GTMatchExpression gt("", operand.firstElement());
}
@@ -603,7 +603,7 @@ TEST(GteOp, MatchesElement) {
ASSERT(!gte.matchesSingleElement(notMatchWrongType.firstElement()));
}
-DEATH_TEST(GteOp, InvalidEooOperand, "Invariant failure _rhs") {
+DEATH_TEST_REGEX(GteOp, InvalidEooOperand, "Invariant failure.*_rhs") {
BSONObj operand;
GTEMatchExpression gte("", operand.firstElement());
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp
index 46edca2496b..44f43bf2832 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp
@@ -109,9 +109,9 @@ TEST(InternalSchemaAllElemMatchFromIndexMatchExpression, HasSingleChild) {
ASSERT(objMatch.getValue()->getChild(0));
}
-DEATH_TEST(InternalSchemaAllElemMatchFromIndexMatchExpression,
- GetChildFailsIndexGreaterThanOne,
- "Invariant failure i == 0") {
+DEATH_TEST_REGEX(InternalSchemaAllElemMatchFromIndexMatchExpression,
+ GetChildFailsIndexGreaterThanOne,
+ "Invariant failure.*i == 0") {
auto query = fromjson("{'a.b': {$_internalSchemaAllElemMatchFromIndex: [2, {a: {$lt: 5}}]}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
auto objMatch = MatchExpressionParser::parse(query, expCtx);
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp
index a6879e10089..854c2cf73a8 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp
@@ -128,9 +128,9 @@ TEST(InternalSchemaMatchArrayIndexMatchExpression, HasSingleChild) {
ASSERT(objMatch.getValue()->getChild(0));
}
-DEATH_TEST(InternalSchemaMatchArrayIndexMatchExpression,
- GetChildFailsIndexGreaterThanZero,
- "Invariant failure i == 0") {
+DEATH_TEST_REGEX(InternalSchemaMatchArrayIndexMatchExpression,
+ GetChildFailsIndexGreaterThanZero,
+ "Invariant failure.*i == 0") {
auto query = fromjson(
"{foo: {$_internalSchemaMatchArrayIndex:"
"{index: 0, namePlaceholder: 'i', expression: {i: {$type: 'number'}}}}}");
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_object_match_test.cpp
index 8eb9332aed7..6c8dee32e26 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match_test.cpp
@@ -216,9 +216,9 @@ TEST(InternalSchemaObjectMatchExpression, HasSingleChild) {
ASSERT(objMatch.getValue()->getChild(0));
}
-DEATH_TEST(InternalSchemaObjectMatchExpression,
- GetChildFailsIndexGreaterThanZero,
- "Invariant failure i == 0") {
+DEATH_TEST_REGEX(InternalSchemaObjectMatchExpression,
+ GetChildFailsIndexGreaterThanZero,
+ "Invariant failure.*i == 0") {
auto query = fromjson(
" {a: {$_internalSchemaObjectMatch: {"
" c: {$eq: 3}"
diff --git a/src/mongo/db/op_observer_impl_test.cpp b/src/mongo/db/op_observer_impl_test.cpp
index 79270c9b5cd..e197b34b70c 100644
--- a/src/mongo/db/op_observer_impl_test.cpp
+++ b/src/mongo/db/op_observer_impl_test.cpp
@@ -555,9 +555,9 @@ DEATH_TEST_F(OpObserverTest, EachOnDeleteRequiresAboutToDelete, "invariant") {
opObserver.onDelete(opCtx.get(), nss, {}, kUninitializedStmtId, false, boost::none);
}
-DEATH_TEST_F(OpObserverTest,
- NodeCrashesIfShardIdentityDocumentRolledBack,
- "Fatal Assertion 50712") {
+DEATH_TEST_REGEX_F(OpObserverTest,
+ NodeCrashesIfShardIdentityDocumentRolledBack,
+ "Fatal Assertion.*50712") {
OpObserverImpl opObserver;
auto opCtx = cc().makeOperationContext();
diff --git a/src/mongo/db/pipeline/document_source_facet_test.cpp b/src/mongo/db/pipeline/document_source_facet_test.cpp
index 6cb58d29279..6316452c22b 100644
--- a/src/mongo/db/pipeline/document_source_facet_test.cpp
+++ b/src/mongo/db/pipeline/document_source_facet_test.cpp
@@ -455,9 +455,9 @@ TEST_F(DocumentSourceFacetTest, ShouldPropagateDisposeThroughToSource) {
}
// TODO: DocumentSourceFacet will have to propagate pauses if we ever allow nested $facets.
-DEATH_TEST_F(DocumentSourceFacetTest,
- ShouldFailIfGivenPausedInput,
- "Invariant failure !input.isPaused()") {
+DEATH_TEST_REGEX_F(DocumentSourceFacetTest,
+ ShouldFailIfGivenPausedInput,
+ R"#(Invariant failure.*!input.isPaused\(\))#") {
auto ctx = getExpCtx();
auto mock =
DocumentSourceMock::createForTest(DocumentSource::GetNextResult::makePauseExecution());
diff --git a/src/mongo/db/pipeline/document_source_match_test.cpp b/src/mongo/db/pipeline/document_source_match_test.cpp
index 264e055b64e..7421529982a 100644
--- a/src/mongo/db/pipeline/document_source_match_test.cpp
+++ b/src/mongo/db/pipeline/document_source_match_test.cpp
@@ -526,9 +526,9 @@ TEST_F(DocumentSourceMatchTest, ShouldCorrectlyJoinWithSubsequentMatch) {
ASSERT_TRUE(match->getNext().isEOF());
}
-DEATH_TEST_F(DocumentSourceMatchTest,
- ShouldFailToDescendExpressionOnPathThatIsNotACommonPrefix,
- "Invariant failure expression::isPathPrefixOf") {
+DEATH_TEST_REGEX_F(DocumentSourceMatchTest,
+ ShouldFailToDescendExpressionOnPathThatIsNotACommonPrefix,
+ "Invariant failure.*expression::isPathPrefixOf") {
const auto expCtx = getExpCtx();
const auto matchSpec = BSON("a.b" << 1 << "b.c" << 1);
const auto matchExpression =
@@ -536,9 +536,9 @@ DEATH_TEST_F(DocumentSourceMatchTest,
DocumentSourceMatch::descendMatchOnPath(matchExpression.get(), "a", expCtx);
}
-DEATH_TEST_F(DocumentSourceMatchTest,
- ShouldFailToDescendExpressionOnPathThatContainsElemMatchWithObject,
- "Invariant failure node->matchType()") {
+DEATH_TEST_REGEX_F(DocumentSourceMatchTest,
+ ShouldFailToDescendExpressionOnPathThatContainsElemMatchWithObject,
+ R"#(Invariant failure.*node->matchType\(\))#") {
const auto expCtx = getExpCtx();
const auto matchSpec = BSON("a" << BSON("$elemMatch" << BSON("a.b" << 1)));
const auto matchExpression =
diff --git a/src/mongo/db/pipeline/document_source_sample_test.cpp b/src/mongo/db/pipeline/document_source_sample_test.cpp
index a2b10600053..0d66a68cac8 100644
--- a/src/mongo/db/pipeline/document_source_sample_test.cpp
+++ b/src/mongo/db/pipeline/document_source_sample_test.cpp
@@ -390,9 +390,9 @@ TEST_F(SampleFromRandomCursorBasics, MimicNonOptimized) {
ASSERT_LTE(secondTotal / nTrials, 0.52);
}
-DEATH_TEST_F(SampleFromRandomCursorBasics,
- ShouldFailIfGivenPausedInput,
- "Invariant failure Hit a MONGO_UNREACHABLE!") {
+DEATH_TEST_REGEX_F(SampleFromRandomCursorBasics,
+ ShouldFailIfGivenPausedInput,
+ "Invariant failure.*Hit a MONGO_UNREACHABLE!") {
createSample(2);
source()->push_back(Document{{"_id", 1}});
source()->push_back(DocumentSource::GetNextResult::makePauseExecution());
diff --git a/src/mongo/db/query/index_entry_test.cpp b/src/mongo/db/query/index_entry_test.cpp
index 5c11630f696..6f80c6c8670 100644
--- a/src/mongo/db/query/index_entry_test.cpp
+++ b/src/mongo/db/query/index_entry_test.cpp
@@ -93,9 +93,9 @@ TEST(QueryPlannerIXSelectTest, IndexedFieldHasMultikeyComponents) {
ASSERT_TRUE(indexEntry.pathHasMultikeyComponent("d"_sd));
}
-DEATH_TEST(QueryPlannerIXSelectTest,
- IndexedFieldHasMultikeyComponentsPassingInvalidFieldIsFatal,
- "Invariant failure Hit a MONGO_UNREACHABLE!") {
+DEATH_TEST_REGEX(QueryPlannerIXSelectTest,
+ IndexedFieldHasMultikeyComponentsPassingInvalidFieldIsFatal,
+ "Invariant failure.*Hit a MONGO_UNREACHABLE!") {
auto indexEntry = makeIndexEntry(BSON("a" << 1), {{}});
indexEntry.pathHasMultikeyComponent("b"_sd);
}
diff --git a/src/mongo/db/repl/oplog_buffer_collection_test.cpp b/src/mongo/db/repl/oplog_buffer_collection_test.cpp
index 27af958e745..81921cee85a 100644
--- a/src/mongo/db/repl/oplog_buffer_collection_test.cpp
+++ b/src/mongo/db/repl/oplog_buffer_collection_test.cpp
@@ -155,9 +155,10 @@ TEST_F(OplogBufferCollectionTest, StartupWithUserProvidedNamespaceCreatesCollect
testStartupCreatesCollection(_opCtx.get(), _storageInterface, makeNamespace(_agent));
}
-DEATH_TEST_F(OplogBufferCollectionTest,
- StartupWithOplogNamespaceTriggersFatalAssertion,
- "Fatal assertion 40154 Location28838: cannot create a non-capped oplog collection") {
+DEATH_TEST_REGEX_F(
+ OplogBufferCollectionTest,
+ StartupWithOplogNamespaceTriggersFatalAssertion,
+ "Fatal assertion.*40154.*Location28838: cannot create a non-capped oplog collection") {
testStartupCreatesCollection(_opCtx.get(), _storageInterface, NamespaceString("local.oplog.Z"));
}
@@ -235,9 +236,9 @@ TEST_F(OplogBufferCollectionTest, addIdToDocumentGeneratesIdForSentinelFromLastP
ts2, 3U, OplogBufferCollection::addIdToDocument({}, ts2, 2U));
}
-DEATH_TEST_F(OplogBufferCollectionTest,
- addIdToDocumentWithMissingTimestampFieldTriggersInvariantFailure,
- "Invariant failure !ts.isNull()") {
+DEATH_TEST_REGEX_F(OplogBufferCollectionTest,
+ addIdToDocumentWithMissingTimestampFieldTriggersInvariantFailure,
+ R"#(Invariant failure.*!ts.isNull\(\))#") {
OplogBufferCollection::addIdToDocument(BSON("x" << 1), {}, 0);
}
@@ -361,11 +362,11 @@ TEST_F(OplogBufferCollectionTest, ShutdownWithDropCollectionAtShutdownFalseDoesN
ASSERT_EQUALS(oplogBuffer.getCount(), 1UL);
}
-DEATH_TEST_F(OplogBufferCollectionTest,
- StartupWithExistingCollectionFailsWhenEntryHasNoId,
- "Fatal assertion 40348 IndexNotFound: Index not found, "
- "ns:local.OplogBufferCollectionTest_"
- "StartupWithExistingCollectionFailsWhenEntryHasNoId, index: _id_") {
+DEATH_TEST_REGEX_F(OplogBufferCollectionTest,
+ StartupWithExistingCollectionFailsWhenEntryHasNoId,
+ "Fatal assertion.*40348.*IndexNotFound: Index not found, "
+ "ns:local.OplogBufferCollectionTest_"
+ "StartupWithExistingCollectionFailsWhenEntryHasNoId, index: _id_") {
auto nss = makeNamespace(_agent);
CollectionOptions collOpts;
collOpts.setNoIdIndex();
@@ -381,9 +382,9 @@ DEATH_TEST_F(OplogBufferCollectionTest,
oplogBuffer.startup(_opCtx.get());
}
-DEATH_TEST_F(OplogBufferCollectionTest,
- StartupWithExistingCollectionFailsWhenEntryHasNoTimestamp,
- "Fatal assertion 40405 NoSuchKey: Missing expected field \"ts\"") {
+DEATH_TEST_REGEX_F(OplogBufferCollectionTest,
+ StartupWithExistingCollectionFailsWhenEntryHasNoTimestamp,
+ R"#(Fatal assertion.*40405.*NoSuchKey: Missing expected field \\"ts\\")#") {
auto nss = makeNamespace(_agent);
ASSERT_OK(_storageInterface->createCollection(_opCtx.get(), nss, CollectionOptions()));
ASSERT_OK(_storageInterface->insertDocument(_opCtx.get(),
@@ -397,9 +398,9 @@ DEATH_TEST_F(OplogBufferCollectionTest,
oplogBuffer.startup(_opCtx.get());
}
-DEATH_TEST_F(OplogBufferCollectionTest,
- StartupWithExistingCollectionFailsWhenEntryHasNoSentinelCount,
- "Fatal assertion 40406 NoSuchKey: Missing expected field \"s\"") {
+DEATH_TEST_REGEX_F(OplogBufferCollectionTest,
+ StartupWithExistingCollectionFailsWhenEntryHasNoSentinelCount,
+ R"#(Fatal assertion.*40406.*NoSuchKey: Missing expected field \\"s\\")#") {
auto nss = makeNamespace(_agent);
ASSERT_OK(_storageInterface->createCollection(_opCtx.get(), nss, CollectionOptions()));
ASSERT_OK(_storageInterface->insertDocument(
@@ -936,10 +937,10 @@ TEST_F(OplogBufferCollectionTest, PushAllNonBlockingPushesOnSentinelsProperly) {
});
}
-DEATH_TEST_F(
+DEATH_TEST_REGEX_F(
OplogBufferCollectionTest,
PushAllNonBlockingWithOutOfOrderDocumentsTriggersInvariantFailure,
- "Invariant failure value.isEmpty() ? ts == previousTimestamp : ts > previousTimestamp") {
+ R"#(Invariant failure.*value.isEmpty\(\) \? ts == previousTimestamp : ts > previousTimestamp)#") {
auto nss = makeNamespace(_agent);
OplogBufferCollection oplogBuffer(_storageInterface, nss);
diff --git a/src/mongo/db/repl/oplog_buffer_proxy_test.cpp b/src/mongo/db/repl/oplog_buffer_proxy_test.cpp
index 03e51aa2a4e..eab37c883d3 100644
--- a/src/mongo/db/repl/oplog_buffer_proxy_test.cpp
+++ b/src/mongo/db/repl/oplog_buffer_proxy_test.cpp
@@ -149,9 +149,9 @@ void OplogBufferProxyTest::tearDown() {
_mock = nullptr;
}
-DEATH_TEST_F(OplogBufferProxyTest,
- NullTargetOplogBufferAtConstructionTriggersInvariant,
- "Invariant failure _target") {
+DEATH_TEST_REGEX_F(OplogBufferProxyTest,
+ NullTargetOplogBufferAtConstructionTriggersInvariant,
+ "Invariant failure.*_target") {
OplogBufferProxy(nullptr);
}
diff --git a/src/mongo/db/repl/oplog_fetcher_test.cpp b/src/mongo/db/repl/oplog_fetcher_test.cpp
index ae50946d213..0191fc2ada0 100644
--- a/src/mongo/db/repl/oplog_fetcher_test.cpp
+++ b/src/mongo/db/repl/oplog_fetcher_test.cpp
@@ -824,9 +824,9 @@ TEST_F(OplogFetcherTest, InvalidOplogQueryMetadataInResponseStopsTheOplogFetcher
processSingleBatch(makeFirstBatch(cursorId, {entry}, metadataObj))->getStatus());
}
-DEATH_TEST_F(OplogFetcherTest,
- ValidMetadataInResponseWithoutOplogMetadataInvariants,
- "Invariant failure oqMetadata") {
+DEATH_TEST_REGEX_F(OplogFetcherTest,
+ ValidMetadataInResponseWithoutOplogMetadataInvariants,
+ "Invariant failure.*oqMetadata") {
CursorId cursorId = 22LL;
auto entry = makeNoopOplogEntry(lastFetched);
auto metadataObj = makeOplogBatchMetadata(replSetMetadata, boost::none);
diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp
index b14b911d973..e946b535c0d 100644
--- a/src/mongo/db/repl/replication_recovery_test.cpp
+++ b/src/mongo/db/repl/replication_recovery_test.cpp
@@ -427,9 +427,9 @@ TEST_F(ReplicationRecoveryTest, RecoveryWithEmptyOplogSucceedsWithStableTimestam
_assertDocsInTestCollection(opCtx, {});
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- TruncateFassertsWithoutOplogCollection,
- "Fatal assertion 34418 NamespaceNotFound: Can't find local.oplog.rs") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ TruncateFassertsWithoutOplogCollection,
+ "Fatal assertion.*34418.*NamespaceNotFound: Can't find local.oplog.rs") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -455,7 +455,7 @@ DEATH_TEST_F(ReplicationRecoveryTest,
recovery.recoverFromOplog(opCtx, Timestamp(1, 1));
}
-DEATH_TEST_F(ReplicationRecoveryTest, TruncateEntireOplogFasserts, "Fatal Assertion 40296") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest, TruncateEntireOplogFasserts, "Fatal Assertion.*40296") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -779,7 +779,9 @@ TEST_F(ReplicationRecoveryTest,
testRecoveryAppliesDocumentsWithNoAppliedThroughAfterTruncation(false);
}
-DEATH_TEST_F(ReplicationRecoveryTest, AppliedThroughBehindOplogFasserts, "Fatal Assertion 40292") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ AppliedThroughBehindOplogFasserts,
+ "Fatal Assertion.*40292") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -789,9 +791,9 @@ DEATH_TEST_F(ReplicationRecoveryTest, AppliedThroughBehindOplogFasserts, "Fatal
recovery.recoverFromOplog(opCtx, boost::none);
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- AppliedThroughAheadOfTopOfOplogCausesFassert,
- "Fatal Assertion 40313") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ AppliedThroughAheadOfTopOfOplogCausesFassert,
+ "Fatal Assertion.*40313") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -801,9 +803,9 @@ DEATH_TEST_F(ReplicationRecoveryTest,
recovery.recoverFromOplog(opCtx, boost::none);
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- AppliedThroughNotInOplogCausesFassert,
- "Fatal Assertion 40292") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ AppliedThroughNotInOplogCausesFassert,
+ "Fatal Assertion.*40292") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -1079,9 +1081,9 @@ TEST_F(ReplicationRecoveryTest, AbortTransactionOplogEntryCorrectlyUpdatesConfig
ASSERT_EQ(getConsistencyMarkers()->getAppliedThrough(opCtx), OpTime(Timestamp(3, 0), 1));
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- RecoveryFailsWithPrepareAndEnableReadConcernMajorityFalse,
- "Fatal Assertion 51146") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ RecoveryFailsWithPrepareAndEnableReadConcernMajorityFalse,
+ "Fatal Assertion.*51146") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -1474,9 +1476,9 @@ TEST_F(ReplicationRecoveryTest,
}
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- RecoverFromOplogUpToWithoutStableCheckpoint,
- "Fatal Assertion 31399") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ RecoverFromOplogUpToWithoutStableCheckpoint,
+ "Fatal Assertion.*31399") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -1485,9 +1487,9 @@ DEATH_TEST_F(ReplicationRecoveryTest,
recovery.recoverFromOplogUpTo(opCtx, Timestamp(5, 5));
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- RecoverFromOplogAsStandaloneFailsWithoutStableCheckpoint,
- "Fatal Assertion 31229") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ RecoverFromOplogAsStandaloneFailsWithoutStableCheckpoint,
+ "Fatal Assertion.*31229") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -1496,9 +1498,9 @@ DEATH_TEST_F(ReplicationRecoveryTest,
recovery.recoverFromOplogAsStandalone(opCtx);
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- RecoverFromOplogAsStandaloneFailsWithNullStableCheckpoint,
- "Fatal Assertion 50806") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ RecoverFromOplogAsStandaloneFailsWithNullStableCheckpoint,
+ "Fatal Assertion.*50806") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -1508,9 +1510,9 @@ DEATH_TEST_F(ReplicationRecoveryTest,
recovery.recoverFromOplogAsStandalone(opCtx);
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- RecoverFromOplogUpToFailsWithNullStableCheckpoint,
- "Fatal Assertion 50806") {
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ RecoverFromOplogUpToFailsWithNullStableCheckpoint,
+ "Fatal Assertion.*50806") {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -1564,10 +1566,10 @@ TEST_F(ReplicationRecoveryTest,
_assertDocsInTestCollection(opCtx, {});
}
-DEATH_TEST_F(
+DEATH_TEST_REGEX_F(
ReplicationRecoveryTest,
RecoverFromOplogAsStandaloneWithTakeUnstableCheckpointOnShutdownFailsWithInitialSyncFlag,
- "Fatal Assertion 31362") {
+ "Fatal Assertion.*31362") {
gTakeUnstableCheckpointOnShutdown = true;
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
@@ -1579,10 +1581,10 @@ DEATH_TEST_F(
recovery.recoverFromOplogAsStandalone(opCtx);
}
-DEATH_TEST_F(
+DEATH_TEST_REGEX_F(
ReplicationRecoveryTest,
RecoverFromOplogAsStandaloneWithTakeUnstableCheckpointOnShutdownFailsWithOplogTruncateAfterPoint,
- "Fatal Assertion 31363") {
+ "Fatal Assertion.*31363") {
gTakeUnstableCheckpointOnShutdown = true;
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
@@ -1594,9 +1596,10 @@ DEATH_TEST_F(
recovery.recoverFromOplogAsStandalone(opCtx);
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- RecoverFromOplogAsStandaloneWithTakeUnstableCheckpointOnShutdownFailsWithEmptyOplog,
- "Fatal Assertion 31364") {
+DEATH_TEST_REGEX_F(
+ ReplicationRecoveryTest,
+ RecoverFromOplogAsStandaloneWithTakeUnstableCheckpointOnShutdownFailsWithEmptyOplog,
+ "Fatal Assertion.*31364") {
gTakeUnstableCheckpointOnShutdown = true;
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
@@ -1607,10 +1610,10 @@ DEATH_TEST_F(ReplicationRecoveryTest,
recovery.recoverFromOplogAsStandalone(opCtx);
}
-DEATH_TEST_F(
+DEATH_TEST_REGEX_F(
ReplicationRecoveryTest,
RecoverFromOplogAsStandaloneWithTakeUnstableCheckpointOnShutdownFailsWithMismatchedAppliedThrough,
- "Fatal Assertion 31365") {
+ "Fatal Assertion.*31365") {
gTakeUnstableCheckpointOnShutdown = true;
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
@@ -1622,9 +1625,10 @@ DEATH_TEST_F(
recovery.recoverFromOplogAsStandalone(opCtx);
}
-DEATH_TEST_F(ReplicationRecoveryTest,
- RecoverFromOplogAsStandaloneWithTakeUnstableCheckpointOnShutdownFailsWithHighMinValid,
- "Fatal Assertion 31366") {
+DEATH_TEST_REGEX_F(
+ ReplicationRecoveryTest,
+ RecoverFromOplogAsStandaloneWithTakeUnstableCheckpointOnShutdownFailsWithHighMinValid,
+ "Fatal Assertion.*31366") {
gTakeUnstableCheckpointOnShutdown = true;
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
diff --git a/src/mongo/db/repl/rollback_impl_test.cpp b/src/mongo/db/repl/rollback_impl_test.cpp
index 47249dcd124..6a540287d8a 100644
--- a/src/mongo/db/repl/rollback_impl_test.cpp
+++ b/src/mongo/db/repl/rollback_impl_test.cpp
@@ -663,9 +663,9 @@ TEST_F(RollbackImplTest, RollbackCallsRecoverToStableTimestamp) {
ASSERT_EQUALS(stableTimestamp, _stableTimestamp);
}
-DEATH_TEST_F(RollbackImplTest,
- RollbackFassertsIfRecoverToStableTimestampFails,
- "Fatal assertion 31049") {
+DEATH_TEST_REGEX_F(RollbackImplTest,
+ RollbackFassertsIfRecoverToStableTimestampFails,
+ "Fatal assertion.*31049") {
auto op = makeOpAndRecordId(1);
_remoteOplog->setOperations({op});
ASSERT_OK(_insertOplogEntry(op.first));
@@ -871,10 +871,10 @@ TEST_F(RollbackImplTest, RollbackSucceedsAndTruncatesOplog) {
ASSERT_EQUALS(_truncatePoint, Timestamp(1, 1));
}
-DEATH_TEST_F(RollbackImplTest,
- RollbackTriggersFatalAssertionOnFailingToTransitionFromRollbackToSecondary,
- "Failed to transition into SECONDARY; expected to be in state ROLLBACK; found self in "
- "ROLLBACK") {
+DEATH_TEST_REGEX_F(RollbackImplTest,
+ RollbackTriggersFatalAssertionOnFailingToTransitionFromRollbackToSecondary,
+ "Failed to transition into .*; expected to be in state .*; found self in "
+ ".*.*SECONDARY.*ROLLBACK.*ROLLBACK") {
_coordinator->failSettingFollowerMode(MemberState::RS_SECONDARY, ErrorCodes::IllegalOperation);
auto op = makeOpAndRecordId(1);
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index b9a78ef8ed3..0cf86695206 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -2772,10 +2772,10 @@ TEST_F(RSRollbackTest, RollbackReturnsImmediatelyOnFailureToTransitionToRollback
ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY), _coordinator->getMemberState());
}
-DEATH_TEST_F(
+DEATH_TEST_REGEX_F(
RSRollbackTest,
RollbackUnrecoverableRollbackErrorTriggersFatalAssertion,
- "Unable to complete rollback. A full resync may be needed: "
+ "Unable to complete rollback. A full resync may be needed:.*"
"UnrecoverableRollbackError: need to rollback, but unable to determine common point "
"between local and remote oplog: InvalidSyncSource: remote oplog empty or unreadable") {
// rollback() should abort on getting UnrecoverableRollbackError from syncRollback(). An empty
@@ -2837,11 +2837,11 @@ DEATH_TEST_F(RSRollbackTest,
_opCtx.get(), localOplog, rollbackSource, {}, {}, _coordinator, _replicationProcess.get());
}
-DEATH_TEST_F(
+DEATH_TEST_REGEX_F(
RSRollbackTest,
RollbackTriggersFatalAssertionOnFailingToTransitionToRecoveringAfterSyncRollbackReturns,
- "Failed to transition into RECOVERING; expected to be in state ROLLBACK; found self in "
- "ROLLBACK") {
+ "Failed to transition into.*; expected to be in state.*; found self "
+ "in.*RECOVERING.*ROLLBACK.*ROLLBACK") {
auto commonOperation = makeNoopOplogEntryAndRecordId(Seconds(1));
OplogInterfaceMock localOplog({commonOperation});
RollbackSourceMock rollbackSource(
diff --git a/src/mongo/db/storage/kv/durable_catalog_test.cpp b/src/mongo/db/storage/kv/durable_catalog_test.cpp
index 5e5b3ceb990..38bdc1c9fa9 100644
--- a/src/mongo/db/storage/kv/durable_catalog_test.cpp
+++ b/src/mongo/db/storage/kv/durable_catalog_test.cpp
@@ -267,18 +267,18 @@ TEST_F(DurableCatalogTest, CanSetMultipleFieldsAndComponentsAsMultikey) {
}
}
-DEATH_TEST_F(DurableCatalogTest,
- CannotOmitPathLevelMultikeyInfoWithBtreeIndex,
- "Invariant failure !multikeyPaths.empty()") {
+DEATH_TEST_REGEX_F(DurableCatalogTest,
+ CannotOmitPathLevelMultikeyInfoWithBtreeIndex,
+ R"#(Invariant failure.*!multikeyPaths.empty\(\))#") {
std::string indexName = createIndex(BSON("a" << 1 << "b" << 1));
auto opCtx = newOperationContext();
DurableCatalog* catalog = getCatalog();
catalog->setIndexIsMultikey(opCtx.get(), getCatalogId(), indexName, MultikeyPaths{});
}
-DEATH_TEST_F(DurableCatalogTest,
- AtLeastOnePathComponentMustCauseIndexToBeMultikey,
- "Invariant failure somePathIsMultikey") {
+DEATH_TEST_REGEX_F(DurableCatalogTest,
+ AtLeastOnePathComponentMustCauseIndexToBeMultikey,
+ R"#(Invariant failure.*somePathIsMultikey)#") {
std::string indexName = createIndex(BSON("a" << 1 << "b" << 1));
auto opCtx = newOperationContext();
DurableCatalog* catalog = getCatalog();
@@ -379,9 +379,9 @@ TEST_F(DurableCatalogTest, TwoPhaseIndexBuild) {
ASSERT_FALSE(catalog->getIndexBuildUUID(opCtx.get(), getCatalogId(), indexName));
}
-DEATH_TEST_F(DurableCatalogTest,
- CannotSetIndividualPathComponentsOfTextIndexAsMultikey,
- "Invariant failure multikeyPaths.empty()") {
+DEATH_TEST_REGEX_F(DurableCatalogTest,
+ CannotSetIndividualPathComponentsOfTextIndexAsMultikey,
+ R"#(Invariant failure.*multikeyPaths.empty\(\))#") {
std::string indexType = IndexNames::TEXT;
std::string indexName = createIndex(BSON("a" << indexType << "b" << 1), indexType);
auto opCtx = newOperationContext();
diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
index 0bce1df682d..1d59850375d 100644
--- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
+++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
@@ -636,7 +636,9 @@ TEST_F(DurableCatalogImplTest, BackupImplemented) {
}
}
-DEATH_TEST_F(DurableCatalogImplTest, TerminateOnNonNumericIndexVersion, "Fatal Assertion 50942") {
+DEATH_TEST_REGEX_F(DurableCatalogImplTest,
+ TerminateOnNonNumericIndexVersion,
+ "Fatal Assertion.*50942") {
setGlobalServiceContext(ServiceContext::make());
std::unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create());
KVEngine* engine = helper->getEngine();
diff --git a/src/mongo/db/transaction_participant_retryable_writes_test.cpp b/src/mongo/db/transaction_participant_retryable_writes_test.cpp
index 36b0a98ab83..48e85c04971 100644
--- a/src/mongo/db/transaction_participant_retryable_writes_test.cpp
+++ b/src/mongo/db/transaction_participant_retryable_writes_test.cpp
@@ -474,17 +474,18 @@ TEST_F(TransactionParticipantRetryableWritesTest, CheckStatementExecuted) {
ASSERT(txnParticipant.checkStatementExecutedNoOplogEntryFetch(2000));
}
-DEATH_TEST_F(TransactionParticipantRetryableWritesTest,
- CheckStatementExecutedForInvalidatedTransactionInvariants,
- "Invariant failure p().isValid") {
+DEATH_TEST_REGEX_F(TransactionParticipantRetryableWritesTest,
+ CheckStatementExecutedForInvalidatedTransactionInvariants,
+ R"#(Invariant failure.*p\(\).isValid)#") {
auto txnParticipant = TransactionParticipant::get(opCtx());
txnParticipant.invalidate(opCtx());
txnParticipant.checkStatementExecuted(opCtx(), 0);
}
-DEATH_TEST_F(TransactionParticipantRetryableWritesTest,
- WriteOpCompletedOnPrimaryForOldTransactionInvariants,
- "Invariant failure sessionTxnRecord.getTxnNum() == o().activeTxnNumber") {
+DEATH_TEST_REGEX_F(
+ TransactionParticipantRetryableWritesTest,
+ WriteOpCompletedOnPrimaryForOldTransactionInvariants,
+ R"#(Invariant failure.*sessionTxnRecord.getTxnNum\(\) == o\(\).activeTxnNumber)#") {
auto txnParticipant = TransactionParticipant::get(opCtx());
txnParticipant.refreshFromStorageIfNeeded(opCtx());
@@ -522,9 +523,10 @@ DEATH_TEST_F(TransactionParticipantRetryableWritesTest,
}
}
-DEATH_TEST_F(TransactionParticipantRetryableWritesTest,
- WriteOpCompletedOnPrimaryForInvalidatedTransactionInvariants,
- "Invariant failure sessionTxnRecord.getTxnNum() == o().activeTxnNumber") {
+DEATH_TEST_REGEX_F(
+ TransactionParticipantRetryableWritesTest,
+ WriteOpCompletedOnPrimaryForInvalidatedTransactionInvariants,
+ R"#(Invariant failure.*sessionTxnRecord.getTxnNum\(\) == o\(\).activeTxnNumber)#") {
auto txnParticipant = TransactionParticipant::get(opCtx());
txnParticipant.refreshFromStorageIfNeeded(opCtx());
diff --git a/src/mongo/db/update/addtoset_node_test.cpp b/src/mongo/db/update/addtoset_node_test.cpp
index 0aaf434fcdb..426d84aa0ba 100644
--- a/src/mongo/db/update/addtoset_node_test.cpp
+++ b/src/mongo/db/update/addtoset_node_test.cpp
@@ -47,7 +47,9 @@ using AddToSetNodeTest = UpdateNodeTest;
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
-DEATH_TEST(AddToSetNodeTest, InitFailsForEmptyElement, "Invariant failure modExpr.ok()") {
+DEATH_TEST_REGEX(AddToSetNodeTest,
+ InitFailsForEmptyElement,
+ R"#(Invariant failure.*modExpr.ok())#") {
auto update = fromjson("{$addToSet: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
AddToSetNode node;
@@ -379,7 +381,9 @@ TEST_F(AddToSetNodeTest, ApplyRespectsCollationFromSetCollator) {
ASSERT_EQUALS(getModifiedPaths(), "{a}");
}
-DEATH_TEST(AddToSetNodeTest, CannotSetCollatorIfCollatorIsNonNull, "Invariant failure !_collator") {
+DEATH_TEST_REGEX(AddToSetNodeTest,
+ CannotSetCollatorIfCollatorIsNonNull,
+ "Invariant failure.*!_collator") {
auto update = fromjson("{$addToSet: {a: 1}}");
CollatorInterfaceMock caseInsensitiveCollator(CollatorInterfaceMock::MockType::kToLowerString);
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
@@ -389,7 +393,7 @@ DEATH_TEST(AddToSetNodeTest, CannotSetCollatorIfCollatorIsNonNull, "Invariant fa
node.setCollator(&caseInsensitiveCollator);
}
-DEATH_TEST(AddToSetNodeTest, CannotSetCollatorTwice, "Invariant failure !_collator") {
+DEATH_TEST_REGEX(AddToSetNodeTest, CannotSetCollatorTwice, "Invariant failure.*!_collator") {
auto update = fromjson("{$addToSet: {a: 1}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
AddToSetNode node;
diff --git a/src/mongo/db/update/arithmetic_node_test.cpp b/src/mongo/db/update/arithmetic_node_test.cpp
index 2783a32d547..85ce7e8b83c 100644
--- a/src/mongo/db/update/arithmetic_node_test.cpp
+++ b/src/mongo/db/update/arithmetic_node_test.cpp
@@ -46,7 +46,9 @@ using ArithmeticNodeTest = UpdateNodeTest;
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
-DEATH_TEST(ArithmeticNodeTest, InitFailsForEmptyElement, "Invariant failure modExpr.ok()") {
+DEATH_TEST_REGEX(ArithmeticNodeTest,
+ InitFailsForEmptyElement,
+ R"#(Invariant failure.*modExpr.ok\(\))#") {
auto update = fromjson("{$inc: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
diff --git a/src/mongo/db/update/compare_node_test.cpp b/src/mongo/db/update/compare_node_test.cpp
index 05c5d9ee68a..698842855f0 100644
--- a/src/mongo/db/update/compare_node_test.cpp
+++ b/src/mongo/db/update/compare_node_test.cpp
@@ -47,7 +47,9 @@ using CompareNodeTest = UpdateNodeTest;
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
-DEATH_TEST(CompareNodeTest, InitFailsForEmptyElement, "Invariant failure modExpr.ok()") {
+DEATH_TEST_REGEX(CompareNodeTest,
+ InitFailsForEmptyElement,
+ R"#(Invariant failure.*modExpr.ok\(\))#") {
auto update = fromjson("{$max: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
CompareNode node(CompareNode::CompareMode::kMax);
@@ -353,7 +355,9 @@ TEST_F(CompareNodeTest, ApplyMaxRespectsCollationFromSetCollator) {
ASSERT_EQUALS(fromjson("{$set: {a: 'abd'}}"), getLogDoc());
}
-DEATH_TEST(CompareNodeTest, CannotSetCollatorIfCollatorIsNonNull, "Invariant failure !_collator") {
+DEATH_TEST_REGEX(CompareNodeTest,
+ CannotSetCollatorIfCollatorIsNonNull,
+ "Invariant failure.*!_collator") {
auto update = fromjson("{$max: {a: 1}}");
CollatorInterfaceMock caseInsensitiveCollator(CollatorInterfaceMock::MockType::kToLowerString);
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
@@ -363,7 +367,7 @@ DEATH_TEST(CompareNodeTest, CannotSetCollatorIfCollatorIsNonNull, "Invariant fai
node.setCollator(&caseInsensitiveCollator);
}
-DEATH_TEST(CompareNodeTest, CannotSetCollatorTwice, "Invariant failure !_collator") {
+DEATH_TEST_REGEX(CompareNodeTest, CannotSetCollatorTwice, "Invariant failure.*!_collator") {
auto update = fromjson("{$max: {a: 1}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
CompareNode node(CompareNode::CompareMode::kMax);
diff --git a/src/mongo/db/update/current_date_node_test.cpp b/src/mongo/db/update/current_date_node_test.cpp
index e16a2cdbe46..71622333925 100644
--- a/src/mongo/db/update/current_date_node_test.cpp
+++ b/src/mongo/db/update/current_date_node_test.cpp
@@ -46,7 +46,9 @@ using CurrentDateNodeTest = UpdateNodeTest;
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
-DEATH_TEST(CurrentDateNodeTest, InitFailsForEmptyElement, "Invariant failure modExpr.ok()") {
+DEATH_TEST_REGEX(CurrentDateNodeTest,
+ InitFailsForEmptyElement,
+ R"#(Invariant failure.*modExpr.ok\(\))#") {
auto update = fromjson("{$currentDate: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
CurrentDateNode node;
diff --git a/src/mongo/db/update/pop_node_test.cpp b/src/mongo/db/update/pop_node_test.cpp
index 1a735a3d0f5..d27931dde80 100644
--- a/src/mongo/db/update/pop_node_test.cpp
+++ b/src/mongo/db/update/pop_node_test.cpp
@@ -172,9 +172,9 @@ TEST_F(PopNodeTest, ThrowsWhenPathIsBlockedByAScalar) {
"Cannot use the part (b) of (a.b) to traverse the element ({a: \"foo\"})");
}
-DEATH_TEST_F(PopNodeTest,
- NonOkElementWhenPathExistsIsFatal,
- "Invariant failure applyParams.element.ok()") {
+DEATH_TEST_REGEX_F(PopNodeTest,
+ NonOkElementWhenPathExistsIsFatal,
+ R"#(Invariant failure.*applyParams.element.ok\(\))#") {
auto update = fromjson("{$pop: {'a.b': 1}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
PopNode popNode;
diff --git a/src/mongo/db/update/set_node_test.cpp b/src/mongo/db/update/set_node_test.cpp
index 8f160c4fe13..8cd2b60243e 100644
--- a/src/mongo/db/update/set_node_test.cpp
+++ b/src/mongo/db/update/set_node_test.cpp
@@ -46,7 +46,7 @@ using SetNodeTest = UpdateNodeTest;
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
-DEATH_TEST(SetNodeTest, InitFailsForEmptyElement, "Invariant failure modExpr.ok()") {
+DEATH_TEST_REGEX(SetNodeTest, InitFailsForEmptyElement, R"#(Invariant failure.*modExpr.ok\(\))#") {
auto update = fromjson("{$set: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
SetNode node;
diff --git a/src/mongo/db/update/unset_node_test.cpp b/src/mongo/db/update/unset_node_test.cpp
index 09788ef573b..fc2c04e9932 100644
--- a/src/mongo/db/update/unset_node_test.cpp
+++ b/src/mongo/db/update/unset_node_test.cpp
@@ -46,16 +46,18 @@ using UnsetNodeTest = UpdateNodeTest;
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
-DEATH_TEST(UnsetNodeTest, InitFailsForEmptyElement, "Invariant failure modExpr.ok()") {
+DEATH_TEST_REGEX(UnsetNodeTest,
+ InitFailsForEmptyElement,
+ R"#(Invariant failure.*modExpr.ok\(\))#") {
auto update = fromjson("{$unset: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
UnsetNode node;
node.init(update["$unset"].embeddedObject().firstElement(), expCtx).transitional_ignore();
}
-DEATH_TEST_F(UnsetNodeTest,
- ApplyToRootFails,
- "Invariant failure !updateNodeApplyParams.pathTaken->empty()") {
+DEATH_TEST_REGEX_F(UnsetNodeTest,
+ ApplyToRootFails,
+ R"#(Invariant failure.*!updateNodeApplyParams.pathTaken->empty\(\))#") {
auto update = fromjson("{$unset: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
UnsetNode node;
diff --git a/src/mongo/db/update/update_array_node_test.cpp b/src/mongo/db/update/update_array_node_test.cpp
index ed45c83be63..d35a3a44633 100644
--- a/src/mongo/db/update/update_array_node_test.cpp
+++ b/src/mongo/db/update/update_array_node_test.cpp
@@ -124,9 +124,9 @@ TEST_F(UpdateArrayNodeTest, UpdateIsAppliedToAllMatchingElements) {
ASSERT_EQUALS("{a.0, a.2}", getModifiedPaths());
}
-DEATH_TEST_F(UpdateArrayNodeTest,
- ArrayElementsMustNotBeDeserialized,
- "Invariant failure childElement.hasValue()") {
+DEATH_TEST_REGEX_F(UpdateArrayNodeTest,
+ ArrayElementsMustNotBeDeserialized,
+ R"#(Invariant failure.*childElement.hasValue\(\))#") {
auto update = fromjson("{$set: {'a.$[i].b': 0}}");
auto arrayFilter = fromjson("{'i.c': 0}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
diff --git a/src/mongo/db/update/update_object_node_test.cpp b/src/mongo/db/update/update_object_node_test.cpp
index 0d1a37489db..1025f93fb0e 100644
--- a/src/mongo/db/update/update_object_node_test.cpp
+++ b/src/mongo/db/update/update_object_node_test.cpp
@@ -1535,9 +1535,9 @@ TEST(UpdateObjectNodeTest, MergeWithConflictingPositionalFails) {
"Update created a conflict at 'root.a.$'");
}
-DEATH_TEST(UpdateObjectNodeTest,
- MergingArrayNodesWithDifferentArrayFiltersFails,
- "Invariant failure &leftNode._arrayFilters == &rightNode._arrayFilters") {
+DEATH_TEST_REGEX(UpdateObjectNodeTest,
+ MergingArrayNodesWithDifferentArrayFiltersFails,
+ "Invariant failure.*leftNode._arrayFilters == &rightNode._arrayFilters") {
auto setUpdate1 = fromjson("{$set: {'a.$[i]': 5}}");
auto setUpdate2 = fromjson("{$set: {'a.$[j]': 6}}");
FieldRef fakeFieldRef("root");
diff --git a/src/mongo/db/views/view_definition_test.cpp b/src/mongo/db/views/view_definition_test.cpp
index 67bb1dec78b..6b2aa57cba9 100644
--- a/src/mongo/db/views/view_definition_test.cpp
+++ b/src/mongo/db/views/view_definition_test.cpp
@@ -89,9 +89,9 @@ TEST(ViewDefinitionTest, CopyAssignmentOperatorProperlyClonesAllFields) {
copiedView.defaultCollator()));
}
-DEATH_TEST(ViewDefinitionTest,
- SetViewOnFailsIfNewViewOnNotInSameDatabaseAsView,
- "Invariant failure _viewNss.db() == viewOnNss.db()") {
+DEATH_TEST_REGEX(ViewDefinitionTest,
+ SetViewOnFailsIfNewViewOnNotInSameDatabaseAsView,
+ R"#(Invariant failure.*_viewNss.db\(\) == viewOnNss.db\(\))#") {
ViewDefinition viewDef(
viewNss.db(), viewNss.coll(), backingNss.coll(), samplePipeline, nullptr);
NamespaceString badViewOn("someOtherDb.someOtherCollection");
@@ -108,9 +108,9 @@ TEST(ViewDefinitionTest, SetViewOnSucceedsIfNewViewOnIsInSameDatabaseAsView) {
ASSERT_EQ(newViewOn, viewDef.viewOn());
}
-DEATH_TEST(ViewDefinitionTest,
- SetPiplineFailsIfPipelineTypeIsNotArray,
- "Invariant failure pipeline.type() == Array") {
+DEATH_TEST_REGEX(ViewDefinitionTest,
+ SetPiplineFailsIfPipelineTypeIsNotArray,
+ R"#(Invariant failure.*pipeline.type\(\) == Array)#") {
ViewDefinition viewDef(
viewNss.db(), viewNss.coll(), backingNss.coll(), samplePipeline, nullptr);
diff --git a/src/mongo/s/query/async_results_merger_test.cpp b/src/mongo/s/query/async_results_merger_test.cpp
index bbaa35734f6..653a8c103c3 100644
--- a/src/mongo/s/query/async_results_merger_test.cpp
+++ b/src/mongo/s/query/async_results_merger_test.cpp
@@ -1333,10 +1333,10 @@ TEST_F(AsyncResultsMergerTest, GetMoreRequestIncludesMaxTimeMS) {
scheduleNetworkResponses(std::move(responses));
}
-DEATH_TEST_F(AsyncResultsMergerTest,
- SortedTailableInvariantsIfInitialBatchHasNoPostBatchResumeToken,
- "Invariant failure _promisedMinSortKeys.empty() || _promisedMinSortKeys.size() == "
- "_remotes.size()") {
+DEATH_TEST_REGEX_F(
+ AsyncResultsMergerTest,
+ SortedTailableInvariantsIfInitialBatchHasNoPostBatchResumeToken,
+ R"#(Invariant failure.*_promisedMinSortKeys.empty\(\) || _promisedMinSortKeys.size\(\) == _remotes.size\(\))#") {
AsyncResultsMergerParams params;
params.setNss(kTestNss);
UUID uuid = UUID::gen();
@@ -1368,9 +1368,9 @@ DEATH_TEST_F(AsyncResultsMergerTest,
MONGO_UNREACHABLE;
}
-DEATH_TEST_F(AsyncResultsMergerTest,
- SortedTailableCursorInvariantsIfOneOrMoreRemotesHasEmptyPostBatchResumeToken,
- "Invariant failure !response.getPostBatchResumeToken()->isEmpty()") {
+DEATH_TEST_REGEX_F(AsyncResultsMergerTest,
+ SortedTailableCursorInvariantsIfOneOrMoreRemotesHasEmptyPostBatchResumeToken,
+ R"#(Invariant failure.*!response.getPostBatchResumeToken\(\)->isEmpty\(\))#") {
AsyncResultsMergerParams params;
params.setNss(kTestNss);
UUID uuid = UUID::gen();
@@ -1830,9 +1830,9 @@ TEST_F(AsyncResultsMergerTest, GetMoresShouldIncludeLSIDAndTxnNumIfSpecified) {
});
}
-DEATH_TEST_F(AsyncResultsMergerTest,
- ConstructingARMWithTxnNumAndNoLSIDShouldCrash,
- "Invariant failure params.getSessionId()") {
+DEATH_TEST_REGEX_F(AsyncResultsMergerTest,
+ ConstructingARMWithTxnNumAndNoLSIDShouldCrash,
+ R"#(Invariant failure.*params.getSessionId\(\))#") {
AsyncResultsMergerParams params;
OperationSessionInfoFromClient sessionInfo;
diff --git a/src/mongo/s/shard_key_pattern_test.cpp b/src/mongo/s/shard_key_pattern_test.cpp
index a022324e329..660523a2324 100644
--- a/src/mongo/s/shard_key_pattern_test.cpp
+++ b/src/mongo/s/shard_key_pattern_test.cpp
@@ -640,9 +640,9 @@ TEST(ShardKeyPattern, ExtractShardKeyFromIndexKeyData_HashedIndexAndShardKey) {
<< "c.d" << 123 << "p.q" << BSONNULL));
}
-DEATH_TEST(ShardKeyPattern,
- ExtractShardKeyFromIndexKeyData_WithMissingFieldsInIndex,
- "Invariant failure matchEl") {
+DEATH_TEST_REGEX(ShardKeyPattern,
+ ExtractShardKeyFromIndexKeyData_WithMissingFieldsInIndex,
+ "Invariant failure.*matchEl") {
ShardKeyPattern pattern(BSON("a.b" << 1 << "c.d"
<< "hashed"
<< "p.q.0" << 1));
@@ -713,9 +713,9 @@ TEST(ShardKeyPattern, ExtractShardKeyFromIndexKeyData_NonHashedIndexAndHashedSha
<< "e.null" << BSONNULL));
}
-DEATH_TEST(ShardKeyPattern,
- ExtractShardKeyFromIndexKeyData_HashedIndexAndNonHashedShardKey,
- "Invariant failure isHashedPatternEl") {
+DEATH_TEST_REGEX(ShardKeyPattern,
+ ExtractShardKeyFromIndexKeyData_HashedIndexAndNonHashedShardKey,
+ "Invariant failure.*isHashedPatternEl") {
ShardKeyPattern pattern(BSON("a.b" << 1 << "c.d" << 1.0));
auto indexPattern = BSON("c.d"
<< "hashed"
diff --git a/src/mongo/s/transaction_router_test.cpp b/src/mongo/s/transaction_router_test.cpp
index 30564c94f6d..2c97927e81b 100644
--- a/src/mongo/s/transaction_router_test.cpp
+++ b/src/mongo/s/transaction_router_test.cpp
@@ -4269,21 +4269,21 @@ TEST_F(TransactionRouterTest, RouterMetricsCurrent_ReapForUnstartedTxn) {
// The following three tests verify that the methods that end metrics tracking for a transaction
// can't be called for an unstarted one.
-DEATH_TEST_F(TransactionRouterMetricsTest,
- ImplicitlyAbortingUnstartedTxnCrashes,
- "Invariant failure isInitialized()") {
+DEATH_TEST_REGEX_F(TransactionRouterMetricsTest,
+ ImplicitlyAbortingUnstartedTxnCrashes,
+ R"#(Invariant failure.*isInitialized\(\))#") {
txnRouter().implicitlyAbortTransaction(operationContext(), kDummyStatus);
}
-DEATH_TEST_F(TransactionRouterMetricsTest,
- AbortingUnstartedTxnCrashes,
- "Invariant failure isInitialized()") {
+DEATH_TEST_REGEX_F(TransactionRouterMetricsTest,
+ AbortingUnstartedTxnCrashes,
+ R"#(Invariant failure.*isInitialized\(\))#") {
txnRouter().abortTransaction(operationContext());
}
-DEATH_TEST_F(TransactionRouterMetricsTest,
- CommittingUnstartedTxnCrashes,
- "Invariant failure isInitialized()") {
+DEATH_TEST_REGEX_F(TransactionRouterMetricsTest,
+ CommittingUnstartedTxnCrashes,
+ R"#(Invariant failure.*isInitialized\(\))#") {
txnRouter().commitTransaction(operationContext(), boost::none);
}
diff --git a/src/mongo/unittest/death_test.cpp b/src/mongo/unittest/death_test.cpp
index b584ec78591..c15055e1cf5 100644
--- a/src/mongo/unittest/death_test.cpp
+++ b/src/mongo/unittest/death_test.cpp
@@ -102,9 +102,12 @@ void DeathTestBase::_doTest() {
}
}
if (WIFSIGNALED(stat) || (WIFEXITED(stat) && WEXITSTATUS(stat) != 0)) {
- // Exited with a signal or non-zero code. Should check the pattern, here,
- // but haven't figured out how, so just return.
- ASSERT_STRING_CONTAINS(os.str(), _doGetPattern());
+ // Exited with a signal or non-zero code. Validate the expected message.
+ if (_isRegex()) {
+ ASSERT_STRING_SEARCH_REGEX(os.str(), _doGetPattern());
+ } else {
+ ASSERT_STRING_CONTAINS(os.str(), _doGetPattern());
+ }
return;
} else {
invariant(!WIFSTOPPED(stat));
diff --git a/src/mongo/unittest/death_test.h b/src/mongo/unittest/death_test.h
index 35ca96142af..599f3da2faa 100644
--- a/src/mongo/unittest/death_test.h
+++ b/src/mongo/unittest/death_test.h
@@ -49,6 +49,13 @@
DEATH_TEST_DEFINE_(SUITE_NAME, TEST_NAME, MATCH_EXPR, ::mongo::unittest::Test)
/**
+ * See DEATH_TEST for details.
+ * Validates output is a partial match using a PCRE regular expression instead of a string match.
+ */
+#define DEATH_TEST_REGEX(SUITE_NAME, TEST_NAME, REGEX_EXPR) \
+ DEATH_TEST_DEFINE_REGEX_(SUITE_NAME, TEST_NAME, REGEX_EXPR, ::mongo::unittest::Test)
+
+/**
* Constructs a single test named TEST_NAME that has access to a common fixture
* named `FIXTURE_NAME`, which will be used as the Suite name.
*
@@ -57,20 +64,38 @@
#define DEATH_TEST_F(FIXTURE_NAME, TEST_NAME, MATCH_EXPR) \
DEATH_TEST_DEFINE_(FIXTURE_NAME, TEST_NAME, MATCH_EXPR, FIXTURE_NAME)
+#define DEATH_TEST_REGEX_F(FIXTURE_NAME, TEST_NAME, REGEX_EXPR) \
+ DEATH_TEST_DEFINE_REGEX_(FIXTURE_NAME, TEST_NAME, REGEX_EXPR, FIXTURE_NAME)
+
#define DEATH_TEST_DEFINE_(SUITE_NAME, TEST_NAME, MATCH_EXPR, TEST_BASE) \
DEATH_TEST_DEFINE_PRIMITIVE_(SUITE_NAME, \
TEST_NAME, \
MATCH_EXPR, \
+ false, \
UNIT_TEST_DETAIL_TEST_TYPE_NAME(SUITE_NAME, TEST_NAME), \
TEST_BASE)
-#define DEATH_TEST_DEFINE_PRIMITIVE_(SUITE_NAME, TEST_NAME, MATCH_EXPR, TEST_TYPE, TEST_BASE) \
+#define DEATH_TEST_DEFINE_REGEX_(SUITE_NAME, TEST_NAME, REGEX_EXPR, TEST_BASE) \
+ DEATH_TEST_DEFINE_PRIMITIVE_(SUITE_NAME, \
+ TEST_NAME, \
+ REGEX_EXPR, \
+ true, \
+ UNIT_TEST_DETAIL_TEST_TYPE_NAME(SUITE_NAME, TEST_NAME), \
+ TEST_BASE)
+
+
+#define DEATH_TEST_DEFINE_PRIMITIVE_( \
+ SUITE_NAME, TEST_NAME, MATCH_EXPR, IS_REGEX, TEST_TYPE, TEST_BASE) \
class TEST_TYPE : public TEST_BASE { \
public: \
static std::string getPattern() { \
return MATCH_EXPR; \
} \
\
+ static bool isRegex() { \
+ return IS_REGEX; \
+ } \
+ \
private: \
void _doTest() override; \
static inline const RegistrationAgent<::mongo::unittest::DeathTest<TEST_TYPE>> _agent{ \
@@ -78,6 +103,7 @@
}; \
void TEST_TYPE::_doTest()
+
namespace mongo::unittest {
class DeathTestBase : public Test {
@@ -91,6 +117,7 @@ private:
// Customization points for derived DeathTest classes.
virtual std::unique_ptr<Test> _doMakeTest() = 0;
virtual std::string _doGetPattern() = 0;
+ virtual bool _isRegex() = 0;
};
template <typename T>
@@ -105,6 +132,10 @@ private:
return T::getPattern();
}
+ bool _isRegex() override {
+ return T::isRegex();
+ }
+
std::unique_ptr<Test> _doMakeTest() override {
return _makeTest();
}
diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h
index f3582d319a0..9e2c2fd0518 100644
--- a/src/mongo/unittest/unittest.h
+++ b/src/mongo/unittest/unittest.h
@@ -39,6 +39,7 @@
#include <cmath>
#include <fmt/format.h>
#include <functional>
+#include <pcrecpp.h>
#include <sstream>
#include <string>
#include <tuple>
@@ -277,6 +278,20 @@
haystack); \
}()))
+#define ASSERT_STRING_SEARCH_REGEX(BIG_STRING, REGEX) \
+ if (auto tup_ = std::tuple(std::string(BIG_STRING), std::string(REGEX)); \
+ pcrecpp::RE(std::get<1>(tup_)).PartialMatch(std::get<0>(tup_))) { \
+ } else \
+ FAIL(([&] { \
+ const auto& [haystack, sub] = tup_; \
+ return format(FMT_STRING("Expected to find regular expression {} /{}/ in {} ({})"), \
+ #REGEX, \
+ sub, \
+ #BIG_STRING, \
+ haystack); \
+ }()))
+
+
/**
* Construct a single test, named `TEST_NAME` within the test Suite `SUITE_NAME`.
*
diff --git a/src/mongo/unittest/unittest_main.cpp b/src/mongo/unittest/unittest_main.cpp
index 71503cf9c2d..f7bcd647c1a 100644
--- a/src/mongo/unittest/unittest_main.cpp
+++ b/src/mongo/unittest/unittest_main.cpp
@@ -54,19 +54,9 @@ int main(int argc, char** argv, char** envp) {
::mongo::runGlobalInitializersOrDie(argc, argv, envp);
- auto& logManager = ::mongo::logv2::LogManager::global();
- ::mongo::logv2::LogDomainGlobal::ConfigurationOptions logConfig;
- logConfig.format = ::mongo::logv2::LogFormat::kText;
-
- Status status = logManager.getGlobalDomainInternal().configure(logConfig);
- if (!status.isOK()) {
- std::cerr << status;
- return EXIT_FAILURE;
- }
-
moe::OptionSection options;
- status = mongo::unittest::addUnitTestOptions(&options);
+ Status status = mongo::unittest::addUnitTestOptions(&options);
if (!status.isOK()) {
std::cerr << status;
return EXIT_FAILURE;
diff --git a/src/mongo/unittest/unittest_test.cpp b/src/mongo/unittest/unittest_test.cpp
index 7a1c7b62338..1689e5e3ebb 100644
--- a/src/mongo/unittest/unittest_test.cpp
+++ b/src/mongo/unittest/unittest_test.cpp
@@ -262,7 +262,7 @@ TEST(UnitTestSelfTest, BSONElementGTE) {
ASSERT_BSONELT_GTE(obj2.firstElement(), obj1.firstElement());
}
-DEATH_TEST(DeathTestSelfTest, TestDeath, "Invariant failure false") {
+DEATH_TEST_REGEX(DeathTestSelfTest, TestDeath, "Invariant failure.*false") {
invariant(false);
}
diff --git a/src/mongo/util/assert_util_test.cpp b/src/mongo/util/assert_util_test.cpp
index b0513c92d02..4707aca15b3 100644
--- a/src/mongo/util/assert_util_test.cpp
+++ b/src/mongo/util/assert_util_test.cpp
@@ -319,7 +319,7 @@ DEATH_TEST(MassertionTerminationTest, msgasserted, "Terminating with msgasserted
}
// invariant and its friends
-DEATH_TEST(InvariantTerminationTest, invariant, "Invariant failure false " __FILE__) {
+DEATH_TEST_REGEX(InvariantTerminationTest, invariant, "Invariant failure.*false.*" __FILE__) {
invariant(false);
}
@@ -408,7 +408,7 @@ DEATH_TEST(InvariantTerminationTest,
#if defined(MONGO_CONFIG_DEBUG_BUILD)
// dassert and its friends
-DEATH_TEST(DassertTerminationTest, invariant, "Invariant failure false " __FILE__) {
+DEATH_TEST_REGEX(DassertTerminationTest, invariant, "Invariant failure.*false.*" __FILE__) {
dassert(false);
}
diff --git a/src/mongo/util/concurrency/thread_pool_test.cpp b/src/mongo/util/concurrency/thread_pool_test.cpp
index 9546a3366d6..7a9f7f9eef9 100644
--- a/src/mongo/util/concurrency/thread_pool_test.cpp
+++ b/src/mongo/util/concurrency/thread_pool_test.cpp
@@ -186,15 +186,16 @@ TEST_F(ThreadPoolTest, MaxPoolSize20MinPoolSize15) {
<< "Failed to reap excess threads after " << durationCount<Milliseconds>(reapTime) << "ms";
}
-DEATH_TEST(ThreadPoolTest, MaxThreadsTooFewDies, "but the maximum must be at least 1") {
+DEATH_TEST_REGEX(ThreadPoolTest, MaxThreadsTooFewDies, "but the maximum must be at least 1") {
ThreadPool::Options options;
options.maxThreads = 0;
ThreadPool pool(options);
}
-DEATH_TEST(ThreadPoolTest,
- MinThreadsTooManyDies,
- "6 which is more than the configured maximum of 5") {
+DEATH_TEST_REGEX(
+ ThreadPoolTest,
+ MinThreadsTooManyDies,
+ R"#(.*which is more than the configured maximum of.*minThreads":6,"options_maxThreads":5)#") {
ThreadPool::Options options;
options.maxThreads = 5;
options.minThreads = 6;
@@ -210,9 +211,9 @@ TEST(ThreadPoolTest, LivePoolCleanedByDestructor) {
// Destructor should reap leftover threads.
}
-DEATH_TEST(ThreadPoolTest,
- DestructionDuringJoinDies,
- "Attempted to join pool DoubleJoinPool more than once") {
+DEATH_TEST_REGEX(ThreadPoolTest,
+ DestructionDuringJoinDies,
+ "Attempted to join pool .* more than once.*DoubleJoinPool") {
// This test is a little complicated. We need to ensure that the ThreadPool destructor runs
// while some thread is blocked running ThreadPool::join, to see that double-join is fatal in
// the pool destructor. To do this, we first wait for minThreads threads to have started. Then,
diff --git a/src/mongo/util/concurrency/thread_pool_test_common.cpp b/src/mongo/util/concurrency/thread_pool_test_common.cpp
index 7c440579160..dcbc875e5cb 100644
--- a/src/mongo/util/concurrency/thread_pool_test_common.cpp
+++ b/src/mongo/util/concurrency/thread_pool_test_common.cpp
@@ -130,6 +130,9 @@ public:
static std::string getPattern() { \
return MATCH_EXPR; \
} \
+ static bool isRegex() { \
+ return false; \
+ } \
\
private: \
void _doTest() override; \
diff --git a/src/mongo/util/latch_analyzer_test.cpp b/src/mongo/util/latch_analyzer_test.cpp
index 993cf14fbe8..9b4844d1311 100644
--- a/src/mongo/util/latch_analyzer_test.cpp
+++ b/src/mongo/util/latch_analyzer_test.cpp
@@ -53,7 +53,7 @@ class LatchAnalyzerTest : public ServiceContextTest {
}
};
-DEATH_TEST_F(LatchAnalyzerTest, AddInvalidWasAbsent, "Fatal assertion 31360") {
+DEATH_TEST_REGEX_F(LatchAnalyzerTest, AddInvalidWasAbsent, "Fatal assertion.*31360") {
Mutex lowerLevel = MONGO_MAKE_LATCH(Level(1), "AddInvalidWasAbsent::lowerLevel");
Mutex higherLevel = MONGO_MAKE_LATCH(Level(2), "AddInvalidWasAbsent::higherLevel");
@@ -62,7 +62,7 @@ DEATH_TEST_F(LatchAnalyzerTest, AddInvalidWasAbsent, "Fatal assertion 31360") {
higherLevel.lock();
}
-DEATH_TEST_F(LatchAnalyzerTest, AddInvalidWasPresent, "Fatal assertion 31360") {
+DEATH_TEST_REGEX_F(LatchAnalyzerTest, AddInvalidWasPresent, "Fatal assertion.*31360") {
Mutex m1 = MONGO_MAKE_LATCH(Level(1), "AddInvalidWasPresent::m1");
Mutex m2 = MONGO_MAKE_LATCH(Level(1), "AddInvalidWasPresent::m2");
@@ -70,13 +70,13 @@ DEATH_TEST_F(LatchAnalyzerTest, AddInvalidWasPresent, "Fatal assertion 31360") {
m2.lock();
}
-DEATH_TEST_F(LatchAnalyzerTest, RemoveInvalidWasAbsent, "Fatal assertion 31361") {
+DEATH_TEST_REGEX_F(LatchAnalyzerTest, RemoveInvalidWasAbsent, "Fatal assertion.*31361") {
Mutex m = MONGO_MAKE_LATCH(Level(1), "RemoveInvalidWasAbsent::m");
m.unlock();
}
-DEATH_TEST_F(LatchAnalyzerTest, RemoveInvalidWasPresent, "Fatal assertion 31361") {
+DEATH_TEST_REGEX_F(LatchAnalyzerTest, RemoveInvalidWasPresent, "Fatal assertion.*31361") {
Mutex higherLevel = MONGO_MAKE_LATCH(Level(2), "RemoveInvalidWasPresent::higherLevel");
Mutex lowerLevel = MONGO_MAKE_LATCH(Level(1), "RemoveInvalidWasPresent::lowerLevel");
diff --git a/src/mongo/util/signal_handlers_synchronous_test.cpp b/src/mongo/util/signal_handlers_synchronous_test.cpp
index 7630a8ed2d7..b1d737584d9 100644
--- a/src/mongo/util/signal_handlers_synchronous_test.cpp
+++ b/src/mongo/util/signal_handlers_synchronous_test.cpp
@@ -81,7 +81,7 @@ DEATH_TEST(FatalTerminateTest,
DEATH_TEST(FatalTerminateTest,
TerminateIsFatalWithDBException,
- " terminate() called. An exception is active") {
+ "terminate() called. An exception is active") {
try {
uasserted(28720, "Fatal DBException occurrence");
} catch (...) {