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

Fix a race condition in ReactiveDatasourceHealthCheck data field population #42260

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public HealthCheckResponse call() {
//20 seconds is rather high, but using just 10 is often not enough on slow CI
//systems, especially if the connections have to be established for the first time.
databaseConnectionAttempt.get(20, TimeUnit.SECONDS);
builder.withData(dataSourceName, "UP");
} catch (RuntimeException | ExecutionException exception) {
operationsError(dataSourceName, exception);
builder.down();
Expand Down Expand Up @@ -105,6 +104,8 @@ private void checkFailure(AsyncResult<RowSet<Row>> ar, HealthCheckResponseBuilde
operationsError(dataSourceName, ar.cause());
builder.down();
builder.withData(dataSourceName, "down - connection failed: " + ar.cause().getMessage());
} else {
builder.withData(dataSourceName, "UP");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.reactive.mssql.client;

import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;

public class DataSourceHealthCheckPayloadTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withEmptyApplication()
.overrideConfigKey("quarkus.datasource.health.enabled", "true")
.overrideConfigKey("quarkus.devservices.enabled", "false");

@Test
public void testDataSourceHealthCheckPayload() {
RestAssured.when().get("/q/health/ready")
.then()
.body("status", CoreMatchers.equalTo("DOWN"))
.body("checks.data", CoreMatchers
.hasItem(Matchers.hasValue(CoreMatchers.containsString("down - connection failed"))));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.reactive.mysql.client;

import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;

public class DataSourceHealthCheckPayloadTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withEmptyApplication()
.overrideConfigKey("quarkus.datasource.health.enabled", "true")
.overrideConfigKey("quarkus.devservices.enabled", "false");

@Test
public void testDataSourceHealthCheckPayload() {
RestAssured.when().get("/q/health/ready")
.then()
.body("status", CoreMatchers.equalTo("DOWN"))
.body("checks.data", CoreMatchers
.hasItem(Matchers.hasValue(CoreMatchers.containsString("down - connection failed"))));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.reactive.oracle.client;

import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;

public class DataSourceHealthCheckPayloadTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withEmptyApplication()
.overrideConfigKey("quarkus.datasource.health.enabled", "true")
.overrideConfigKey("quarkus.devservices.enabled", "false");

@Test
public void testDataSourceHealthCheckPayload() {
RestAssured.when().get("/q/health/ready")
.then()
.body("status", CoreMatchers.equalTo("DOWN"))
.body("checks.data", CoreMatchers
.hasItem(Matchers.hasValue(CoreMatchers.containsString("down - connection failed"))));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.reactive.pg.client;

import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;

public class DataSourceHealthCheckPayloadTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withEmptyApplication()
.overrideConfigKey("quarkus.datasource.health.enabled", "true")
.overrideConfigKey("quarkus.devservices.enabled", "false");

@Test
public void testDataSourceHealthCheckPayload() {
RestAssured.when().get("/q/health/ready")
.then()
.body("status", CoreMatchers.equalTo("DOWN"))
.body("checks.data", CoreMatchers
.hasItem(Matchers.hasValue(CoreMatchers.containsString("down - connection failed"))));
}

}
Loading