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

Worker assign logic #1043

Open
SviatoslavKovalchuk opened this issue Mar 18, 2024 · 5 comments
Open

Worker assign logic #1043

SviatoslavKovalchuk opened this issue Mar 18, 2024 · 5 comments

Comments

@SviatoslavKovalchuk
Copy link

Hey all!
I already opened a similar ticket #1031

Could some one please explain to me logic, whats going on under the hood when xdist assign (using @pytest.mark.xdist_group(name="example1")) group of test to worker ?

@nicoddemus
Copy link
Member

Hey @SviatoslavKovalchuk,

I'm short on time, but I can point you to the source code: https://github.com/pytest-dev/pytest-xdist/blob/master/src/xdist/scheduler/loadgroup.py

@SviatoslavKovalchuk
Copy link
Author

Thank you for your quick response @nicoddemus
I've already seen this a few times, and this is still not clear to me.
I may have asked a little incorrect question. My main goal is to understand the logic of assigning test groups to workers, such as I describe in this ticket #1031 and like the feature request here #365

@nicoddemus
Copy link
Member

The logic IIRC is simple: tests marked with the same xdist_group (and executing via loadgroup) will be sent to the same worker at runtime. You cannot control which worker that will be (so in the first run that might be gw1, the next run might be gw7, etc), but they will execute in the same worker.

@SviatoslavKovalchuk
Copy link
Author

SviatoslavKovalchuk commented Mar 19, 2024

Can we control which worker will be assigned?
And are you planning something like 'Lock tests to a specific worker'?
And have a marker like @pytest.mark.xdist_group(name="example-group-one", worker="gw1")
Thank you in advance @nicoddemus

@nicoddemus
Copy link
Member

nicoddemus commented Mar 28, 2024

Can we control which worker will be assigned?

No, you cannot control directly.

And are you planning something like 'Lock tests to a specific worker'?
And have a marker like @pytest.mark.xdist_group(name="example-group-one", worker="gw1")

None of the above is planned, however they should all be possible if you implement your own scheduler. You can use one of the builtin as basis: https://github.com/pytest-dev/pytest-xdist/tree/master/src/xdist/scheduler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants