Skip to content
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): add flag for test sharding #13047

Merged
merged 3 commits into from Sep 14, 2021
Merged

tests(smokehouse): add flag for test sharding #13047

merged 3 commits into from Sep 14, 2021

Conversation

brendankenny
Copy link
Member

Adds an easier way to split up smoke tests across multiple runners with a --shard=n/d flag, which splits the requested tests up into d shards and runs the nth shard.

This stacks with the existing test selection and --invert-match functionality, so e.g. yarn smoke seo --shard=1/2 will run seo-passing seo-failing (out of all the seo tests seo-passing seo-failing seo-status-403 seo-tap-targets), and similarly yarn smoke --invert-match forms --shard=1/4 will run the first fourth of all the smoke tests excluding forms.

Both FR and the smoke bundle now run almost all of the smoke tests so are taking longer and we may want to split them up, but the --invert-match trick won't work to split them up into multiple runners because they need --invert-match to disallow certain tests. We may also eventually want to split up the smoke tests into more than two jobs, which --invert-match also wouldn't handle.

I got the flag naming from playwright's shard (similar flags exist elsewhere but this was the most recent inspiration). Also the reason for using 1 as the lowest shard number instead of 0...not sure how other people feel about that :)

@brendankenny brendankenny requested a review from a team as a code owner September 10, 2021 23:21
@brendankenny brendankenny requested review from connorjclark and removed request for a team September 10, 2021 23:21
@google-cla google-cla bot added the cla: yes label Sep 10, 2021
@connorjclark
Copy link
Collaborator

I got the flag naming from playwright's shard (similar flags exist elsewhere but this was the most recent inspiration). Also the reason for using 1 as the lowest shard number instead of 0...not sure how other people feel about that :)

It's being used to count things and we humans start at 1, and starting at zero is only necessary to help computers squeeze performance out of adding offsets to memory locations so... 1 sgtm :)

Comment on lines +21 to +23
# 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: 2
Copy link
Member Author

Choose a reason for hiding this comment

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

this is unfortunately really annoying. You can get the length of the entire matrix with ${{ strategy.job-index }}, but that's 4 here, not 2 (since it's chrome-channel × smoke-test-shard).

There are also ways you can do fancy things with | jq '. | length', but you need a reference to the whole array first, so you need it to be the output of another job (can't do it with env because they aren't available inside matrix...), at which point it all becomes much more verbose than just having a 2 here.

So... :/

* Parses the cli `shardArg` flag into `shardNumber/shardTotal`. Splits
* `testDefns` into `shardTotal` shards and returns the `shardNumber`th shard.
* Shards will differ in size by at most 1.
* Shard params must be 1≤shardNumber≤shardTotal.
Copy link
Collaborator

Choose a reason for hiding this comment

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

here and elsewhere: can you break up with spaces, hard to read. 1 ≤ shardNumber ≤ shardTotal

Copy link
Member Author

Choose a reason for hiding this comment

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

good call

@brendankenny
Copy link
Member Author

Slow smoke test completion times

maybe time to divide up the other smoke tests :)

@brendankenny brendankenny merged commit d02747d into master Sep 14, 2021
@brendankenny brendankenny deleted the smokeshard branch September 14, 2021 16:52
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.

None yet

3 participants