Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: migrate test.js to support concurrent test execution #1531

Merged
merged 7 commits into from Dec 12, 2017

Conversation

aslushnikov
Copy link
Contributor

@aslushnikov aslushnikov commented Dec 4, 2017

This patch migrates tests so that they can be run concurrently.

  • By default, tests still run in one thread.
  • To run tests in 4 parallel threads, run node test/test.js -j 4 or npm run unit -- -j 4
  • Environment variable PPTR_PARALLEL_TESTS could be set to override default parallelization

Every test gets passed in a state. State is set up in the beforeAll and beforeEach callbacks,
and should be teared down in the afterAll and afterEach callbacks.

By default, state has a parallelIndex variable initialized that defines the thread index that runs the execution.

@aslushnikov aslushnikov force-pushed the parallel-test branch 3 times, most recently from 7349b16 to cc4518e Compare December 7, 2017 23:36
test/test.js Outdated
expect(FrameUtils.dumpFrames(restoredPage.mainFrame())).toBeGolden('reconnect-nested-frames.txt');
expect(await restoredPage.evaluate(() => 7 * 8)).toBe(56);
await browser.close();
}));
});
describe('Puppeteer.executablePath', function() {
it('should work', SX(async function() {
it('should work', SX(async({urls}) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove SX in this patch.

Run tests in parallel. The amount of threads equals
to the CPU count.
test/test.js Outdated
if (fs.existsSync(OUTPUT_DIR))
rm(OUTPUT_DIR);
}));
const port = 8907 + state.parallel * 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index

@aslushnikov aslushnikov changed the title [Experimental] run parallel test on travis test: migrate test.js to support concurrent test execution Dec 12, 2017
@aslushnikov aslushnikov merged commit a5db6d4 into puppeteer:master Dec 12, 2017
dios-david added a commit to dios-david/puppeteer that referenced this pull request Dec 16, 2017
This patch fixes broken Tracing tests which are failing since the `state.parallel` -> `state.parallelIndex` modification of puppeteer#1531
aslushnikov pushed a commit that referenced this pull request Dec 18, 2017
This patch fixes broken Tracing tests which are failing since the `state.parallel` -> `state.parallelIndex` modification of #1531
@aslushnikov aslushnikov deleted the parallel-test branch January 25, 2018 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants