Skip to content

Conversation

sipa
Copy link
Member

@sipa sipa commented Jan 6, 2022

A few simplifications to test_runner.py to make it easier to reason about (and perhaps fix #23799 (review)):

  • Remove the num_running variable as it should be implied by the length of the jobs variable.
  • Remove the i variable as it should be implied by the length of the test_results variable.
  • Instead of counting results to determine if we're done, make the queue object itself responsible (by looking at running jobs and jobs left).

Remove the num_running variable as it should be implied by the
length of the jobs variable.

Remove the i variable as it should be implied by the length of the
test_results variable.

Instead of counting results to determine if we're done, make the
queue object itself responsible (by looking at running jobs and
jobs left).
@mzumsande
Copy link
Contributor

mzumsande commented Jan 7, 2022

I think the problem with #23799 was that it introduced a second outer loop while i < test_count: which broke the --failfast option. If that option was chosen and a test failed, the break would leave the inner loop, but since the condition of the outer loop was not fulfilled, the inner loop would just be started again.

As far as I can see, this problem is still there (even though I can't reproduce the "pop from empty list" with this branch).

@maflcko maflcko mentioned this pull request Jan 12, 2022
@pg156
Copy link

pg156 commented Jan 13, 2022

I see the same behavior as @mzumsande: --failfast option doesn't work, and can't reproduce "pop from empty list".

Here is a suggested fix. (I don't know how to suggest changes on lines unchanged.) Any feedback is appreciated as it is a learning opportunity.

  • add failed attribute to TestHandler class
class TestHandler:
    """
    Trigger the test scripts passed in via the list.
    """

    def __init__(self, *, num_tests_parallel, tests_dir, tmpdir, test_list, flags, use_term_control, failed):
        assert num_tests_parallel >= 1
        self.num_jobs = num_tests_parallel
        self.tests_dir = tests_dir
        self.tmpdir = tmpdir
        self.test_list = test_list
        self.flags = flags
        self.jobs = []
        self.use_term_control = use_term_control
        self.failed = failed

job_queue = TestHandler(
    num_tests_parallel=jobs,
    tests_dir=tests_dir,
    tmpdir=tmpdir,
    test_list=test_list,
    flags=flags,
    use_term_control=use_term_control,
    failed=False
)
  • modify 'failed' in case of fast fail
if failfast:
    job_queue.failed = True
    logging.debug("Early exiting after test failure")
    break
  • modify done method
def done(self):
    return self.failed or (not (self.jobs or self.test_list))

@katesalazar
Copy link
Contributor

katesalazar commented Jan 21, 2022

I think the problem with #23799 was that it introduced a second outer loop while i < test_count: which broke the --failfast option. If that option was chosen and a test failed, the break would leave the inner loop, but since the condition of the outer loop was not fulfilled, the inner loop would just be started again.

failfast is very useful when having smol computing power

if this languge supports multiple block breaking (as many
others do) I suppose why wouldnt you have it break 2
as an urgent amend to 23799 while something more
calmly thought is coming

TODO: add some tests to test the tests framework

@DrahtBot
Copy link
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24195 (test: Fix failfast option for functional test runner by mzumsande)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

maflcko pushed a commit that referenced this pull request Feb 7, 2022
a036358 test: Repair failfast option for test runner (Martin Zumsande)

Pull request description:

  Fixes #23990

  After #23799, the `--failfast` option in the test runner for the functional tests stopped working, because a second outer loop was introduced, which would have needed a `break` too for the test runner to fail immediately. This also led to the errors reported in #23990.

  This provides a straightforward fix for that.
  There is also #23995 which is a larger refactor, but that hasn't been updated in a while to fix the failfast issue.

ACKs for top commit:
  pg156:
    Tested ACK a036358. I agree adding the `all_passed` flag to break out of the outer loop when needed makes sense. The "failfast" option works after this change.

Tree-SHA512: 3e2f775e36c13d180d32a05cd1cfe0883274e8615cdbbd4e069a9899e9b9ea1091066cf085e93f1c5326bd8ecc6ff524e0dad7c638f60dfdb169fefcdb26ee52
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 7, 2022
…nner

a036358 test: Repair failfast option for test runner (Martin Zumsande)

Pull request description:

  Fixes bitcoin#23990

  After bitcoin#23799, the `--failfast` option in the test runner for the functional tests stopped working, because a second outer loop was introduced, which would have needed a `break` too for the test runner to fail immediately. This also led to the errors reported in bitcoin#23990.

  This provides a straightforward fix for that.
  There is also bitcoin#23995 which is a larger refactor, but that hasn't been updated in a while to fix the failfast issue.

ACKs for top commit:
  pg156:
    Tested ACK a036358. I agree adding the `all_passed` flag to break out of the outer loop when needed makes sense. The "failfast" option works after this change.

Tree-SHA512: 3e2f775e36c13d180d32a05cd1cfe0883274e8615cdbbd4e069a9899e9b9ea1091066cf085e93f1c5326bd8ecc6ff524e0dad7c638f60dfdb169fefcdb26ee52
@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 7, 2022

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@maflcko
Copy link
Member

maflcko commented Mar 22, 2022

lgtm, but this still needs rebase, either here or in a separate pull.

@laanwj
Copy link
Member

laanwj commented Apr 5, 2022

Concept ACK

@sipa
Copy link
Member Author

sipa commented Apr 5, 2022

Closing. #23799 is fixed through #24195, and I don't feel like rebasing the other changes here.

@sipa sipa closed this Apr 5, 2022
@sipa
Copy link
Member Author

sipa commented Apr 5, 2022

Marked up for grabs.

@bitcoin bitcoin locked and limited conversation to collaborators Apr 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants