Skip to content

tests(smoke): use fraggle rock as the default #13951

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

Merged
merged 14 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/package-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
# Fail if any changes were written to source files.
- run: git diff --exit-code

package-test-fr:
package-test-legacy:
runs-on: ubuntu-latest
name: Package Test Fraggle Rock
name: Package Test Legacy Navigation

steps:
- name: git clone
Expand All @@ -45,7 +45,7 @@ jobs:
- run: yarn build-report
- run: sudo apt-get install xvfb

- run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/lighthouse-core/scripts/release/package-test.sh --fraggle-rock
- run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/lighthouse-core/scripts/release/package-test.sh --legacy-navigation

# Fail if any changes were written to source files.
- run: git diff --exit-code
14 changes: 7 additions & 7 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
name: Smokehouse (windows)
path: .tmp/smokehouse-ci-failures/

smoke-fr:
smoke-legacy:
strategy:
matrix:
smoke-test-shard: [1, 2, 3]
Expand All @@ -126,7 +126,7 @@ jobs:
# The total number of shards. Set dynamically when length of *single* matrix variable is
# computable. See https://github.community/t/get-length-of-strategy-matrix-or-get-all-matrix-options/18342
SHARD_TOTAL: 3
name: Fraggle Rock ${{ matrix.smoke-test-shard }}/3
name: Legacy Navigation ${{ matrix.smoke-test-shard }}/3

steps:
- name: git clone
Expand All @@ -150,7 +150,7 @@ jobs:

- run: sudo apt-get install xvfb
- name: yarn smoke --fraggle-rock
run: xvfb-run --auto-servernum yarn smoke --debug --fraggle-rock -j=2 --retries=2 --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL
run: xvfb-run --auto-servernum yarn smoke --debug --legacy-navigation -j=2 --retries=2 --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL

# Fail if any changes were written to source files.
- run: git diff --exit-code
Expand All @@ -159,7 +159,7 @@ jobs:
if: failure()
uses: actions/upload-artifact@v1
with:
name: Smokehouse (fr)
name: Smokehouse (legacy)
path: .tmp/smokehouse-ci-failures/

smoke-bundle:
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
name: Smokehouse (bundled)
path: .tmp/smokehouse-ci-failures/

smoke-bundle-fr:
smoke-bundle-legacy:
strategy:
matrix:
smoke-test-shard: [1, 2, 3]
Expand All @@ -220,7 +220,7 @@ jobs:
# The total number of shards. Set dynamically when length of *single* matrix variable is
# computable. See https://github.community/t/get-length-of-strategy-matrix-or-get-all-matrix-options/18342
SHARD_TOTAL: 3
name: Bundled Fraggle Rock ${{ matrix.smoke-test-shard }}/3
name: Bundled Legacy Navigation ${{ matrix.smoke-test-shard }}/3

steps:
- name: git clone
Expand All @@ -244,7 +244,7 @@ jobs:

- run: sudo apt-get install xvfb
- name: yarn test-bundle
run: xvfb-run --auto-servernum yarn test-bundle --fraggle-rock --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL
run: xvfb-run --auto-servernum yarn test-bundle --legacy-navigation --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL

# Fail if any changes were written to source files.
- run: git diff --exit-code
Expand Down
6 changes: 3 additions & 3 deletions lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ async function begin() {
default: false,
describe: 'Save test artifacts and output verbose logs',
},
'fraggle-rock': {
'legacy-navigation': {
type: 'boolean',
default: false,
describe: 'Use the new Fraggle Rock runner',
describe: 'Use the legacy navigation runner',
},
'jobs': {
type: 'number',
Expand Down Expand Up @@ -216,7 +216,7 @@ async function begin() {
jobs,
retries,
isDebug: argv.debug,
useFraggleRock: argv.fraggleRock,
useLegacyNavigation: argv.legacyNavigation,
lighthouseRunner: runLighthouse,
takeNetworkRequestUrls,
};
Expand Down
14 changes: 7 additions & 7 deletions lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (!isMainThread && parentPort) {
/**
* @param {string} url
* @param {LH.Config.Json|undefined} configJson
* @param {{isDebug?: boolean, useFraggleRock?: boolean}} testRunnerOptions
* @param {{isDebug?: boolean, useLegacyNavigation?: boolean}} testRunnerOptions
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts}>}
*/
async function runBundledLighthouse(url, configJson, testRunnerOptions) {
Expand Down Expand Up @@ -80,15 +80,15 @@ async function runBundledLighthouse(url, configJson, testRunnerOptions) {
try {
const logLevel = testRunnerOptions.isDebug ? 'info' : undefined;
let runnerResult;
if (testRunnerOptions.useFraggleRock) {
if (testRunnerOptions.useLegacyNavigation) {
const connection = new ChromeProtocol(port);
runnerResult =
await lighthouse.legacyNavigation(url, {port, logLevel}, configJson, connection);
} else {
// Puppeteer is not included in the bundle, we must create the page here.
const browser = await puppeteer.connect({browserURL: `http://localhost:${port}`});
const page = await browser.newPage();
runnerResult = await lighthouse(url, {port, logLevel}, configJson, page);
} else {
const connection = new ChromeProtocol(port);
runnerResult =
await lighthouse.legacyNavigation(url, {port, logLevel}, configJson, connection);
}
if (!runnerResult) throw new Error('No runnerResult');

Expand All @@ -106,7 +106,7 @@ async function runBundledLighthouse(url, configJson, testRunnerOptions) {
* Launch Chrome and do a full Lighthouse run via the Lighthouse DevTools bundle.
* @param {string} url
* @param {LH.Config.Json=} configJson
* @param {{isDebug?: boolean, useFraggleRock?: boolean}=} testRunnerOptions
* @param {{isDebug?: boolean, useLegacyNavigation?: boolean}=} testRunnerOptions
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
*/
async function runLighthouse(url, configJson, testRunnerOptions = {}) {
Expand Down
22 changes: 3 additions & 19 deletions lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,16 @@ async function runLighthouse(url, configJson, testRunnerOptions = {}) {
.finally(() => !isDebug && fs.rm(tmpPath, {recursive: true, force: true}));
}

/**
* @param {LH.Config.Json=} configJson
* @return {LH.Config.Json|undefined}
*/
function convertToFraggleRockConfig(configJson) {
if (!configJson) return configJson;
if (!configJson.passes) return configJson;

return {
...configJson,
navigations: configJson.passes.map(pass => ({...pass, id: pass.passName})),
};
}

/**
* Internal runner.
* @param {string} url
* @param {string} tmpPath
* @param {LH.Config.Json=} configJson
* @param {{isDebug?: boolean, useFraggleRock?: boolean}=} options
* @param {{isDebug?: boolean, useLegacyNavigation?: boolean}=} options
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
*/
async function internalRun(url, tmpPath, configJson, options) {
const {isDebug = false, useFraggleRock = false} = options || {};
const {isDebug = false, useLegacyNavigation = false} = options || {};
const localConsole = new LocalConsole();

const outputPath = `${tmpPath}/smokehouse.report.json`;
Expand All @@ -81,9 +67,7 @@ async function internalRun(url, tmpPath, configJson, options) {
'--quiet',
];

if (useFraggleRock) {
configJson = convertToFraggleRockConfig(configJson);
} else {
if (useLegacyNavigation) {
args.push('--legacy-navigation');
}

Expand Down
10 changes: 5 additions & 5 deletions lighthouse-cli/test/smokehouse/report-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ function makeComparison(name, actualResult, expectedResult) {
* @param {LocalConsole} localConsole
* @param {LH.Result} lhr
* @param {Smokehouse.ExpectedRunnerResult} expected
* @param {{runner?: string, isBundled?: boolean, useFraggleRock?: boolean}=} reportOptions
* @param {{runner?: string, isBundled?: boolean, useLegacyNavigation?: boolean}=} reportOptions
*/
function pruneExpectations(localConsole, lhr, expected, reportOptions) {
const isFraggleRock = reportOptions?.useFraggleRock;
const isLegacyNavigation = reportOptions?.useLegacyNavigation;
const isBundled = reportOptions?.isBundled;

/**
Expand Down Expand Up @@ -276,13 +276,13 @@ function pruneExpectations(localConsole, lhr, expected, reportOptions) {
`Actual Chromium version: ${getChromeVersionString()}`,
].join(' '));
remove(key);
} else if (value._legacyOnly && isFraggleRock) {
} else if (value._legacyOnly && !isLegacyNavigation) {
localConsole.log([
`[${key}] marked legacy only but run is Fraggle Rock, pruning expectation:`,
JSON.stringify(value, null, 2),
].join(' '));
remove(key);
} else if (value._fraggleRockOnly && !isFraggleRock) {
} else if (value._fraggleRockOnly && isLegacyNavigation) {
localConsole.log([
`[${key}] marked Fraggle Rock only but run is legacy, pruning expectation:`,
JSON.stringify(value, null, 2),
Expand Down Expand Up @@ -459,7 +459,7 @@ function reportAssertion(localConsole, assertion) {
* summary. Returns count of passed and failed tests.
* @param {{lhr: LH.Result, artifacts: LH.Artifacts, networkRequests?: string[]}} actual
* @param {Smokehouse.ExpectedRunnerResult} expected
* @param {{runner?: string, isDebug?: boolean, isBundled?: boolean, useFraggleRock?: boolean}=} reportOptions
* @param {{runner?: string, isDebug?: boolean, isBundled?: boolean, useLegacyNavigation?: boolean}=} reportOptions
* @return {{passed: number, failed: number, log: string}}
*/
function getAssertionReport(actual, expected, reportOptions = {}) {
Expand Down
45 changes: 38 additions & 7 deletions lighthouse-cli/test/smokehouse/smokehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const DEFAULT_RETRIES = 0;
async function runSmokehouse(smokeTestDefns, smokehouseOptions) {
const {
isDebug,
useFraggleRock,
useLegacyNavigation,
jobs = DEFAULT_CONCURRENT_RUNS,
retries = DEFAULT_RETRIES,
lighthouseRunner = Object.assign(cliLighthouseRunner, {runnerName: 'cli'}),
Expand All @@ -65,7 +65,13 @@ async function runSmokehouse(smokeTestDefns, smokehouseOptions) {
// Run each testDefn in parallel based on the concurrencyLimit.
const concurrentMapper = new ConcurrentMapper();

const testOptions = {isDebug, useFraggleRock, retries, lighthouseRunner, takeNetworkRequestUrls};
const testOptions = {
isDebug,
useLegacyNavigation,
retries,
lighthouseRunner,
takeNetworkRequestUrls,
};
const smokePromises = smokeTestDefns.map(testDefn => {
// If defn is set to `runSerially`, we'll run it in succession with other tests, not parallel.
const concurrency = testDefn.runSerially ? 1 : jobs;
Expand Down Expand Up @@ -118,15 +124,35 @@ function purpleify(str) {
return `${log.purple}${str}${log.reset}`;
}

/**
* @param {LH.Config.Json=} configJson
* @return {LH.Config.Json|undefined}
*/
function convertToLegacyConfig(configJson) {
if (!configJson) return configJson;
if (!configJson.navigations) return configJson;

return {
...configJson,
passes: configJson.navigations.map(nav => ({...nav, passName: nav.id.concat('Pass')})),
};
}

/**
* Run Lighthouse in the selected runner.
* @param {Smokehouse.TestDfn} smokeTestDefn
* @param {{isDebug?: boolean, useFraggleRock?: boolean, retries: number, lighthouseRunner: Smokehouse.LighthouseRunner, takeNetworkRequestUrls?: () => string[]}} testOptions
* @param {{isDebug?: boolean, useLegacyNavigation?: boolean, retries: number, lighthouseRunner: Smokehouse.LighthouseRunner, takeNetworkRequestUrls?: () => string[]}} testOptions
* @return {Promise<SmokehouseResult>}
*/
async function runSmokeTest(smokeTestDefn, testOptions) {
const {id, config: configJson, expectations} = smokeTestDefn;
const {lighthouseRunner, retries, isDebug, useFraggleRock, takeNetworkRequestUrls} = testOptions;
const {id, expectations} = smokeTestDefn;
const {
lighthouseRunner,
retries,
isDebug,
useLegacyNavigation,
takeNetworkRequestUrls,
} = testOptions;
const requestedUrl = expectations.lhr.requestedUrl;

console.log(`${purpleify(id)} smoketest starting…`);
Expand All @@ -143,10 +169,15 @@ async function runSmokeTest(smokeTestDefn, testOptions) {
bufferedConsole.log(` Retrying run (${i} out of ${retries} retries)…`);
}

let configJson = smokeTestDefn.config;
if (useLegacyNavigation) {
configJson = convertToLegacyConfig(configJson);
}

// Run Lighthouse.
try {
result = {
...await lighthouseRunner(requestedUrl, configJson, {isDebug, useFraggleRock}),
...await lighthouseRunner(requestedUrl, configJson, {isDebug, useLegacyNavigation}),
networkRequests: takeNetworkRequestUrls ? takeNetworkRequestUrls() : undefined,
};
} catch (e) {
Expand All @@ -161,7 +192,7 @@ async function runSmokeTest(smokeTestDefn, testOptions) {
report = getAssertionReport(result, expectations, {
runner: lighthouseRunner.runnerName,
isDebug,
useFraggleRock,
useLegacyNavigation,
});

runs.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const config = {
// to complete.
maxWaitForLoad: 180000,
},
passes: [{
passName: 'defaultPass',
navigations: [{
id: 'default',
// CI machines are pretty weak which lead to many more long tasks than normal.
// Reduce our requirement for CPU quiet.
cpuQuietThresholdMs: 500,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const config = {
// to complete.
maxWaitForLoad: 180000,
},
passes: [
navigations: [
// CI machines are pretty weak which lead to many more long tasks than normal.
// Reduce our requirement for CPU quiet.
{
passName: 'defaultPass',
id: 'default',
cpuQuietThresholdMs: 500,
},
],
Expand Down
6 changes: 3 additions & 3 deletions types/smokehouse.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ declare global {
{expectations: Smokehouse.ExpectedRunnerResult | Array<Smokehouse.ExpectedRunnerResult>}

export type LighthouseRunner =
{runnerName?: string} & ((url: string, configJson?: Config.Json, runnerOptions?: {isDebug?: boolean; useFraggleRock?: boolean}) => Promise<{lhr: LHResult, artifacts: Artifacts, log: string}>);
{runnerName?: string} & ((url: string, configJson?: Config.Json, runnerOptions?: {isDebug?: boolean; useLegacyNavigation?: boolean}) => Promise<{lhr: LHResult, artifacts: Artifacts, log: string}>);

export interface SmokehouseOptions {
/** If true, performs extra logging from the test runs. */
isDebug?: boolean;
/** If true, uses the new Fraggle Rock runner. */
useFraggleRock?: boolean;
/** If true, use the legacy navigation runner. */
useLegacyNavigation?: boolean;
/** Manually set the number of jobs to run at once. `1` runs all tests serially. */
jobs?: number;
/** The number of times to retry failing tests before accepting. Defaults to 0. */
Expand Down