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

testing: prevent test scheduling after reactor exit #2644

Closed
wants to merge 1 commit into from

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Feb 17, 2025

Previously, when handling "--help" (introduced in b8a13be), we returned status code 0 but continued scheduling test tasks to the Seastar reactor. This caused test applications to hang since the tasks expected the exchanger 'e' to be available after reactor exit.

Fix this by using the "_done" flag to track reactor state:

  • Set "_done" when Seastar application exits
  • Skip task scheduling and exchanger wait if "_done" is set
  • Change test_runner::start_thread() to return bool indicating successful engine startup instead of exit code (exit code now stored in _exit_code member)

This fixes the regression where "--help" would cause test applications to hang indefinitely.

Fixes #2635
Signed-off-by: Kefu Chai [email protected]

@@ -130,6 +131,11 @@ test_runner::run_sync(std::function<future<>()> task) {
// it.
return;
}
if (_done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it happen that _done is false, but _exit_code is non-zero?
In other words -- is the above if (_exit_code != 0) still required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh, you're right. with my change, if _done is true, it implies app.run() has returned -- it's an early return, and the return code is either 0 or a non-zero status code. let me update the change to further simplify this implementation.

@tchaikov tchaikov marked this pull request as draft February 17, 2025 14:32
@tchaikov

This comment was marked as resolved.

Previously, when handling "--help" (introduced in b8a13be), we returned
status code 0 but continued scheduling test tasks to the Seastar reactor.
This caused test applications to hang since the tasks expected the exchanger
'e' to be available after reactor exit.

Fix this by using the "_done" flag to track reactor state:
- Set "_done" when Seastar application exits
- Skip task scheduling and exchanger wait if "_done" is set
- Change test_runner::start_thread() to return bool indicating successful
  engine startup instead of exit code (exit code now stored in _exit_code
  member)

This fixes the regression where "--help" would cause test applications to
hang indefinitely.

Fixes scylladb#2635
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov tchaikov marked this pull request as ready for review February 18, 2025 00:50
@tchaikov
Copy link
Contributor Author

v2:

  • Instead of setting _done in test_runner::start_thread() member function, change test_runner::start_thread() to return bool indicating successful engine startup instead of exit code (exit code now stored in _exit_code member), and set and _done in test_runner::run_sync(). simpler this way. and it is more obvious that we early return when _done is set.

@tchaikov
Copy link
Contributor Author

tested with

kefu@mega:~/dev/seastar$ build/debug/tests/unit/queue_test -- --help
Running 3 test cases...
WARNING: debug mode. Not for benchmarking or production
App options:
  -h [ --help ]                         show help message
  --help-seastar                        show help message about seastar options
  --help-loggers                        print a list of logger names and exit
  --random-seed arg                     Random number generator seed
  --fail-on-abandoned-failed-futures arg (=1)
                                        Fail the test if there are any 
                                        abandoned failed futures


*** No errors detected
kefu@mega:~/dev/seastar$ 

@tchaikov tchaikov requested a review from xemul February 18, 2025 04:08
@xemul xemul closed this in 9ca4fee Feb 19, 2025
@tchaikov tchaikov deleted the test-exit-on-stop branch February 20, 2025 03:08
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.

When --help flag is passed to a test the program hangs/never exits
2 participants