mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: test sharding for firefox (#11008)
Co-authored-by: jrandolf <101637635+jrandolf@users.noreply.github.com>
This commit is contained in:
parent
4b130730ad
commit
52468adcff
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@ -220,7 +220,7 @@ jobs:
|
|||||||
- run: 'exit 0'
|
- run: 'exit 0'
|
||||||
|
|
||||||
firefox-tests:
|
firefox-tests:
|
||||||
name: ${{ matrix.suite }} tests on ${{ matrix.os }}
|
name: ${{ matrix.suite }} tests on ${{ matrix.os }} (${{ matrix.shard }})
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
needs: check-changes
|
needs: check-changes
|
||||||
if: ${{ contains(fromJSON(needs.check-changes.outputs.changes), 'puppeteer') }}
|
if: ${{ contains(fromJSON(needs.check-changes.outputs.changes), 'puppeteer') }}
|
||||||
@ -234,6 +234,11 @@ jobs:
|
|||||||
- firefox-bidi
|
- firefox-bidi
|
||||||
- firefox-headful
|
- firefox-headful
|
||||||
- firefox-headless
|
- firefox-headless
|
||||||
|
shard:
|
||||||
|
- 1/4
|
||||||
|
- 2/4
|
||||||
|
- 3/4
|
||||||
|
- 4/4
|
||||||
exclude:
|
exclude:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
suite: firefox-headful
|
suite: firefox-headful
|
||||||
@ -268,10 +273,10 @@ jobs:
|
|||||||
run: npm run postinstall
|
run: npm run postinstall
|
||||||
- name: Run all tests (for non-Linux)
|
- name: Run all tests (for non-Linux)
|
||||||
if: ${{ matrix.os != 'ubuntu-latest' }}
|
if: ${{ matrix.os != 'ubuntu-latest' }}
|
||||||
run: npm run test -- --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
|
run: npm run test -- --shard '${{ matrix.shard }}' --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
|
||||||
- name: Run all tests (for Linux)
|
- name: Run all tests (for Linux)
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
run: xvfb-run --auto-servernum npm run test -- --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
|
run: xvfb-run --auto-servernum npm run test -- --shard '${{ matrix.shard }}' --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
|
||||||
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
|
@ -22,10 +22,14 @@ module.exports = {
|
|||||||
reporter: 'dot',
|
reporter: 'dot',
|
||||||
logLevel: 'debug',
|
logLevel: 'debug',
|
||||||
require: ['./test/build/mocha-utils.js', 'source-map-support/register'],
|
require: ['./test/build/mocha-utils.js', 'source-map-support/register'],
|
||||||
spec: 'test/build/**/*.spec.js',
|
|
||||||
exit: !!process.env.CI,
|
exit: !!process.env.CI,
|
||||||
retries: process.env.CI ? 3 : 0,
|
retries: process.env.CI ? 3 : 0,
|
||||||
parallel: !!process.env.PARALLEL,
|
parallel: !!process.env.PARALLEL,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
reporter: process.env.CI ? 'spec' : 'dot',
|
reporter: process.env.CI ? 'spec' : 'dot',
|
||||||
|
...(!process.env['PUPPETEER_SHARD']
|
||||||
|
? {
|
||||||
|
spec: 'test/build/**/*.spec.js',
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
};
|
};
|
||||||
|
@ -1481,12 +1481,6 @@
|
|||||||
"parameters": ["cdp", "firefox"],
|
"parameters": ["cdp", "firefox"],
|
||||||
"expectations": ["FAIL", "PASS"]
|
"expectations": ["FAIL", "PASS"]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[click.spec] Page.click should click the button after navigation",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["FAIL"]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[click.spec] Page.click should click the button if window.Node is removed",
|
"testIdPattern": "[click.spec] Page.click should click the button if window.Node is removed",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -1637,12 +1631,6 @@
|
|||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["FAIL", "PASS"]
|
"expectations": ["FAIL", "PASS"]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[defaultbrowsercontext.spec] DefaultBrowserContext page.cookies() should work",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["cdp", "firefox"],
|
|
||||||
"expectations": ["FAIL"]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[defaultbrowsercontext.spec] DefaultBrowserContext page.deleteCookie() should work",
|
"testIdPattern": "[defaultbrowsercontext.spec] DefaultBrowserContext page.deleteCookie() should work",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -2331,7 +2319,7 @@
|
|||||||
"testIdPattern": "[navigation.spec] navigation Frame.waitForNavigation should work",
|
"testIdPattern": "[navigation.spec] navigation Frame.waitForNavigation should work",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
"parameters": ["firefox", "webDriverBiDi"],
|
||||||
"expectations": ["TIMEOUT"]
|
"expectations": ["FAIL", "TIMEOUT"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.goBack should work with HistoryAPI",
|
"testIdPattern": "[navigation.spec] navigation Page.goBack should work with HistoryAPI",
|
||||||
@ -2471,12 +2459,6 @@
|
|||||||
"parameters": ["cdp", "firefox"],
|
"parameters": ["cdp", "firefox"],
|
||||||
"expectations": ["SKIP"]
|
"expectations": ["SKIP"]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["TIMEOUT"]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work when subframe issues window.stop()",
|
"testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work when subframe issues window.stop()",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -2495,12 +2477,6 @@
|
|||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["FAIL"]
|
"expectations": ["FAIL"]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work with both domcontentloaded and load",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["TIMEOUT"]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work with clicking on anchor links",
|
"testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work with clicking on anchor links",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -3603,7 +3579,7 @@
|
|||||||
"testIdPattern": "[target.spec] Target should not report uninitialized pages",
|
"testIdPattern": "[target.spec] Target should not report uninitialized pages",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
"parameters": ["firefox", "webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["FAIL", "PASS"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[target.spec] Target should report when a new page is created and closed",
|
"testIdPattern": "[target.spec] Target should report when a new page is created and closed",
|
||||||
|
@ -22,6 +22,8 @@ import {spawn, type SpawnOptions} from 'node:child_process';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
import {globSync} from 'glob';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
zPlatform,
|
zPlatform,
|
||||||
zTestSuiteFile,
|
zTestSuiteFile,
|
||||||
@ -93,6 +95,12 @@ async function main() {
|
|||||||
minTests = Number(process.argv[minTestsIdx + 1]);
|
minTests = Number(process.argv[minTestsIdx + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const shardIdx = process.argv.indexOf('--shard');
|
||||||
|
let shard = null;
|
||||||
|
if (shardIdx !== -1) {
|
||||||
|
shard = String(process.argv[shardIdx + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
const platform = zPlatform.parse(os.platform());
|
const platform = zPlatform.parse(os.platform());
|
||||||
|
|
||||||
const expectations = readJSON(
|
const expectations = readJSON(
|
||||||
@ -182,13 +190,41 @@ async function main() {
|
|||||||
args.push('--no-parallel');
|
args.push('--no-parallel');
|
||||||
}
|
}
|
||||||
if (process.argv.indexOf('--fullTrace')) {
|
if (process.argv.indexOf('--fullTrace')) {
|
||||||
args.push('--fullTrace');
|
args.push('--full-trace');
|
||||||
|
}
|
||||||
|
if (shard) {
|
||||||
|
const specs = globSync('test/build/**/*.spec.js').sort((a, b) => {
|
||||||
|
return a.localeCompare(b);
|
||||||
|
});
|
||||||
|
// Shard ID is 1-based.
|
||||||
|
const [shardId, shards] = shard.split('/').map(s => {
|
||||||
|
return Number(s);
|
||||||
|
}) as [number, number];
|
||||||
|
const argsLength = args.length;
|
||||||
|
for (let i = 0; i < specs.length; i++) {
|
||||||
|
if (i % shards === shardId - 1) {
|
||||||
|
args.push(specs[i]!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (argsLength === args.length) {
|
||||||
|
throw new Error('Shard did not result in any test files');
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
`Running shard ${shardId}/${shards}. Picked ${
|
||||||
|
args.length - argsLength
|
||||||
|
} files out of ${specs.length}.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const spawnArgs: SpawnOptions = {
|
const spawnArgs: SpawnOptions = {
|
||||||
shell: true,
|
shell: true,
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
env,
|
env: shard
|
||||||
|
? {
|
||||||
|
...env,
|
||||||
|
PUPPETEER_SHARD: 'true',
|
||||||
|
}
|
||||||
|
: env,
|
||||||
};
|
};
|
||||||
const handle = noCoverage
|
const handle = noCoverage
|
||||||
? spawn('npx', ['mocha', ...args], spawnArgs)
|
? spawn('npx', ['mocha', ...args], spawnArgs)
|
||||||
@ -229,7 +265,7 @@ async function main() {
|
|||||||
results.updates = updates;
|
results.updates = updates;
|
||||||
writeJSON(tmpFilename, results);
|
writeJSON(tmpFilename, results);
|
||||||
} else {
|
} else {
|
||||||
if (totalTests < minTests) {
|
if (!shard && totalTests < minTests) {
|
||||||
fail = true;
|
fail = true;
|
||||||
console.log(
|
console.log(
|
||||||
`Test run matches expectations but the number of discovered tests is too low (expected: ${minTests}, actual: ${totalTests}).`
|
`Test run matches expectations but the number of discovered tests is too low (expected: ${minTests}, actual: ${totalTests}).`
|
||||||
|
Loading…
Reference in New Issue
Block a user