-
Notifications
You must be signed in to change notification settings - Fork 3.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
feat(test runner): shuffle order of tests with sharding seed #30817
Conversation
@microsoft-github-policy-service agree company="Adobe" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
retest |
This comment has been minimized.
This comment has been minimized.
This looks great, thank you! |
This comment has been minimized.
This comment has been minimized.
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.
Looks good overall!
@@ -32,6 +32,7 @@ export type ConfigCLIOverrides = { | |||
reporter?: ReporterDescription[]; | |||
additionalReporters?: ReporterDescription[]; | |||
shard?: { current: number, total: number }; | |||
shardingSeed?: 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.
revert: no need to pass it to the workers.
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.
shardingSeed
is required on ConfigCLIOverrides
to support --sharding-seed
cli option... It would be limiting to only support this via config file. Or am I missing something?
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.
…OR if not via cli option, it would be great to support it via environment variable e.g.export PW_SHARDING_SEED=...
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.
Ah, you are right, we need it here since we are setting it in the command line.
* ``` | ||
* | ||
*/ | ||
shardingSeed?: 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.
These will disappear.
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.
Looks like it did not. Is that a problem?
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.
We have user-defined config TestConfig and resolved FullConfig. Should be in TestConfig and not in FullConfig. So you seem to be fine.
This comment has been minimized.
This comment has been minimized.
Test results for "tests 1"1 flaky27030 passed, 610 skipped Merge workflow run. |
I think there is some more room for improvement regarding the sharding logic. Currently the way sharding works something like this…
I think it would be better to change the distribution logic to something like this…
And when we are able to sort the test groups by duration (e.g. given the results of a previous test run), we could achieve better distribution than this shuffle logic in this PR. However, that can be explored in a different PR… |
@@ -32,6 +32,7 @@ export type ConfigCLIOverrides = { | |||
reporter?: ReporterDescription[]; | |||
additionalReporters?: ReporterDescription[]; | |||
shard?: { current: number, total: number }; | |||
shardingSeed?: 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.
Ah, you are right, we need it here since we are setting it in the command line.
* ``` | ||
* | ||
*/ | ||
shardingSeed?: 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.
We have user-defined config TestConfig and resolved FullConfig. Should be in TestConfig and not in FullConfig. So you seem to be fine.
Adds a new feature to the test runner which allows to specify a seed value to randomize the test group order before sharding.
Problem
For example, if the first half of your tests are slower than the rest of your tests and you are using 4 shards to run your tests across multiple machines, it means that shard 1 and 2 will take significantly more time to complete than shard 3 and 4.
Solution
By randomizing the order of test groups before sharding in a deterministic way we can achieve a better distribution of slow and fast tests across all shards.
Example
Below are some runtime stats from a project I've been working on, which shows the potential benefit of this change.
Previously our distributed test job required around 30 minutes to complete due to individual shards requiring between 9-29 minutes. Now, with the seeded shuffling we're down to 20 minutes with individual shards requiring between 15-19 minutes.