Issue #838 Implement extension point to run diagnosis tools when forked JVM times out#3372
Open
olamy wants to merge 8 commits into
Open
Issue #838 Implement extension point to run diagnosis tools when forked JVM times out#3372olamy wants to merge 8 commits into
olamy wants to merge 8 commits into
Conversation
…ed JVM times out Signed-off-by: Olivier Lamy <olamy@apache.org>
There was a problem hiding this comment.
Pull request overview
Adds a new Surefire/Failsafe extension point that lets plugins/extensions run diagnostic tooling when a forked test JVM hits forkedProcessTimeoutInSeconds, including a built-in (opt-in) jstack implementation plus ITs and site documentation.
Changes:
- Introduce
ForkedProcessTimeoutExtensionSPI +ForkedProcessTimeoutContextAPI and wire it into the fork timeout/kill path. - Add plugin-side dispatcher/context implementation and a built-in
JstackTimeoutExtension(disabled by default, configurable via a context map). - Add unit tests, an integration test (SUREFIRE-838), and new site docs/menus for the feature.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| surefire-its/src/test/resources/surefire-838-timeout-extension/src/test/java/surefire838/SleepingTest.java | Adds a hanging test used to trigger fork timeout in the IT project. |
| surefire-its/src/test/resources/surefire-838-timeout-extension/pom.xml | Consumer IT POM enabling timeout + configuring extension context keys and adding the extension dependency. |
| surefire-its/src/test/resources/surefire-838-timeout-extension-ext/src/main/resources/META-INF/services/org.apache.maven.surefire.extensions.ForkedProcessTimeoutExtension | Registers the IT extension implementation via ServiceLoader. |
| surefire-its/src/test/resources/surefire-838-timeout-extension-ext/src/main/java/org/apache/maven/surefire/its/extension/MarkerTimeoutExtension.java | Test extension that writes marker files when timeout/exited callbacks fire. |
| surefire-its/src/test/resources/surefire-838-timeout-extension-ext/pom.xml | Builds the IT extension JAR against the new extensions API. |
| surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire838TimeoutExtensionIT.java | Integration test asserting the timeout extension callbacks (and best-effort jstack dump) occur. |
| surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineExecutor.java | Exposes the underlying Process so the fork PID can be queried. |
| surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/ForkedProcessTimeoutExtension.java | New SPI interface invoked on fork timeout and fork exit. |
| surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/ForkedProcessTimeoutContext.java | New context interface carrying fork diagnostics + extension configuration map. |
| surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java | Adds pidOf(Process) (Java 9+ reflective Process.pid()) to support PID reporting. |
| pom.xml | Updates RAT excludes for the new ServiceLoader file in main resources. |
| maven-surefire-plugin/src/site/site.xml | Adds site menu entries for the timeout extension docs. |
| maven-surefire-plugin/src/site/markdown/timeout-extension-guide.md | New detailed guide for enabling built-in jstack and authoring extensions. |
| maven-surefire-plugin/src/site/markdown/examples/timeout-extension.md | New concise example/reference page for the timeout extension SPI. |
| maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/timeout/TimeoutExtensionDispatcherTest.java | Unit tests for dispatcher behavior (fan-out, exception isolation, context propagation, bounded execution). |
| maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/timeout/JstackTimeoutExtensionTest.java | Unit tests for built-in jstack extension enablement and output-location behavior. |
| maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClientTest.java | Adds a test ensuring timeout listener fires once and before KILL is sent. |
| maven-surefire-common/src/main/resources/META-INF/services/org.apache.maven.surefire.extensions.ForkedProcessTimeoutExtension | Registers the built-in JstackTimeoutExtension via ServiceLoader. |
| maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/timeout/TimeoutExtensionDispatcher.java | New plugin-side ServiceLoader discovery + bounded callback execution. |
| maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/timeout/JstackTimeoutExtension.java | Built-in (opt-in) implementation that captures a jstack dump on timeout. |
| maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/timeout/DefaultForkedProcessTimeoutContext.java | Default immutable context implementation for extensions. |
| maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java | Adds a one-shot “timeout detected” listener invoked immediately before sending KILL. |
| maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java | Wires extension dispatch into fork lifecycle (on-timeout-before-kill + after-exit) and passes context/config. |
| maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java | Adds forkedProcessTimeoutExtensionContext parameter and passes it into ForkStarter. |
|
|
||
| @Test | ||
| public void sleepsLongerThanTimeout() throws Exception { | ||
| Thread.sleep(120_000L); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Olivier Lamy olamy@apache.org
Following this checklist to help us incorporate your
contribution quickly and easily:
mvn clean installto make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean install).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.