Skip to content

Conversation

@connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Sep 14, 2019

EDIT: just doing --only-urls in this PR.


[original message]

Two new flags to run a subset of smoke tests: --only-audits and --only-urls

cjamcl@cjamcl:~/code/lighthouse$ yarn smoke --help
yarn run v1.12.3
$ node lighthouse-cli/test/smokehouse/run-smoke.js --help
Options:
  --help         Show help                                                                                      [boolean]
  --only-audits  Filter for audit expectations to run                                                             [array]
  --only-urls    Filter for urls to run. Patterns accepted                                                        [array]

Examples:
  yarn smoke --only-audits network-requests                   Only run tests for the network-request audit
  yarn smoke --only-urls http://localhost:10200/preload.html  Only run tests for http://localhost:10200/preload.html

Also, if one of the batches fails, a command to rerun the failures is printed:

image

@connorjclark connorjclark changed the title tests(smokehouse): filter which tests runs tests(smokehouse): filter tests Sep 14, 2019
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

neat! I'm suspecting this might have a few bad interactions though with some of the audits that are added just so we can assert something on artifacts and whatnot, but I don't have great ideas for that

@vercel vercel bot temporarily deployed to staging September 16, 2019 19:33 Inactive
@connorjclark
Copy link
Collaborator Author

neat! I'm suspecting this might have a few bad interactions though with some of the audits that are added just so we can assert something on artifacts and whatnot, but I don't have great ideas for that

good point. should be good now.

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

Is this serving a current need? Each smokehouse definition is pretty short on its own, typically is limited to audits that will individually trigger the same number of passes anyway, and I don't think I'm ever going to remember one of the URLs off the top of my head, if only for the port numbers alone :)

This seems more suited for a different definition setup, where each smoke test runs the full default config over each test page instead of each being pruned by hand (which may or may not be sustainable much longer, who knows).

@connorjclark
Copy link
Collaborator Author

Is this serving a current need?
being pruned by hand

Investigating any specific failure in the smoke tests requires pruning away what you don't want, which has become a step I really dislike.

and I don't think I'm ever going to remember one of the URLs off the top of my head

The bit that spits out the exact command to re-run the failures doesn't require remembering any URLs.

@brendankenny
Copy link
Contributor

Investigating any specific failure in the smoke tests requires pruning away what you don't want, which has become a step I really dislike.

audit pruning doesn't seem like it would help, though? They're already silenced if they're passing.

If an expectations file has more than one url in it is annoying if the failure is in e.g. the last one, that's a good point (though we don't require URLs to be unique)

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

not sure what the status of this effort is, but I'm fine either way. seems useful to me but I understand not churning smoke tests too 🤷‍♂

`--expectations-path=${expectations}`,
].join(' ');
];
if (argv.onlyAudits) commandParts.push(`--only-audits ${argv.onlyAudits.join(' ')}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

should these be pushed separately? feels weird to double join with " "

@vercel vercel bot temporarily deployed to staging September 23, 2019 22:32 Inactive
@paulirish
Copy link
Member

been a while but came here because i really want url filtering.

Investigating any specific failure in the smoke tests requires pruning away what you don't want, which has become a step I really dislike.

...

If an expectations file has more than one url in it is annoying if the failure is in e.g. the last one, that's a good point (though we don't require URLs to be unique)

yeah i do this all the time. i comment out the other URLs (and their expectations) in an expectation file. super annoying.

(I care less about only-audits and currently i dont think i'd really use it)


one thought: going in another direction, maybe each expectation file should only be for a single URL. we currently have 39 URLs we load. and they're defined across 16 files. (the 16 are selectable as 'pwa', 'dbw' 'pwa2', etc etc). does anyone feel like it should be 1 file per tested LH run?

@connorjclark
Copy link
Collaborator Author

I'm more open to "one url per expectation file" now, but there is the extra complication that some files (like seo/expectations.js) have a shared bit of code between each url declaration.

I suggest opening a new issue to talk more about it / schedule a talk during eng sync.

I will update this PR now.

@connorjclark connorjclark requested a review from a team as a code owner January 13, 2021 01:14
@connorjclark connorjclark changed the title tests(smokehouse): filter tests tests(smokehouse): filter tests by url Jan 13, 2021
@connorjclark connorjclark changed the title tests(smokehouse): filter tests by url tests(smokehouse): filter tests by url, print rerun command Jan 13, 2021
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

this is a nice intermediate step, thanks for fixing up :)

}

const exitCode = isPassing ? 0 : 1;
const failingUrls = testResults.testResults
Copy link
Collaborator

Choose a reason for hiding this comment

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

should the variable be something like smokehouseResult? testResults.testResults twitches my nose a bit :)

console.log(usage);
}

if (onlyUrls) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

interaction with invertMatch is a little confusing now, maybe warrants some documentation on the method and/or CLI help?

long-term fix might be a skipUrls parallel :)

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

This is relatively straightforward, but it's also treating url as an id, so every test has two IDs. This results in things like every smokehouse result being double keyed and being confusing which ID you need to look at to evaluate success (at the expectation level or the url level), the unclear interplay between --invert-match and --only-urls, etc.

It's a slightly more painful transition, but it does seem like @paulirish is right that making a change to 1 ID <=> 1 test solves all this more simply.

smokes = smokes.filter(smoke => {
smoke.expectations = smoke.expectations.filter(expectation => {
const url = expectation.lhr.requestedUrl;
const shouldRunUrl = onlyUrls.some(pattern => new RegExp(pattern).test(url));
Copy link
Contributor

Choose a reason for hiding this comment

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

new RegExp(pattern)

it seems like this would be a problem with some of the gnarlier URLs when c/p verbatim

Copy link
Contributor

Choose a reason for hiding this comment

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

new RegExp(pattern)

it seems like this would be a problem with some of the gnarlier URLs when c/p verbatim

actually they look mostly ok, it's just the test urls with querystrings that break it, since ? won't match itself in new RegExp(urlWithQuery).test(urlWithQuery)

(are there other metacharacters that aren't usually url encoded that could make their way into one of our test URLs?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I asked my friend SO for help.

'node',
path.relative(process.cwd(), __filename),
// This is the good bit.
`--only-urls ${failingUrls.join(' ')}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

ampersands, at least, are an issue for me without quoting

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed with a child_process hack. too bad it doesn't expose a function "give me formatted command".

@connorjclark
Copy link
Collaborator Author

this is mostly replaced by the each-url-a-test refactor, but I would like to close and follow up with a small change that does the "print a command to rerun failures" thing this PR did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants