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

Fix #330 - Preserve load-list order #331

Merged
merged 1 commit into from
Aug 31, 2022
Merged

Conversation

Akrog
Copy link
Contributor

@Akrog Akrog commented Aug 17, 2022

When using --load-list to run tests the tests were always run in a different order than the one provided in the file, even when the --random argument was not present:

  $ stestr run --serial --load-list failing

This patch preserves the order of the tests from the file when --load-list is used, and it will only randomize it when --random is provided:

  $ stestr run --serial --random --load-list failing

When using `--load-list` to run tests the tests were always run in a
different order than the one provided in the file, even when the
`--random` argument was not present:

  $ stestr run --serial --load-list failing

This patch preserves the order of the tests from the file when
`--load-list` is used, and it will only randomize it when `--random` is
provided:

  $ stestr run --serial --random --load-list failing
@Akrog Akrog changed the title Fix #333 - Preserve load-list order Fix #330 - Preserve load-list order Aug 17, 2022
Copy link
Owner

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

Overall this looks great to me, thanks for tackling this.

Comment on lines +61 to +74
def _filter_tests(to_filter, id_map):
# Compatible objects
if extras.safe_hasattr(to_filter, 'filter_by_ids'):
res = to_filter.filter_by_ids(test_ids)
_filter_tests(res, id_map)
# TestCase objects.
elif extras.safe_hasattr(to_filter, 'id'):
test_id = to_filter.id()
if test_id in test_ids:
id_map[test_id] = to_filter
# Standard TestSuites or derived classes.
elif isinstance(to_filter, unittest.TestSuite):
for item in to_filter:
_filter_tests(item, id_map)
Copy link
Owner

Choose a reason for hiding this comment

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

I'm a little uneasy about the recursion here. I feel like it probably would have been a bit cleaner to just do it iteratively. But it's not a big deal this should be fine. If it becomes an issue we can always refactor it later

@mtreinish mtreinish merged commit 6edb3ed into mtreinish:main Aug 31, 2022
mtreinish added a commit that referenced this pull request Sep 22, 2022
Several issues have been reported about the run order and other odd
behavior in running of tests since the 4.0.0 release including a high
degree of random failures in stestr CI. #331 is the only likely
candidate as to the root cause. In the interest of fixing these issues
for people this commit reverts #331.

This reverts commit ff25c99.
mtreinish added a commit that referenced this pull request Sep 22, 2022
Several issues have been reported about the run order and other odd
behavior in running of tests since the 4.0.0 release including a high
degree of random failures in stestr CI. #331 is the only likely
candidate as to the root cause. In the interest of fixing these issues
for people this commit reverts #331.

This revert was already released as part of 4.0.1. Since the main branch
adopted `black` code formatting recently it was easier to do the
straight revert on the stable branch first as there was conflicts.

This reverts commit ff25c99.
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.

None yet

2 participants