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

[WIP] Add dynamic scheduling operation mode #271

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

mtreinish
Copy link
Owner

This commit adds an opt-in scheduler option for dynamic scheduling.
Instead of partitioning the test list up-front based on historical
timing data this commit lets each worker ask for the next test
dynamically. This is built using python's multiprocess module to
launch new workers instead of shelling out to call python via
subprocess.

This hopefully will provide a better worker balance since we will keep
each worker occupied until there are no more tests to be run. Instead
of trying to pack fill each work optimially up front. Additionally this
should hopefully improve the pdb story for users who use pdb with tests.
Since instead of spawning subprocesses calling python to invoke the
subunit runner and reading the subunit stream from stdout and instead
uses multiprocessing to fork workers and uses pipes to pass the subunit
streams between workers.

@mtreinish
Copy link
Owner Author

This still fails some tests but after switching away from subunit.run this seems to run reliably on python >=3.5. It also will need proper test coverage since this flow is very different from what was there before. I probably should add a dynamic job to travis and appveyor to split out running the full suite between the old way and this new approach.

stestr/commands/run.py Outdated Show resolved Hide resolved
Copy link

@aspiers aspiers left a comment

Choose a reason for hiding this comment

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

Thanks for accepting my suggestion. As per this comment this doesn't seem to work for me yet.

@coveralls
Copy link

coveralls commented Oct 29, 2019

Coverage Status

Coverage decreased (-21.2%) to 46.985% when pulling e8989ca on dynamic-schedule into bbc839f on master.

mtreinish and others added 4 commits November 24, 2019 06:17
This commit adds an opt-in scheduler option for dynamic scheduling.
Instead of partitioning the test list up-front based on historical
timing data this commit lets each worker ask for the next test
dynamically.  This is built using python's multiprocess module to
launch new workers instead of shelling out to call python via
subprocess.

This hopefully will provide a better worker balance since we will keep
each worker occupied until there are no more tests to be run. Instead
of trying to pack fill each work optimially up front. Additionally this
should hopefully improve the pdb story for users who use pdb with tests.
Since instead of spawning subprocesses calling python to invoke the
subunit runner and reading the subunit stream from stdout and instead
uses multiprocessing to fork workers and uses pipes to pass the subunit
streams between workers.
Co-Authored-By: Adam Spiers <github@adamspiers.org>
This commit fixes the failing tests by catching a couple of missing
things from the update. The biggest fix was that for the --no-discover
case we still use a subprocess and because of that we need to tell
output.ReturnCodeToSubunit to that the input is not dynamic (and
therefore a Popen object) so it can handle that properly. The other
major change is that the return code tests are updated so that the
stdout and stderr from the subprocess calls are always decoded in the
non-subunit test cases. This was done primarily for ease of debugging,
but it also enabled the removal of several decode() calls when the
output is parsed.
This is a refinement on the previous commit to reduce unecessary changes
to the functional tests in the test_return_codes module. Mainly always
decoding the output from the subprocess for testing broken things
unexpectedly when a bytes object was expected.
I originally developed this feature when we still supported older
python versions in stestr. The dynamic scheduling feature depends on
functionality added in Python 3.5. Since then the WIP feature branch sat
stale for years since that time we've bumped the minimum version of
Python supported to 3.7 so the runtime check for older python versions
is no longer needed.
@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2023

Codecov Report

Merging #271 (e23f8ed) into main (d24afca) will decrease coverage by 1.64%.
The diff coverage is 20.20%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #271      +/-   ##
==========================================
- Coverage   61.79%   60.15%   -1.64%     
==========================================
  Files          30       30              
  Lines        2625     2713      +88     
  Branches      428      448      +20     
==========================================
+ Hits         1622     1632      +10     
- Misses        884      957      +73     
- Partials      119      124       +5     
Flag Coverage Δ
unittests 60.15% <20.20%> (-1.64%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
stestr/config_file.py 96.29% <ø> (ø)
stestr/scheduler.py 66.08% <2.63%> (-31.32%) ⬇️
stestr/test_processor.py 67.27% <29.26%> (-13.50%) ⬇️
stestr/output.py 63.57% <30.76%> (-3.61%) ⬇️
stestr/commands/run.py 41.48% <42.85%> (-0.18%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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

Successfully merging this pull request may close these issues.

4 participants