summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Lapkov <nikita.lapkov@mongodb.com>2020-11-27 16:01:46 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-27 16:54:14 +0000
commit28bd503024df528e29ea07f5d966411b15db2be8 (patch)
treeeaef4c064d344bca1fe212055c1183d2cec2a3f0
parent35fa4e01778f93a5ece635307a5bba04c6648f3f (diff)
downloadmongo-28bd503024df528e29ea07f5d966411b15db2be8.tar.gz
SERVER-53096 Introduce additional logging for mod_overflow.js
-rw-r--r--jstests/core/mod_overflow.js71
1 files changed, 45 insertions, 26 deletions
diff --git a/jstests/core/mod_overflow.js b/jstests/core/mod_overflow.js
index 9903e76e2d0..983e943b6dd 100644
--- a/jstests/core/mod_overflow.js
+++ b/jstests/core/mod_overflow.js
@@ -18,32 +18,51 @@
// For each possible integral representation of -1, confirm that overflow does not occur.
for (let divisor of[-1.0, NumberInt("-1"), NumberLong("-1"), NumberDecimal("-1")]) {
- assert.docEq(testColl.find({val: {$mod: [divisor, 0]}}).sort({_id: 1}).toArray(),
- insertedDocs);
- assert.docEq(
- testColl
- .aggregate(
- [{$match: {$expr: {$eq: [0, {$mod: ["$val", divisor]}]}}}, {$sort: {_id: 1}}])
- .toArray(),
- insertedDocs);
+ try {
+ assert.docEq(testColl.find({val: {$mod: [divisor, 0]}}).sort({_id: 1}).toArray(),
+ insertedDocs);
+ assert.docEq(testColl
+ .aggregate([
+ {$match: {$expr: {$eq: [0, {$mod: ["$val", divisor]}]}}},
+ {$sort: {_id: 1}}
+ ])
+ .toArray(),
+ insertedDocs);
- // Confirm that overflow does not occur during agg expression evaluation. Also confirm that
- // the correct type is returned for each combination of input types.
- const expectedResults = [
- Object.merge(insertedDocs[0], {
- modVal: (divisor instanceof NumberDecimal ? NumberDecimal("-0") : NumberLong("0"))
- }),
- Object.merge(insertedDocs[1], {
- modVal: (divisor instanceof NumberLong
- ? NumberLong("0")
- : divisor instanceof NumberDecimal ? NumberDecimal("-0") : 0)
- })
- ];
- assert.docEq(
- testColl
- .aggregate(
- [{$project: {val: 1, modVal: {$mod: ["$val", divisor]}}}, {$sort: {_id: 1}}])
- .toArray(),
- expectedResults);
+ // Confirm that overflow does not occur during agg expression evaluation. Also confirm
+ // that the correct type is returned for each combination of input types.
+ const expectedResults = [
+ Object.merge(insertedDocs[0], {
+ modVal:
+ (divisor instanceof NumberDecimal ? NumberDecimal("-0") : NumberLong("0"))
+ }),
+ Object.merge(insertedDocs[1], {
+ modVal: (divisor instanceof NumberLong
+ ? NumberLong("0")
+ : divisor instanceof NumberDecimal ? NumberDecimal("-0") : 0)
+ })
+ ];
+ assert.docEq(testColl
+ .aggregate([
+ {$project: {val: 1, modVal: {$mod: ["$val", divisor]}}},
+ {$sort: {_id: 1}}
+ ])
+ .toArray(),
+ expectedResults);
+ } catch (error) {
+ jsTestLog("Failure encountered on divisor: " + tojson(divisor));
+ jsTestLog("Explain output for find with $mod match expression: " +
+ tojson(testColl.find({val: {$mod: [divisor, 0]}}).sort({_id: 1}).explain()));
+ jsTestLog("Explain output for aggregate with $mod aggregation expression in $expr: " +
+ tojson(testColl.explain().aggregate([
+ {$match: {$expr: {$eq: [0, {$mod: ["$val", divisor]}]}}},
+ {$sort: {_id: 1}}
+ ])));
+ jsTestLog(
+ "Explain output for aggregate with $mod aggregation expression in $project: " +
+ tojson(testColl.explain().aggregate(
+ [{$project: {val: 1, modVal: {$mod: ["$val", divisor]}}}, {$sort: {_id: 1}}])));
+ throw error;
+ }
}
})(); \ No newline at end of file