Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

@Disabled
public class WaitStartupWaitTest {

// this should catch the `Caused by: java.io.IOException: Gave up waiting for server to start after 100ms` exception
Expand All @@ -21,6 +22,5 @@ public class WaitStartupWaitTest {

@Test()
public void waitStartup() {
Assertions.fail("Expected failure to check startup timeout exception");
Copy link
Contributor Author

@fjtirado fjtirado Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion was wrong, causing the test to behave randomly
We want to check that the timeout is properly set, so quarkus should receive the IO (which is guaranted by the setExpectedException) and the test should suceeed, not fail

Copy link
Contributor Author

@fjtirado fjtirado Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disable the test, it is inherently flaky due to the usage of arbitrary timeout. In my local, setting it to 1 ms always worked, but in CI it always failed (effect what I achieve in my local by setting it to 10000ms, which makes sense, there is not exception since the db has time to start and when setting it to 1ms there should be an exception since DB will take more than that to startup)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

import jakarta.inject.Inject;

import io.quarkus.devui.runtime.config.ConfigDescriptionBean;
import io.quarkus.runtime.LaunchMode;
import org.eclipse.microprofile.config.inject.ConfigProperty;

import static io.quarkus.runtime.LaunchMode.DEVELOPMENT;
import io.quarkus.devui.runtime.config.ConfigDescriptionBean;

public class EmbeddedPostgreSQLJsonRpcService {

Expand All @@ -21,25 +19,16 @@ public class EmbeddedPostgreSQLJsonRpcService {
Optional<String> jdbcUrl;

public int getDatasourcePort() {
String port = LaunchMode.current().equals(DEVELOPMENT) && jdbcUrl.isPresent() ? jdbcUrl.get()
: configDescriptionBean.getAllConfig().stream()
String port = jdbcUrl
.orElseGet(() -> configDescriptionBean.getAllConfig().stream()
.filter(c -> c.getName().equalsIgnoreCase("quarkus.datasource.jdbc.url"))
.map(c -> c.getConfigValue().getValue())
.findFirst()
.orElseThrow(() -> new IllegalStateException(
"No JDBC URL found in configuration. Please ensure 'quarkus.datasource.jdbc.url' is set."));

// Define a regex pattern to match numbers
Pattern pattern = Pattern.compile("\\d+");

"No JDBC URL found in configuration. Please ensure 'quarkus.datasource.jdbc.url' is set.")));
// Create a matcher with the input string
Matcher matcher = pattern.matcher(port);

Matcher matcher = Pattern.compile("\\d+").matcher(port);
// Find and print all numbers in the input string
while (matcher.find()) {
String number = matcher.group();
return Integer.parseInt(number);
}
return 0;
return matcher.find() ? Integer.parseInt(matcher.group()) : 0;
}
}