summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Guo <robert.guo@mongodb.com>2019-10-17 21:17:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-29 17:25:37 +0000
commit8a3fdaf06f64c86b8fe6686af0f0729853cda2b5 (patch)
tree297dbd4eba5212b9b19ef1d9d45929a2c260d1f7
parent62d9f36d148e4dacfec1ca8fcb110f1cc410336f (diff)
downloadmongo-8a3fdaf06f64c86b8fe6686af0f0729853cda2b5.tar.gz
SERVER-43973 Use a unique test name for each thread in ParallelTester.
This commit combines two others: - Cherry pick 82daedc0abbea3acdd22e99ba0c2639a297bc9bb. This commit makes ParallelTester use unique test names for each thread - Revert 28bd503024df528e29ea07f5d966411b15db2be8. This commit disables additional logging in mod_overflow.js test, which was added in SERVER-53096
-rw-r--r--jstests/core/mod_overflow.js71
-rw-r--r--jstests/libs/parallelTester.js12
2 files changed, 36 insertions, 47 deletions
diff --git a/jstests/core/mod_overflow.js b/jstests/core/mod_overflow.js
index 983e943b6dd..9903e76e2d0 100644
--- a/jstests/core/mod_overflow.js
+++ b/jstests/core/mod_overflow.js
@@ -18,51 +18,32 @@
// 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")]) {
- 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);
+ 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);
- } 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;
- }
+ // 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);
}
})(); \ No newline at end of file
diff --git a/jstests/libs/parallelTester.js b/jstests/libs/parallelTester.js
index 25ac95e6894..e858f14bbd3 100644
--- a/jstests/libs/parallelTester.js
+++ b/jstests/libs/parallelTester.js
@@ -383,11 +383,19 @@ if (typeof _threadInject != "undefined") {
for (var i in params) {
var param = params[i];
var test = param.shift();
+
+ // Make a shallow copy of TestData so we can override the test name to
+ // prevent tests on different threads that to use jsTestName() as the
+ // collection name from colliding.
+ const clonedTestData = Object.assign({}, TestData);
+ clonedTestData.testName = `ParallelTesterThread${i}`;
+
var t;
if (newScopes)
- t = new ScopedThread(wrapper, test, param, {TestData: TestData});
+ t = new ScopedThread(wrapper, test, param, {TestData: clonedTestData});
else
- t = new Thread(wrapper, test, param, {TestData: TestData});
+ t = new Thread(wrapper, test, param, {TestData: clonedTestData});
+
runners.push(t);
}