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

[9.x] Fix dev-watch tests server shutdown #399

Open
wants to merge 4 commits into
base: 9.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ jobs:
path: |
!**/bootable-jar-build-artifacts/**
**/dev-watch-test-output.txt
- uses: actions/upload-artifact@v2
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,7 @@ private void shutdownContainer() {
ServerHelper.shutdownStandalone(client, 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}
Expand Down
Loading