-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add hang detection to @QuarkusTest #14507
Conversation
This will dump a stack trace if the test appears to have hung.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Added few minor comments...
if (!runOnce.compareAndSet(false, true)) { | ||
return; | ||
} | ||
System.err.println("@QuarkusTest has detected a hang, as there has been no test activity in " + hangTimeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be useful to be able (config?) to dump the stack trace to a file instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is most likely going to be useful in CI, it is so much easier to just use system err.
If we were to dump it to a file, it would need to be in a location that is then included in the artifacts produced by the CI pipeline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm talking about local builds... but the truth is that you can easily dump the stack manually in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly
|
||
private ExtensionState doJavaStart(ExtensionContext context, Class<? extends QuarkusTestProfile> profile) throws Throwable { | ||
hangDetectionExecutor = Executors.newSingleThreadScheduledExecutor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could skip the executor completely if -Dquarkus.test.hang-detection-timeout=-1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That make sense, but in what scenario do you envision doing that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in case, if there are any problems with the executor/cancelling the task or something like that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it can't hurt :)
|
||
No further action will be taken, and the tests will continue as normal (generally until CI times out), however the printed | ||
stack traces should help diagnose why the build has failed. You can control this timeout with the | ||
`quarkus.test.hang-detection-timeout` system property (you can also set this in application.properties, but this won't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, maybe something like "If you set this property in application.properties
the value will be ignored and the default value will be used instead. The reason is that the timeout is initialized before the test application starts." or something like that...
@geoand ah, late to the party ;-). |
This will dump a stack trace if the test
appears to have hung.