[9.x] Fix dev-watch tests server shutdown #399
Merged
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.
It has been reported failing test execution on Windows of some DevWatch test. Although the test is passing, the test fails when shutting down the server.
I also updated the DevWatchTestCase to remove another instability.
I suspect the server process shutdown hook to not be run on Windows. We have 2 shutdown in //, with one of the two receiving an exception when sending :shutdown , this exception causes abrupt termination of the server process (On Windows it seems not yet fixed (very old but seems still the case: https://bugs.openjdk.org/browse/JDK-8056139) that in turn will not run its shutdown hooks: https://github.com/wildfly-extras/wildfly-jar-maven-plugin/blob/main/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchBootableJarMojo.java#L1301)
If the test was not calling a shutdown of the server in // with the DevWatchGoal shutdown, I suspect that we shouldn't observe the issue.
If a failure occurs, calling process.destroy is the right thing to do. We want the process to end, in Dev Mode having the installation directory to be deleted is needed but is not that strict. We should add a WARN trace. I logged:
#398
We have 4 processes:
In the Test process:
When the test is done.
First shutdown the server asynchronously (:shutdown)
Then write a file to have the mvn process to exit
Then wait 60 seconds for the mvn process to exit
If after 60secs it has not exited, fail the test ==> What we observe
In the mvn process:
The process has detected that it needs to exit (presence of the file)
It exists
Shutdown hook to shutdown the server is run
If an exception is thrown when calling server :shutdown (perhaps because of the shutdown, initiated by the test), process.destroy is called (https://github.com/wildfly-extras/wildfly-jar-maven-plugin/blob/main/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchBootableJarMojo.java#L1301)
On Windows process.destroy will make the process to exit without giving time to the shutdown hook to run.
Then it wait 60secs for the server to delete the installation (based on a marker file). ==> We observe that it waited and the server dir was not deleted
In the server process:
When shutdown is received, shutdown hook are run and cleanup of the server installation is fired in a new process (Only on windows due to file lock)
In the cleanup process:
Clean the file and exit
This one seems not started.