-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
tests(smokehouse): run smoketests in parallel #4748
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems good most of the time, but I am concerned about the debuggability if something does go wrong and the output is all interleaved together :)
also, whats the feasibility of getting rid of all the run-tests.sh files for just one :)
Aye. I added an extra line of output where "checking " is emitted right before the assertions are checked. IMO i think that lowers the probability of confusing results a LOT. But it's still possible and to fix that means buffering output which means any failures you won't see until ALL smoketests are done. Also requires lots more work. :)
And going to JS? Mmmmmmm that's also an option. |
@patrickhulce (no rush, but..) thoughts? right now it looks like this work will go into ❄️ chillin state. |
shelljs is somewhat active again so could work ok for this (and get us easier windows support) |
TBH it could move to JS without shelljs, even. really not too terrible. |
100% js would be nice. For now we could still buffer the output inside a variable and output it where needed if we are afraid of debugging. |
Yeah.. Now with basic pattern of https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/scripts/update-report-fixtures.js available, we can much more easily do this in JS. And yeah we can avoid interleaving much easier. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once you're feeling good about them, can you also list all the changes to the individual smoke tests. Like yarn smokehouse
is getting broken out into an explicit pwa smoke test, a bunch of stuff is getting moved into offline-expectations, but I believe you mentioned that was because you were going to get rid of one of the existing tests that already had a lot of overlap?
package.json
Outdated
"smoke": "bash lighthouse-cli/test/smokehouse/run-all-tests.sh", | ||
|
||
"smoke": "node lighthouse-cli/test/smokehouse/run-smoke.js", | ||
"coverage": "istanbul cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*-test.js') --reporter progress --report lcovonly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase problem?
const results = runLighthouse(expected.initialUrl, configPath); | ||
console.log(`Comparing results of '${expected.initialUrl}':`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe console.log(`Auditing findings of '${expected.initialUrl}':`);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱
config: smokehouseDir + 'pwa-config.js', | ||
}, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line
}; | ||
|
||
|
||
function displayOutput(cp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add jsdoc?
} | ||
|
||
/** | ||
* Update the report artifacts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old comment?
serverForOffline.listen(10503, 'localhost'); | ||
|
||
const cmdPromises = []; | ||
for (const [id, {expectations, config}] of Object.entries(smokes)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add way to specify how many to run at the same time? But it sounds like you may be planning that already
703ff43
to
9ccedbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm % nits
for (const {id, expectations, config} of smokes) { | ||
// If the machine is terribly slow, do them in succession, not parallel | ||
if (process.env.APPVEYOR) { | ||
await Promise.all(cmdPromises); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have a slight preference to just move this farther down and await p
for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's a little confusing at first how this would work since it's Promise.all
and at the top of the loop, though it's nice doing it in one line and with the same array as the parallel case :)
const serialSmokeResults = await runSmokehouse(serialSmokes); | ||
smokeResults.push(...serialSmokeResults); | ||
|
||
await new Promise(res => server.close(res)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this really throws me just because res
is the canonical express response
shorthand and then later you use it for result, resolve
or done
? :)
await new Promise(res => server.close(res)); | ||
await new Promise(res => serverForOffline.close(res)); | ||
|
||
const failingTests = smokeResults.filter(res => !!res.error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/res/anything else :)
const results = runLighthouse(expected.initialUrl, configPath, cli.debug); | ||
|
||
console.log(`Auditing findings of '${expected.initialUrl}':`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe console.log(`Scoring reportCategory results of '${expected.initialUrl}':`);
instead?
}, | ||
}, | ||
|
||
// Disabled due to flakiness of site. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we reenable :)
const results = runLighthouse(expected.initialUrl, configPath, cli.debug); | ||
|
||
console.log(`Auditing findings of '${expected.initialUrl}':`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe console.log(`Scoring reportCategory results of '${expected.initialUrl}':`);
instead?
|
||
/** | ||
* Display smokehouse output from child process | ||
* @param {{id: string, process?: NodeJS.Process, code?: number}} cp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/cp/result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would also be something like @param {{id: string, process: NodeJS.Process} || {id: string, error: Error & {stdout : NodeJS.WriteStream, stderr: NodeJS.WriteStream}}} result
but that might be getting a bit silly, especially with no type checking on this file :)
/** | ||
* Run smokehouse in child processes for selected smoketests | ||
* Display output from each as soon as they finish, but resolve function when ALL are complete | ||
* @param {*} smokes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{id: string, expectations: string, config: string}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
er, and perfSensitive?: boolean
for (const {id, expectations, config} of smokes) { | ||
// If the machine is terribly slow, do them in succession, not parallel | ||
if (process.env.APPVEYOR) { | ||
await Promise.all(cmdPromises); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's a little confusing at first how this would work since it's Promise.all
and at the top of the loop, though it's nice doing it in one line and with the same array as the parallel case :)
`--config-path=${config}`, | ||
`--expectations-path=${expectations}`, | ||
].join(' '); | ||
const p = execAsync(cmd, {timeout: 5 * 60 * 1000, encoding: 'utf8'}).then(cp => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a comment that the promise then/catch is on purpose so p resolves with process output no matter what?
@@ -23,7 +23,9 @@ | |||
"build-viewer": "cd ./lighthouse-viewer && yarn build", | |||
"clean": "rimraf *.report.html *.report.dom.html *.report.json *.screenshots.html *.screenshots.json *.devtoolslog.json *.trace.json || true", | |||
"lint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .", | |||
"smoke": "bash lighthouse-cli/test/smokehouse/run-all-tests.sh", | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these newlines won't survive a yarn add
, fwiw
} else { | ||
smokes = SMOKETESTS.filter(test => argv.includes(test.id)); | ||
console.log(`Running ONLY smoketests for: ${smokes.map(t => t.id).join(' ')}\n`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add an error case that prints smokes
ids?
} | ||
|
||
const parallelSmokes = SMOKETESTS.filter(t => !t.perfSensitive); | ||
const serialSmokes = SMOKETESTS.filter(t => t.perfSensitive); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I'm missing it, but aren't these still run in parallel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🛤️🛤️🔀🛤️🛤️
/** | ||
* | ||
* @param {string[]} argv | ||
* @return {Map<string, Array<SmoketestDfn>>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string|undefined
? or give a default batch name/symbol so it doesn't fall back to undefined
} | ||
|
||
// Split into serial batches that will run their tests concurrently | ||
const batches = smokes.reduce((map, test) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still running the two perf batches in parallel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently there's a default batch (with like 7 smoketests) and a perf batch (with 2).
when perf batch goes, the 2 smoketests in there do run in parallel.
I was hoping that style was a little more clear with this "batch" framing.
async function runSmokehouse(smokes) { | ||
const cmdPromises = []; | ||
for (const {id, expectations, config} of smokes) { | ||
console.log(`${purpleify(id)} smoketest starting…`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const ret = {id: id, error: err}; | ||
displaySmokehouseOutput(ret); | ||
return ret; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to code golf, could also be
const p = execAsync(cmd, {timeout: 3 * 60 * 1000, encoding: 'utf8'}).then(cp => {
return {id: id, process: cp};
}).catch(err => {
return {id: id, error: err};
}).then(result => displaySmokehouseOutput(result));
(or the even shorter parenthesized version)
From 149s (2.5 minutes!) down to 45s!
Mostly a matter of running them in parallel.
Changes
run-test.sh
scripts with a flexible JS-based smoketest runner. Runs eachsmokehouse.js
invocation in its own child-process.dbw-expectations
intooffline
, as it was testing the exact same URL, just asserting different aspects out the output.yarn smoke
will run all, but you can doyarn smoke byte
andyarn smoke byte ttci
to run individual smokehouse expectationspwa
andpwa2
), as they were some of the slowest smoketests we did.yarn smokehouse
was removed. it's effectively replaced withyarn smoke pwa && yarn smoke pwa2
shop.polymer-project.org
smoketest.