From db3f2040ce478eebbe5fc47d8a27f2282b9f6a64 Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Fri, 21 Jun 2024 17:54:10 +0200 Subject: [PATCH 1/4] Remove the shutdown operation sent by test that seems to cause instability on Windows platform (due to process.destroy different behavior) --- .../bootablejar/maven/goals/AbstractDevWatchTestCase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractDevWatchTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractDevWatchTestCase.java index 21c12266..1eb0c35a 100644 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractDevWatchTestCase.java +++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractDevWatchTestCase.java @@ -154,7 +154,8 @@ public void run() { @Override public void shutdownServer() throws Exception { - super.shutdownServerAsync(); + // Do not initiate shutdown, when the mvn process will exit, shutdown hook will shutdown any running server + //super.shutdownServerAsync(); if (process != null) { if (retCode != null) { From ebaa84c9a0a7f823c773e4da8099d6b6f96c2b73 Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Fri, 21 Jun 2024 14:53:20 +0200 Subject: [PATCH 2/4] DevWatch goal, add a warn trace when exception occurs on shutdown --- .../plugins/bootablejar/maven/goals/DevWatchBootableJarMojo.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchBootableJarMojo.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchBootableJarMojo.java index e7e815bb..6148de57 100644 --- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchBootableJarMojo.java +++ b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchBootableJarMojo.java @@ -1299,6 +1299,7 @@ private void shutdownContainer() { ServerManager.builder().client(client).process(process).standalone().shutdown(timeout); } catch (Throwable ignore) { process.destroy(); + getLog().warn("Server process has been destroyed due to raised exception when shutting down the server. Exception: " + ignore); } try { if (!process.waitFor(timeout, TimeUnit.SECONDS)) { From d1d8665e21f97e1030a98fd9b7d68b15d47983d5 Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Fri, 21 Jun 2024 15:58:58 +0200 Subject: [PATCH 3/4] Add traces in test and uploaded more content in CI for diagnosis --- .github/workflows/ci.yml | 8 ++++++++ .../wildfly/plugins/demo/jaxrs/HelloWorldEndpoint.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c66de01..1951ac38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,14 @@ jobs: !**/bootable-jar-build-artifacts/** **/dev-watch-test-output.txt - uses: actions/upload-artifact@v4 + if: failure() + with: + name: project-src-${{ matrix.os }}-${{ matrix.java }} + path: | + !**/bootable-jar-build-artifacts/** + **/tests/target/devwatch*/src/** + **/tests/target/devwatch*/target/deployments/** + - uses: actions/upload-artifact@v2 if: failure() with: name: logs-${{ matrix.os }}-${{ matrix.java }} diff --git a/tests/src/test/resources/projects/jaxrs/src/main/java/org/wildfly/plugins/demo/jaxrs/HelloWorldEndpoint.java b/tests/src/test/resources/projects/jaxrs/src/main/java/org/wildfly/plugins/demo/jaxrs/HelloWorldEndpoint.java index a1c8509b..4bca10f7 100644 --- a/tests/src/test/resources/projects/jaxrs/src/main/java/org/wildfly/plugins/demo/jaxrs/HelloWorldEndpoint.java +++ b/tests/src/test/resources/projects/jaxrs/src/main/java/org/wildfly/plugins/demo/jaxrs/HelloWorldEndpoint.java @@ -20,6 +20,7 @@ public Response doGet() throws IOException { props = new Properties(); props.load(inputStream); } + System.out.println("CLASSLOADER " + HelloWorldEndpoint.class.getClassLoader()); InputStream inputStream2 = HelloWorldEndpoint.class.getResourceAsStream("/myresources2.properties"); Properties props2 = null; if (inputStream2 != null) { @@ -30,7 +31,9 @@ public Response doGet() throws IOException { inputStream2.close(); } } - + for(String k : props.stringPropertyNames()) { + System.out.println("KEY " + k + "=" + props.getProperty(k)); + } //return Response.ok("Hello from " + "XXXWildFly bootable jar!").build(); return Response.ok("Hello from " + props.getProperty("msg") + (props2 == null ? "" : " " + props2.getProperty("msg"))).build(); } From 3daaa104cdffa4501df3d131440857c3bfcc2fb4 Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Fri, 21 Jun 2024 17:37:03 +0200 Subject: [PATCH 4/4] Simplify DevWatchTest to avoid random windows failure --- .../bootablejar/maven/goals/DevWatchTestCase.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchTestCase.java index 88f05a57..fcb9e2e6 100644 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchTestCase.java +++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchTestCase.java @@ -92,14 +92,24 @@ public void testDevWatchWeb() throws Exception { assertTrue(pollBodyContent(url, expectedNewContent)); Thread.sleep(3000); - // Update Java file and check that previous resources update is reflected + // In some very rare cases we got an empty resource file in the expoded deployment. + // Allthough in the previous check the resource file has been tested to be updated. + // This is a cause of test instability that we are removing with a simpler use-case, make a change to the resource file + // to force again having it updated. + // Update Java file and check that resources update is reflected + String testMsg2 = " The test2!"; + props.setProperty("msg", testMsg2); + try (FileOutputStream output = new FileOutputStream(resourcesFile.toFile())) { + props.store(output, null); + } + Thread.sleep(3000); javaFile = getTestDir().resolve("src").resolve("main").resolve("java"). resolve("org").resolve("wildfly").resolve("plugins").resolve("demo").resolve("jaxrs").resolve("HelloWorldEndpoint.java"); str = new String(Files.readAllBytes(javaFile), "UTF-8"); radical = "Hi guys "; patchedRadical = "FOOFOO "; str = str.replace(radical, patchedRadical); - expectedNewContent = patchedRadical + testMsg; + expectedNewContent = patchedRadical + testMsg2; Files.write(javaFile, str.getBytes()); assertTrue(pollBodyContent(url, expectedNewContent));