quarkus: NativeImageTest fails because the LauncherUtil is unable to determine the status of the running process

Describe the bug

After upgrading from Quarkus 1.12 to 1.13 not even a native image smoke test works anymore. When Using the @NativeImageTest the test failes before the first test step is executed. The exceptions says:

java.lang.IllegalStateException: Unable to determine the status of the running process. See the above logs for details
        at io.quarkus.test.common.LauncherUtil.waitForCapturedListeningData(LauncherUtil.java:73)

This is happening (according to LauncherUtil) when the Quarkus Application is not reporting its address within 10 seconds. According to the logs the application started and I can see the address and port like that:

0.0.1 native (powered by Quarkus 1.13.6.Final) started in 0.029s. Listening on: http://0.0.0.0:43529"

Expected behavior

The tests is starting.

Actual behavior

The test is not starting but failing with the described exception.

Output of uname -a or ver

Linux  5.12.2-1-MANJARO #1 SMP PREEMPT Fri May 7 17:53:15 UTC 2021 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

Quarkus version or git rev

1.13.6

Build tool (ie. output of mvnw --version or gradlew --version)

gradle 7.0.2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 84 (58 by maintainers)

Commits related to this issue

Most upvoted comments

This fix will likely be part of 2.2.4, hopefully to come out next week.

I’m building / testing now from main.

Any chance this can end up in a maintenance release on 2.2 soon?

I figured out my problem:

As we use logback and the ELK Stack to write to logs directly to kibana we do not write any log files. Apparently the @QuarkusIntegrationTest triggers a lookup of the host and ports in a log file.

Therefore we now write that logfile during service startup. I attached the code below. I don’t know if the filepath works for you. You may have to alter it to your needings. However we also had to fix the quarkus.http.test-portto a fix value instead of the dynamic 0 value. Because we found no solution how to get the randomly chosen port during runtime and the code would otherwise just write 0 in the file.

Here is the code:

import io.quarkus.runtime.StartupEvent;
import org.eclipse.microprofile.config.ConfigProvider;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import java.io.FileWriter;
import java.io.IOException;
import java.util.NoSuchElementException;


@ApplicationScoped
public class StartupListener {

    void onStart(@Observes StartupEvent ev) {
        try {
            String port = ConfigProvider.getConfig().getValue("quarkus.http.test-port", String.class);
            FileWriter myWriter = new FileWriter("./build/quarkus.log");
            myWriter.write("Listening on: http://localhost:" + port);
            myWriter.close();
        } catch(NoSuchElementException | IOException nse){
            nse.printStackTrace();
        }
    }
}

Please do not blame me on the hackyness of this solution, its not my fault…

I personally I am not looking into it (as the application does not use standard logging - other applications I tried worked just fine), others are obiously free to check

Ah, I hadn’t seen that. I’ll need to check it out

@geoand I will try that with our current project but I think that an update to 2.0.0 will break a couple of other things. If that is the case I will try to create a small reproducer.