mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-21 20:49:10 +01:00
SERVER-73541 Use dynamic import when loading parallel tester tests
This commit is contained in:
parent
64cdb91c0f
commit
ee66aa703f
@ -1,9 +1,9 @@
|
||||
env:
|
||||
es2020: true
|
||||
es2022: true
|
||||
mongo: true
|
||||
|
||||
parserOptions:
|
||||
ecmaVersion: 2020
|
||||
ecmaVersion: 2022
|
||||
sourceType: "module"
|
||||
|
||||
rules:
|
||||
|
@ -124,8 +124,8 @@ if (typeof _threadInject != "undefined") {
|
||||
this.params.push(args);
|
||||
};
|
||||
|
||||
ParallelTester.prototype.run = function(msg) {
|
||||
assert.parallelTests(this.params, msg);
|
||||
ParallelTester.prototype.run = async function(msg) {
|
||||
await assert.parallelTests(this.params, msg);
|
||||
};
|
||||
|
||||
// creates lists of tests from jstests dir in a format suitable for use by
|
||||
@ -359,22 +359,28 @@ if (typeof _threadInject != "undefined") {
|
||||
return params;
|
||||
};
|
||||
|
||||
async function measureAsync(fn) {
|
||||
const start = new Date();
|
||||
await fn.apply(null, Array.from(arguments).slice(2));
|
||||
return (new Date()).getTime() - start.getTime();
|
||||
}
|
||||
|
||||
// runs a set of test files
|
||||
// first argument is an identifier for this tester, remaining arguments are file names
|
||||
ParallelTester.fileTester = function() {
|
||||
ParallelTester.fileTester = async function() {
|
||||
var args = Array.from(arguments);
|
||||
var suite = args.shift();
|
||||
args.forEach(function(x) {
|
||||
for (const x of args) {
|
||||
print(" S" + suite + " Test : " + x + " ...");
|
||||
var time = Date.timeFunc(function() {
|
||||
const time = await measureAsync(async function() {
|
||||
// Create a new connection to the db for each file. If tests share the same
|
||||
// connection it can create difficult to debug issues.
|
||||
db = new Mongo(db.getMongo().host).getDB(db.getName());
|
||||
gc();
|
||||
load(x);
|
||||
}, 1);
|
||||
await import(x);
|
||||
});
|
||||
print(" S" + suite + " Test : " + x + " " + time + "ms");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// params: array of arrays, each element of which consists of a function followed
|
||||
|
@ -6,12 +6,12 @@ Random.setRandomSeed();
|
||||
|
||||
var params = ParallelTester.createJstestsLists(4);
|
||||
var t = new ParallelTester();
|
||||
for (i in params) {
|
||||
for (let i in params) {
|
||||
t.add(ParallelTester.fileTester, params[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
t.run("one or more tests failed");
|
||||
await t.run("one or more tests failed");
|
||||
} finally {
|
||||
print(
|
||||
"If the failure here is due to a test unexpected being run, " +
|
||||
|
@ -8,7 +8,7 @@ Random.setRandomSeed();
|
||||
|
||||
var params = ParallelTester.createJstestsLists(4);
|
||||
var t = new ParallelTester();
|
||||
for (i in params) {
|
||||
for (let i in params) {
|
||||
t.add(ParallelTester.fileTester, params[i]);
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ for (var i = 4; i < 8; ++i) {
|
||||
t.add(EventGenerator.dispatch, g.getEvents());
|
||||
}
|
||||
try {
|
||||
t.run("one or more tests failed");
|
||||
await t.run("one or more tests failed");
|
||||
} finally {
|
||||
print(
|
||||
"If the failure here is due to a test unexpected being run, " +
|
||||
|
Loading…
Reference in New Issue
Block a user