-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix retries and error notification in workers (#8079)
* Add tests that show that retries are broken in jest-worker * Re-send requests to workers after they're re-created to retry * Refactor request handling in workers * Add changelog entry * Fix lint issues * Improve e2e test
- Loading branch information
1 parent
b0cbcbf
commit 0c9737e
Showing
6 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import path from 'path'; | ||
import os from 'os'; | ||
import {cleanup, writeFiles} from '../Utils'; | ||
import runJest from '../runJest'; | ||
|
||
const DIR = path.resolve(os.tmpdir(), 'fatal-worker-error'); | ||
|
||
beforeEach(() => cleanup(DIR)); | ||
afterAll(() => cleanup(DIR)); | ||
|
||
const NUMBER_OF_TESTS_TO_FORCE_USING_WORKERS = 25; | ||
|
||
test('fails a test that terminates the worker with a fatal error', () => { | ||
const testFiles = { | ||
'__tests__/fatalWorkerError.test.js': ` | ||
test('fatal worker error', () => { | ||
process.exit(134); | ||
}); | ||
`, | ||
}; | ||
|
||
for (let i = 0; i <= NUMBER_OF_TESTS_TO_FORCE_USING_WORKERS; i++) { | ||
testFiles[`__tests__/test${i}.test.js`] = ` | ||
test('test ${i}', () => {}); | ||
`; | ||
} | ||
|
||
writeFiles(DIR, { | ||
...testFiles, | ||
'package.json': '{}', | ||
}); | ||
|
||
const {status, stderr} = runJest(DIR, ['--maxWorkers=2']); | ||
|
||
const numberOfTestsPassed = (stderr.match(/\bPASS\b/g) || []).length; | ||
|
||
expect(status).not.toBe(0); | ||
expect(numberOfTestsPassed).toBe(Object.keys(testFiles).length - 1); | ||
expect(stderr).toContain('FAIL __tests__/fatalWorkerError.test.js'); | ||
expect(stderr).toContain('Call retries were exceeded'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters