summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Paroski <drew.paroski@mongodb.com>2021-04-29 18:22:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-03 05:53:41 +0000
commit6ce8dd249685f3baebb80d7d90c769447a98db5f (patch)
tree5cfd16c4b92755faa636934c384828de97c9de26
parent1e7169833cf3804f08ef2854120be339bf4809f6 (diff)
downloadmongo-6ce8dd249685f3baebb80d7d90c769447a98db5f.tar.gz
SERVER-56493 Fix "unionWith_explain.js" test in various aggregation suites
-rw-r--r--jstests/aggregation/sources/unionWith/unionWith_explain.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/jstests/aggregation/sources/unionWith/unionWith_explain.js b/jstests/aggregation/sources/unionWith/unionWith_explain.js
index 2ffff833330..a22b2a3c994 100644
--- a/jstests/aggregation/sources/unionWith/unionWith_explain.js
+++ b/jstests/aggregation/sources/unionWith/unionWith_explain.js
@@ -42,9 +42,8 @@ function getUnionWithStage(explain) {
}
function buildErrorString(unionExplain, realExplain, field) {
- const toString = e => typeof e !== 'string' ? tojson(e) : e;
- return "Explains did not match in field " + field + ". Union:\n" + toString(unionExplain) +
- "\nRegular:\n" + toString(realExplain);
+ return "Explains did not match in field " + field + ". Union:\n" + tojson(unionExplain) +
+ "\nRegular:\n" + tojson(realExplain);
}
function docEqWithIgnoredFields(union, regular) {
@@ -55,6 +54,13 @@ function docEqWithIgnoredFields(union, regular) {
"restoreState",
"works",
"needTime",
+ "slots",
+ ]);
+}
+
+function arrayEqWithIgnoredFields(union, regular) {
+ return arrayEq(union, regular, false /* verbose */, null /* valueComparator */, [
+ "slots",
]);
}
@@ -86,11 +92,9 @@ function assertExplainEq(unionExplain, regularExplain) {
assert(docEqWithIgnoredFields(unionSubStats, realStats),
buildErrorString(unionSubStats, realStats));
} else {
- // Tolerate different values for the "NOW" slot when comparing explain output.
- const toString = e => tojson(e).replace(/^.* NOW = s[0-9]+ \([0-9]+\).*$/gm, "");
const realExplain = regularExplain.stages;
- assert(toString(unionSubExplain) == toString(realExplain),
- buildErrorString(toString(unionSubExplain), toString(realExplain)));
+ assert(arrayEqWithIgnoredFields(unionSubExplain, realExplain),
+ buildErrorString(unionSubExplain, realExplain));
}
}
}