summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/plan_cache_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/plan_cache_test.cpp')
-rw-r--r--src/mongo/db/query/plan_cache_test.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/mongo/db/query/plan_cache_test.cpp b/src/mongo/db/query/plan_cache_test.cpp
index d719c911d0e..7870c34a247 100644
--- a/src/mongo/db/query/plan_cache_test.cpp
+++ b/src/mongo/db/query/plan_cache_test.cpp
@@ -31,6 +31,8 @@
* This file contains tests for mongo/db/query/plan_cache.h
*/
+#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kTest
+
#include "mongo/db/query/plan_cache.h"
#include <algorithm>
@@ -50,6 +52,7 @@
#include "mongo/db/query/query_planner_test_lib.h"
#include "mongo/db/query/query_solution.h"
#include "mongo/db/query/query_test_service_context.h"
+#include "mongo/logv2/log.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/scopeguard.h"
@@ -1086,8 +1089,14 @@ protected:
BSONObj testSoln = fromjson(solnJson);
size_t matches = 0;
for (auto&& soln : solns) {
- if (QueryPlannerTestLib::solutionMatches(testSoln, soln->root())) {
+ auto matchStatus = QueryPlannerTestLib::solutionMatches(testSoln, soln->root());
+ if (matchStatus.isOK()) {
++matches;
+ } else {
+ LOGV2_DEBUG(51551100,
+ 2,
+ "Mismatching solution: {reason}",
+ "reason"_attr = matchStatus.reason());
}
}
return matches;
@@ -1168,8 +1177,14 @@ protected:
QuerySolution* firstMatchingSolution(const string& solnJson) const {
BSONObj testSoln = fromjson(solnJson);
for (auto&& soln : solns) {
- if (QueryPlannerTestLib::solutionMatches(testSoln, soln->root())) {
+ auto matchStatus = QueryPlannerTestLib::solutionMatches(testSoln, soln->root());
+ if (matchStatus.isOK()) {
return soln.get();
+ } else {
+ LOGV2_DEBUG(51551101,
+ 2,
+ "Mismatching solution: {reason}",
+ "reason"_attr = matchStatus.reason());
}
}
@@ -1190,10 +1205,12 @@ protected:
*/
void assertSolutionMatches(QuerySolution* trueSoln, const string& solnJson) const {
BSONObj testSoln = fromjson(solnJson);
- if (!QueryPlannerTestLib::solutionMatches(testSoln, trueSoln->root())) {
+ auto matchStatus = QueryPlannerTestLib::solutionMatches(testSoln, trueSoln->root());
+ if (!matchStatus.isOK()) {
str::stream ss;
ss << "Expected solution " << solnJson
- << " did not match true solution: " << trueSoln->toString() << '\n';
+ << " did not match true solution: " << trueSoln->toString()
+ << ". Reason: " << matchStatus.reason() << '\n';
FAIL(ss);
}
}