playwright/src/grid
Andrey Lushnikov 4f762ba90a
feat: introduce experimental general-purpose grid (#8941)
This patch adds a general-purpose grid framework to parallelize
Playwright across multiple agents.

This patch adds two CLI commands to manage grid:

- `npx playwright experimental-grid-server` - to launch grid
- `npx playwrigth experimental-grid-agent` - to launch agent in a host
  environment.

Grid server accepts an `--agent-factory` argument. A simple
`factory.js` might look like this:

```js
const child_process = require('child_process');

module.exports = {
  name: 'My Simple Factory',
  capacity: Infinity, // How many workers launch per agent
  timeout: 10_000, // 10 seconds timeout to create agent
  launch: ({agentId, gridURL, playwrightVersion}) => child_process.spawn(`npx`, [
    'playwright'
    'experimental-grid-agent',
    '--grid-url', gridURL,
    '--agent-id', agentId,
  ], {
    cwd: __dirname,
    shell: true,
    stdio: 'inherit',
  }),
};
```

With this `factory.js`, grid server could be launched like this:

```bash
npx playwright experimental-grid-server --factory=./factory.js
```

Once launched, it could be used with Playwright Test using env variable:

```bash
PW_GRID=http://localhost:3000 npx playwright test
```
2021-09-16 01:20:36 -07:00
..
gridAgent.ts feat: introduce experimental general-purpose grid (#8941) 2021-09-16 01:20:36 -07:00
gridClient.ts feat: introduce experimental general-purpose grid (#8941) 2021-09-16 01:20:36 -07:00
gridServer.ts feat: introduce experimental general-purpose grid (#8941) 2021-09-16 01:20:36 -07:00
gridWorker.ts feat: introduce experimental general-purpose grid (#8941) 2021-09-16 01:20:36 -07:00
simpleGridFactory.ts feat: introduce experimental general-purpose grid (#8941) 2021-09-16 01:20:36 -07:00