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

Add hang detection to @QuarkusTest #14507

Merged
merged 1 commit into from
Jan 22, 2021

Conversation

stuartwdouglas
Copy link
Member

This will dump a stack trace if the test
appears to have hung.

This will dump a stack trace if the test
appears to have hung.
Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

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

Great idea!

@geoand geoand merged commit 0d25c05 into quarkusio:master Jan 22, 2021
@ghost ghost added this to the 1.12 - master milestone Jan 22, 2021
Copy link
Contributor

@mkouba mkouba left a 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);
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

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...

Copy link
Contributor

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
Copy link
Contributor

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...

@mkouba
Copy link
Contributor

mkouba commented Jan 22, 2021

@geoand ah, late to the party ;-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants