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

Feature/skip remaining tests being executed #1029

Merged
merged 18 commits into from
Jan 17, 2024

Conversation

zhenyu-ms
Copy link
Contributor

@zhenyu-ms zhenyu-ms commented Dec 5, 2023

Bug / Requirement Description

Clearly and concisely describe the problem.

Solution description

Describe your code changes in detail for reviewers.

Checklist:

  • Test
  • Example (both test_plan.py and .rst)
  • Documentation (API)
  • News fragment present for release notes
  • MS info leakage check
  • For new driver: driver index page
  • For new assertion: ui/pdf/std renderers, documentation
  • For new cmdline arg: documentation

- convert certain statuses into enum
- introduce cross-executor messaging
- fix config clone
self._msg_handlers[msg.mark](msg)
time.sleep(interval)

def _handle_expected_abort(self, _):
Copy link
Contributor

Choose a reason for hiding this comment

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

Between abort & stop, i think this feature shall re-use stop logic of entities. But I'd rather not having a 3rd mode (expected_abort).

This can be useful in interactive mode, that after triggering an entire testsuite/multitest, we can stop the on-going execution with the same flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

2nd thought... stop_plan is going to discard all on-going tests, so maybe it's good enough to just reuse the timeout workflow, which is essentially abort().

self._results[next_uid] = result
self.ongoing.pop(0)

if thres and result.report.status <= thres:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just call a method of TestRunner here to set the flag, something like

if self.cfg.stop_strategy.should_stop_plan(result):
self.parent.stop_plan()

Then TestRunner shall distribute the should_stop flag to all executors (including this one).

Executors just discard all pending_work and pretend we have finished, and triggers normal stop workflow.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think pool size code change shall be in task result handler, every time pool receives a task result, check if we shall stop plan. Then the handling logic shall be exactly as testplan timeout handler.

The nested child pool on the remote side needs some special handing, need to disable this feature.

@zhenyu-ms zhenyu-ms marked this pull request as ready for review December 20, 2023 08:08
@zhenyu-ms zhenyu-ms force-pushed the skip-remaining branch 2 times, most recently from 35151a2 to f3d6dea Compare December 27, 2023 14:11
@@ -1000,6 +1008,7 @@ def _post_run_checks(self, start_threads, start_procs):
:param start_procs: processes before run
:type start_procs: ``list`` of ``Process``
"""
# XXX: do we want to suppress process/thread check for tests?
Copy link
Contributor

Choose a reason for hiding this comment

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

what does XXX mean?

Copy link
Contributor Author

@zhenyu-ms zhenyu-ms Jan 12, 2024

Choose a reason for hiding this comment

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

i use XXX for something that's not TODO and not FIXME and not NOTE

suppression is from intuition, use XXX instead of FIXME here

@@ -95,6 +98,7 @@ def __init__(self, **options) -> None:
self.event_recorder = EventRecorder(
name=str(self), event_type="Worker"
)
self._discard_running = threading.Event()
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference of using threading.Event() v.s boolean.

And _discard_running v.s _discard_pending?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this simple use case i think they could be equivalent even in the GIL-free world, threading.Event() might only exist as a reminder

i tend to choose different variable names for the ease of grep

@@ -13,6 +13,9 @@
from testplan.common.utils import logger
from testplan.runners.pools.communication import Message

if TYPE_CHECKING:
from testplan.runners.pools.base import Worker
Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously missing, see L291

@@ -0,0 +1,3 @@
Added a new command line argument ``--skip-remaining``, a new argument ``skip_strategy`` to MultiTest, allowing certain test execution being skipped for a better user experience.
Copy link
Contributor

Choose a reason for hiding this comment

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

allow early return of test execution and skip remaining Testcases/Testsuites/Multitests being executed when a Testcase has failed or raised exception.

Pyifan
Pyifan previously approved these changes Jan 17, 2024
@zhenyu-ms zhenyu-ms merged commit c6e4646 into morganstanley:main Jan 17, 2024
15 checks passed
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.

2 participants