Quarkus: Add tests for the startup log output

Created on 11 Apr 2019  路  14Comments  路  Source: quarkusio/quarkus

It got broken numerous times either in dev mode or java mode.

We need to add tests for that. And soon.

@cescoffier said the easiest would be to add tests in the Maven tests. But we also need to test the output of java -jar my-runner.jar

arelogging good first issue

All 14 comments

That should be possible to implement at the same place:

  1. Use the maven invoker to do mvn package
  2. Use the Java executor (do we have it already?) to do java -jar ...
  1. Use the maven invoker to do mvn package

@cescoffier, won't the first option collide with this issue 1909?

I think he was talking about the Maven invoker API, not the invoker plugin.

Use the Java executor (do we have it already?) to do java -jar ...

@cescoffier what is the Java executor? This issue seems kind of related to what I'm up to in #1986...

It should be trivial to assert (logging) output from running the JAR (and the Native) there.

/Cc @stalep

FYI #1986 now proposes a new QuarkusJavaLauncher which should come in handy for this.

@machi1990 were you interested by this one? It became pretty critical considering the number of times we broke the output.

I think for now we should stick to the standard APIs, we can still revisit later once we have the structure of the tests.

@gsmet I started to check this, I run mvn package and then run java -jar but i have a problem with the ProcessBuilder API running java commands. Seems like it cannot find the java bin. Any ideas?

Otherwise my idea is to redirect the output in a log file and then check if it contains coloured output. See 60fc188a143f

Did you use something like System.getProperty("java.home") + "/bin/java" to get the Java home? (obviously, it needs to be made portable for Windows with proper separator char and java.exe).

So we should check it contains coloured output but we should also check that:

  • it contains the list of features
  • it does not contain JBoss Threads version

@machi1990 ^

Did you use something like System.getProperty("java.home") + "/bin/java" to get the Java home? (obviously, it needs to be made portable for Windows with proper separator char and java.exe).

I tried something like that but had the same error after stealing some piece of code from QuarkusDev.java but had the same error. I'll investigate more tomorrow.

So we should check it contains coloured output but we should also check that:

  • it contains the list of features
  • it does not contain JBoss Threads version

Once I got the process running I'll check this checks which seem appropriate.

@gsmet @machi1990 have you seen that in #1986 I am a QuarkusJavaLauncher for this purpose?

@vorburger thanks for the pointer. I managed to launch the bin after properly finding the java executable. Since your work on QuarkusJavaLauncher.java is not already in the master, I decided to use some piece of code that was already in QaurkusDev.java.

@gsmet @cescoffier @dmlloyd , any pointer on how to test for coloured output? here is where I wish to add it.

Testing to ensure that java.util.logging.LogManager.getLogManager() is an instance of org.jboss.logmanager.LogManager would get you most of the way there.

Theoretically you could probe the fields of the console handler to see if it has decided to output in color or not. But that seems less important since 99% of the cases where color output is lost are due to losing the entire log manager (and thus formatting, log level filtering, etc.).

@dmlloyd thanks for the detailed response.

I finally decided to leave aside testing for coloured output and instead focus on formatting, log level, installed features etc PR #2116.

Was this page helpful?
0 / 5 - 0 ratings