-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-27857 Fix timeout exception handling in HBaseClassTestRule #5231
HBASE-27857 Fix timeout exception handling in HBaseClassTestRule #5231
Conversation
HBaseClassTestRule applies a timeout and a system exit rule to tests. The timeout rule throws an exception if it hits the timeout threshold. Since the timeout rule is applied after the system exit rule, the system exit rule does not see the exception and does not re-enable the system exit behavior which can cause maven to hang on some tests. This change applies the timeout rule before the system exit rule so that normal system exit can be restored before the surefire forked node is shutdown. Signed-off-by: Jonathan Albrecht <jonathan.albrecht@ibm.com>
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Mind explain a bit more? IIRC, the SystemExitRule is to forbid System.exit call, so what is actual problem here? |
Yes, the SystemExitRule is supposed to forbid the System.exit call while a test is running so that the various test servers running in the surefire forked jvm don't cause it to exit before a test has finished IIUC. The SystemExitRule will restore the normal System.exit behaviour when the test completes. The problem is, if a test times out, the test doesn't actually complete. The forked jvm really does need to exit but the SystemExitRule hasn't restored System.exit so it can't. Note that the timeout exception originates in the timeout rule part of HBaseClassTestRule. The timeout rule actually runs the test method in a separate thread in a Future with a timeout value. The change in this PR applies the systemExitRule first so when the timeout rule throws an exception it will go through the try...finally block in the systemExitRule which restores the normal System.exit and the forked jvm can exit normally when it needs to. Without this change, you can see that org.apache.hadoop.hbase.TestSecurityManager shows up in the stacktrace if a test times out:
|
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
) HBaseClassTestRule applies a timeout and a system exit rule to tests. The timeout rule throws an exception if it hits the timeout threshold. Since the timeout rule is applied after the system exit rule, the system exit rule does not see the exception and does not re-enable the system exit behavior which can cause maven to hang on some tests. This change applies the timeout rule before the system exit rule so that normal system exit can be restored before the surefire forked node is shutdown. Signed-off-by: Duo Zhang <zhangduo@apache.org> (cherry picked from commit 220eacf)
) HBaseClassTestRule applies a timeout and a system exit rule to tests. The timeout rule throws an exception if it hits the timeout threshold. Since the timeout rule is applied after the system exit rule, the system exit rule does not see the exception and does not re-enable the system exit behavior which can cause maven to hang on some tests. This change applies the timeout rule before the system exit rule so that normal system exit can be restored before the surefire forked node is shutdown. Signed-off-by: Duo Zhang <zhangduo@apache.org> (cherry picked from commit 220eacf)
) HBaseClassTestRule applies a timeout and a system exit rule to tests. The timeout rule throws an exception if it hits the timeout threshold. Since the timeout rule is applied after the system exit rule, the system exit rule does not see the exception and does not re-enable the system exit behavior which can cause maven to hang on some tests. This change applies the timeout rule before the system exit rule so that normal system exit can be restored before the surefire forked node is shutdown. Signed-off-by: Duo Zhang <zhangduo@apache.org> (cherry picked from commit 220eacf)
Thanks for reviewing and merging @Apache9! |
…ache#5231) HBaseClassTestRule applies a timeout and a system exit rule to tests. The timeout rule throws an exception if it hits the timeout threshold. Since the timeout rule is applied after the system exit rule, the system exit rule does not see the exception and does not re-enable the system exit behavior which can cause maven to hang on some tests. This change applies the timeout rule before the system exit rule so that normal system exit can be restored before the surefire forked node is shutdown. Signed-off-by: Duo Zhang <zhangduo@apache.org> (cherry picked from commit 220eacf) (cherry picked from commit 4df157d) Change-Id: Id051ff2cf38fcdd3ef47f7e8d9ec99a8de88b6c8
HBaseClassTestRule applies a timeout and a system exit rule to tests. The timeout rule throws an exception if it hits the timeout threshold. Since the timeout rule is applied after the system exit rule, the system exit rule does not see the exception and does not re-enable the system exit behavior which can cause maven to hang on some tests.
This change applies the timeout rule before the system exit rule so that normal system exit can be restored before the surefire forked node is shutdown.