diff options
Diffstat (limited to 'src/mongo/db/ftdc/ftdc_test.cpp')
| -rw-r--r-- | src/mongo/db/ftdc/ftdc_test.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/mongo/db/ftdc/ftdc_test.cpp b/src/mongo/db/ftdc/ftdc_test.cpp index 7e4020b3979..49be73bb8cc 100644 --- a/src/mongo/db/ftdc/ftdc_test.cpp +++ b/src/mongo/db/ftdc/ftdc_test.cpp @@ -48,7 +48,23 @@ namespace mongo { -void ValidateDocumentList(const boost::filesystem::path& p, const std::vector<BSONObj>& docs) { +namespace { + +BSONObj filteredFTDCCopy(const BSONObj& obj) { + BSONObjBuilder builder; + for (const auto& f : obj) { + if (FTDCBSONUtil::isFTDCType(f.type())) { + builder.append(f); + } + } + return builder.obj(); +} +} // namespace + + +void ValidateDocumentList(const boost::filesystem::path& p, + const std::vector<BSONObj>& docs, + FTDCValidationMode mode) { FTDCFileReader reader; ASSERT_OK(reader.open(p)); @@ -62,20 +78,32 @@ void ValidateDocumentList(const boost::filesystem::path& p, const std::vector<BS ASSERT_OK(sw); - ValidateDocumentList(list, docs); + ValidateDocumentList(list, docs, mode); } -void ValidateDocumentList(const std::vector<BSONObj>& docs1, const std::vector<BSONObj>& docs2) { +void ValidateDocumentList(const std::vector<BSONObj>& docs1, + const std::vector<BSONObj>& docs2, + FTDCValidationMode mode) { ASSERT_EQUALS(docs1.size(), docs2.size()); auto ai = docs1.begin(); auto bi = docs2.begin(); while (ai != docs1.end() && bi != docs2.end()) { - if (SimpleBSONObjComparator::kInstance.evaluate(*ai != *bi)) { - std::cout << *ai << " vs " << *bi << std::endl; - ASSERT_BSONOBJ_EQ(*ai, *bi); + if (mode == FTDCValidationMode::kStrict) { + if (SimpleBSONObjComparator::kInstance.evaluate(*ai != *bi)) { + std::cout << *ai << " vs " << *bi << std::endl; + ASSERT_BSONOBJ_EQ(*ai, *bi); + } + } else { + BSONObj left = filteredFTDCCopy(*ai); + BSONObj right = filteredFTDCCopy(*bi); + if (SimpleBSONObjComparator::kInstance.evaluate(left != right)) { + std::cout << left << " vs " << right << std::endl; + ASSERT_BSONOBJ_EQ(left, right); + } } + ++ai; ++bi; } |
