-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for execution sharding #2600
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
Conversation
(to avoid this being a breaking change for api consumers)
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.
Many thanks for contributing this, it's a great quality PR.
Feature is implemented as plugin on event pickles:filter and will run between filter and order plugins.
As such defined order is not affected by sharding and random order will only shuffle tests in a shard.Alternatively, a new event pickles:shard could be introduced to be executed after pickles:order which would allow a global random seed. This will require a documentation change to warn users they should use the same seed across shards.
I think what you've done is the best balance - no sense in adding another event just for this.
From looking at the code, I coudl not tell how the pickles are sorted. If this is a random sort, based on how they are read from the file system, this will lead to errors. You must sort all pickles in a unique way. As a side note, since you use modulo, sorting by file size and then alphabetically will give better performance compared to alphabetically only. |
@Tallyb can you elaborate on what errors you are foreseeing? Are you able to reproduce them in a sample project? This PR doesn't deal with any sorting - that is handled in a later phase, after filtering. |
let's take a simple example: Machine 1: tests are read in the following order - A, B, C, D, E, F, G. tests taken - A, D, G. (positions: 1, 4, 7) |
The code in all instances does 3 things in this order:
Can see this is load_sources.ts or run_cucumber.ts Sharding is applied after discovery but before further ordering. So discovery is responsible for the Getting back to your example, all 3 machines run the exact same code to discover So all 3 machines will discover the tests in an order which roughly resembles Then all 3 machines will apply the same filtering logic, which would leave them Picking nth test on each shard will provide uniform distribution of all tests afterwards. As a last step if a random order is used, those left on each shard are reshuffled. |
Thanks for laying that out @agologan. As you say, the initial order of sources and pickles is deterministic given the same configuration, so I don't believe we have a problem here. |
Ok, as long as it is deterministic, there is no issue. |
🤔 What's changed?
--shard 1/3
to allow for execution sharding similar to https://playwright.dev/docs/test-sharding⚡️ What's your motivation?
Closes #2303
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
Feature is implemented as plugin on event
pickles:filter
and will run between filter and order plugins.As such
defined
order is not affected by sharding andrandom
order will only shuffle tests in a shard.Alternatively, a new event
pickles:shard
could be introduced to be executed afterpickles:order
which would allow a global random seed. This will require a documentation change to warn users they should use the same seed across shards.The option was added to
ISourcesCoordinates
as it acts more like a filtering option for a specific instance rather than how--parallel
behaves and the plugin was loaded only forrunCucumber
.📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.