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

test(health): check for reports, build info #823

Merged
merged 1 commit into from
Feb 28, 2025
Merged
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
56 changes: 41 additions & 15 deletions src/test/java/itest/HealthIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import io.cryostat.resources.GrafanaResource;
import io.cryostat.resources.JFRDatasourceResource;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusIntegrationTest;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;
Expand All @@ -31,12 +27,9 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

@QuarkusIntegrationTest
@QuarkusTestResource(GrafanaResource.class)
@QuarkusTestResource(JFRDatasourceResource.class)
public class HealthIT extends StandardSelfTest {

JsonObject response;
Expand Down Expand Up @@ -68,25 +61,58 @@ void shouldIncludeApplicationVersion() {
Matchers.matchesRegex("^v[\\d]\\.[\\d]\\.[\\d](?:-snapshot)?"));
}

@Disabled("TODO")
@Test
void shouldHaveAvailableDatasource() {
void shouldIncludeGitHash() {
Assertions.assertTrue(response.containsKey("build"));
Assertions.assertTrue(response.getJsonObject("build").containsKey("git"));
Assertions.assertTrue(
response.getJsonObject("build").getJsonObject("git").containsKey("hash"));
MatcherAssert.assertThat(
response.getJsonObject("build").getJsonObject("git").getString("hash"),
Matchers.not(Matchers.emptyOrNullString()));
MatcherAssert.assertThat(
response.getJsonObject("build").getJsonObject("git").getString("hash"),
Matchers.matchesRegex("^[a-f0-9]+$"));
}

@Test
void shouldHaveConfiguredDatasource() {
Assertions.assertTrue(response.containsKey("datasourceConfigured"));
MatcherAssert.assertThat(
response.getString("datasourceConfigured"), Matchers.equalTo("true"));
Assertions.assertTrue(response.containsKey("datasourceAvailable"));
MatcherAssert.assertThat(
response.getString("datasourceAvailable"), Matchers.equalTo("true"));
}

@Disabled("TODO")
@Test
void shouldHaveAvailableDashboard() {
void shouldHaveConfiguredDashboard() {
Assertions.assertTrue(response.containsKey("dashboardConfigured"));
MatcherAssert.assertThat(
response.getString("dashboardConfigured"), Matchers.equalTo("true"));
}

@Test
void shouldHaveConfigureREports() {
Assertions.assertTrue(response.containsKey("reportsConfigured"));
MatcherAssert.assertThat(
response.getString("reportsConfigured"), Matchers.equalTo("false"));
}

@Test
void shouldHaveAvailableDatasource() {
Assertions.assertTrue(response.containsKey("datasourceAvailable"));
MatcherAssert.assertThat(
response.getString("datasourceAvailable"), Matchers.equalTo("false"));
}

@Test
void shouldHaveAvailableDashboard() {
Assertions.assertTrue(response.containsKey("dashboardAvailable"));
MatcherAssert.assertThat(
response.getString("dashboardAvailable"), Matchers.equalTo("true"));
response.getString("dashboardAvailable"), Matchers.equalTo("false"));
}

@Test
void shouldHaveAvailableREports() {
Assertions.assertTrue(response.containsKey("reportsAvailable"));
MatcherAssert.assertThat(response.getString("reportsAvailable"), Matchers.equalTo("true"));
}
}
Loading