Commit | Line | Data |
---|---|---|
1 | class TestUtils { | |
2 | static async waitExits (pool, numberOfExitEventsToWait) { | |
3 | let exitEvents = 0 | |
4 | return new Promise(function (resolve, reject) { | |
5 | pool.workers.forEach(w => { | |
6 | w.on('exit', () => { | |
7 | exitEvents++ | |
8 | if (exitEvents === numberOfExitEventsToWait) { | |
9 | resolve(exitEvents) | |
10 | } | |
11 | }) | |
12 | }) | |
13 | }) | |
14 | } | |
15 | ||
16 | static async sleep (ms) { | |
17 | return new Promise(resolve => setTimeout(resolve, ms)) | |
18 | } | |
19 | } | |
20 | ||
21 | module.exports = TestUtils |