diff --git a/microprofile-health/pom.xml b/microprofile-health/pom.xml index 0750d43d..d5658f7c 100644 --- a/microprofile-health/pom.xml +++ b/microprofile-health/pom.xml @@ -39,5 +39,10 @@ wildfly-arquillian-container-managed test + + tooling-server-configuration + org.jboss.eap.qe + ${project.version} + \ No newline at end of file diff --git a/microprofile-health/src/main/java/org/jboss/eap/qe/microprofile/health/SimplifiedHealthCheck.java b/microprofile-health/src/main/java/org/jboss/eap/qe/microprofile/health/SimplifiedHealthCheck.java new file mode 100644 index 00000000..2f062789 --- /dev/null +++ b/microprofile-health/src/main/java/org/jboss/eap/qe/microprofile/health/SimplifiedHealthCheck.java @@ -0,0 +1,15 @@ +package org.jboss.eap.qe.microprofile.health; + +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; +import org.eclipse.microprofile.health.Liveness; +import org.eclipse.microprofile.health.Readiness; + +@Liveness +@Readiness +public class SimplifiedHealthCheck implements HealthCheck { + @Override + public HealthCheckResponse call() { + return HealthCheckResponse.up("simplified"); + } +} diff --git a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealthDeprecatedTest.java b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthDeprecatedTest.java similarity index 74% rename from microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealthDeprecatedTest.java rename to microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthDeprecatedTest.java index fc8bee52..3b62d1d6 100644 --- a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealthDeprecatedTest.java +++ b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthDeprecatedTest.java @@ -11,6 +11,7 @@ import org.jboss.arquillian.junit.Arquillian; import org.jboss.as.arquillian.api.ContainerResource; import org.jboss.as.arquillian.container.ManagementClient; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; @@ -22,39 +23,41 @@ @RunAsClient @RunWith(Arquillian.class) -public class MicroProfileHealthDeprecatedTest { +public class HealthDeprecatedTest { @ContainerResource ManagementClient managementClient; @Deployment(testable = false) public static Archive deployment() { - WebArchive war = ShrinkWrap.create(WebArchive.class, "MicroProfileHealthDeprecatedTest.war") + return ShrinkWrap.create(WebArchive.class, HealthDeprecatedTest.class.getSimpleName() + ".war") .addClasses(DeprecatedHealthCheck.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); - return war; } + /** + * @tpTestDetails backward compatibility scenario - test for deprecated however still supported annotation {@code @Health}. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ @Test - public void testDeprecatedHealthCheck() { - final String healthURL = "http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort() - + "/health"; + public void testDeprecatedHealthAnnotation() throws ConfigurationException { - get(healthURL).then() + get(HealthUrlProvider.healthEndpoint()).then() .contentType(ContentType.JSON) .header("Content-Type", containsString("application/json")) .body("status", is("UP"), "checks.status", containsInAnyOrder("UP"), "checks.name", containsInAnyOrder("deprecated-health")); - get(healthURL + "/live").then() + get(HealthUrlProvider.liveEndpoint()).then() .contentType(ContentType.JSON) .header("Content-Type", containsString("application/json")) .body("status", is("UP"), "checks.status", is(empty()), "checks.name", is(empty())); - get(healthURL + "/ready").then() + get(HealthUrlProvider.readyEndpoint()).then() .contentType(ContentType.JSON) .header("Content-Type", containsString("application/json")) .body("status", is("UP"), diff --git a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealthNullTest.java b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthNullTest.java similarity index 70% rename from microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealthNullTest.java rename to microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthNullTest.java index 80ce941b..03c4e9b5 100644 --- a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealthNullTest.java +++ b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthNullTest.java @@ -8,8 +8,7 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; -import org.jboss.as.arquillian.api.ContainerResource; -import org.jboss.as.arquillian.container.ManagementClient; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; @@ -21,32 +20,30 @@ @RunAsClient @RunWith(Arquillian.class) -public class MicroProfileHealthNullTest { - - @ContainerResource - ManagementClient managementClient; +public class HealthNullTest { @Deployment(testable = false) public static Archive deployment() { - WebArchive war = ShrinkWrap.create(WebArchive.class, "MicroProfileHealthNullTest.war") + return ShrinkWrap.create(WebArchive.class, HealthNullTest.class.getSimpleName() + ".war") .addClasses(NullLivenessHealthCheck.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); - return war; } + /** + * @tpTestDetails Negative scenario - health check returns null. + * @tpPassCrit Overall and the health check status is down. + * @tpSince EAP 7.4.0.CD19 + */ @Test - public void testDeprecatedHealthCheck() { - final String healthURL = "http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort() - + "/health"; - - get(healthURL).then() + public void testNullHealthCheck() throws ConfigurationException { + get(HealthUrlProvider.healthEndpoint()).then() .contentType(ContentType.JSON) .header("Content-Type", containsString("application/json")) .body("status", is("DOWN"), "checks.status", contains("DOWN"), "checks.name", contains(NullLivenessHealthCheck.class.getCanonicalName())); - get(healthURL + "/live").then() + get(HealthUrlProvider.liveEndpoint()).then() .contentType(ContentType.JSON) .header("Content-Type", containsString("application/json")) .body("status", is("DOWN")); diff --git a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealth21Test.java b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthTest.java similarity index 59% rename from microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealth21Test.java rename to microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthTest.java index 7d3bbc05..b9b01cc4 100644 --- a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MicroProfileHealth21Test.java +++ b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthTest.java @@ -11,13 +11,11 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; -import org.jboss.as.arquillian.api.ContainerResource; -import org.jboss.as.arquillian.container.ManagementClient; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -25,45 +23,43 @@ @RunAsClient @RunWith(Arquillian.class) -public class MicroProfileHealth21Test { - - @ContainerResource - ManagementClient managementClient; - - String healthURL; - - @Before - public void composeHealthEndpointURL() { - healthURL = "http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort() + "/health"; - } +public class HealthTest { @Deployment(testable = false) public static Archive deployment() { - WebArchive war = ShrinkWrap.create(WebArchive.class, "MicroProfileHealth21Test.war") - .addClasses(DeprecatedHealthCheck.class, BothHealthCheck.class, LivenessHealthCheck.class, - ReadinessHealthCheck.class) + return ShrinkWrap.create(WebArchive.class, HealthTest.class.getSimpleName() + ".war") + .addClasses(BothHealthCheck.class, LivenessHealthCheck.class, ReadinessHealthCheck.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); - return war; } + /** + * @tpTestDetails Customer scenario where health check contains customer data. + * @tpPassCrit Overall and the health check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ @Test - public void testHealthEndpoint() { - get(healthURL).then() + public void testHealthEndpoint() throws ConfigurationException { + get(HealthUrlProvider.healthEndpoint()).then() .contentType(ContentType.JSON) .header("Content-Type", containsString("application/json")) .body("status", is("UP"), - "checks", hasSize(5), // BothHealthCheck contains both annotations: @Liveness and @Readiness + "checks", hasSize(4), // BothHealthCheck contains both annotations: @Liveness and @Readiness "checks.status", hasItems("UP"), "checks.status", not(hasItems("DOWN")), - "checks.name", containsInAnyOrder("deprecated-health", "both", "live", "ready", "both"), - "checks.data", hasSize(5), + "checks.name", containsInAnyOrder("both", "live", "ready", "both"), + "checks.data", hasSize(4), "checks.data[0].key", is("value"), - "checks.data[0..4].key", hasItems("value")); + "checks.data[0..3].key", hasItems("value")); } + /** + * @tpTestDetails Customer scenario where liveness check contains customer data. + * @tpPassCrit Overall and the liveness check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ @Test - public void testLivenessEndpoint() { - get(healthURL + "/live").then() + public void testLivenessEndpoint() throws ConfigurationException { + get(HealthUrlProvider.liveEndpoint()).then() .contentType(ContentType.JSON) .header("Content-Type", containsString("application/json")) .body("status", is("UP"), @@ -74,9 +70,14 @@ public void testLivenessEndpoint() { "checks.data[0..1].key", hasItems("value")); } + /** + * @tpTestDetails Customer scenario where readiness check contains customer data. + * @tpPassCrit Overall and the readiness check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ @Test - public void testReadinessEndpoint() { - get(healthURL + "/ready").then() + public void testReadinessEndpoint() throws ConfigurationException { + get(HealthUrlProvider.readyEndpoint()).then() .contentType(ContentType.JSON) .header("Content-Type", containsString("application/json")) .body("status", is("UP"), diff --git a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthUrlProvider.java b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthUrlProvider.java new file mode 100644 index 00000000..3ad2521d --- /dev/null +++ b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/HealthUrlProvider.java @@ -0,0 +1,27 @@ +package org.jboss.eap.qe.microprofile.health; + +import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.arquillian.ArquillianContainerProperties; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.arquillian.ArquillianDescriptorWrapper; + +public class HealthUrlProvider { + public static String healthEndpoint() throws ConfigurationException { + ArquillianContainerProperties arqProps = new ArquillianContainerProperties( + ArquillianDescriptorWrapper.getArquillianDescriptor()); + return "http://" + arqProps.getDefaultManagementAddress() + ":" + arqProps.getDefaultManagementPort() + "/health"; + } + + public static String liveEndpoint() throws ConfigurationException { + ArquillianContainerProperties arqProps = new ArquillianContainerProperties( + ArquillianDescriptorWrapper.getArquillianDescriptor()); + return "http://" + arqProps.getDefaultManagementAddress() + ":" + arqProps.getDefaultManagementPort() + + "/health/live"; + } + + public static String readyEndpoint() throws ConfigurationException { + ArquillianContainerProperties arqProps = new ArquillianContainerProperties( + ArquillianDescriptorWrapper.getArquillianDescriptor()); + return "http://" + arqProps.getDefaultManagementAddress() + ":" + arqProps.getDefaultManagementPort() + + "/health/ready"; + } +} diff --git a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MimeTypeHealthTest.java b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MimeTypeHealthTest.java new file mode 100644 index 00000000..d165a4b8 --- /dev/null +++ b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MimeTypeHealthTest.java @@ -0,0 +1,162 @@ +package org.jboss.eap.qe.microprofile.health; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import io.restassured.http.ContentType; + +@RunAsClient +@RunWith(Arquillian.class) +public class MimeTypeHealthTest { + + @Deployment(testable = false) + public static Archive deployment() { + return ShrinkWrap.create(WebArchive.class, MimeTypeHealthTest.class.getSimpleName() + ".war") + .addClasses(BothHealthCheck.class, LivenessHealthCheck.class, ReadinessHealthCheck.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + /** + * @tpTestDetails Negative scenario where health check contains customer data. + * HTTP GET request to /health, /health/live and /health/ready endpoints accepts invalid MIME type - + * application/x-json. MP Health should not care about requested MIME type and always produce JSON. + * @tpPassCrit Overall and the health check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testHealthXJSON() throws ConfigurationException { + test("application/x-json"); + } + + /** + * @tpTestDetails Negative scenario where health check contains customer data. + * HTTP GET request to /health, /health/live and /health/ready endpoints accepts invalid MIME type - + * application/json-p. MP Health should not care about requested MIME type and always produce JSON. + * @tpPassCrit Overall and the health check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testHealthJSONP() throws ConfigurationException { + test("application/json-p"); + } + + /** + * @tpTestDetails Negative scenario where health check contains customer data. + * HTTP GET request to /health, /health/live and /health/ready endpoints accepts invalid MIME type - + * text/plain. MP Health should not care about requested MIME type and always produce JSON. + * @tpPassCrit Overall and the health check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testHealtTextPlain() throws ConfigurationException { + test("text/plain"); + } + + /** + * @tpTestDetails Negative scenario where health check contains customer data. + * HTTP GET request to /health, /health/live and /health/ready endpoints accepts invalid MIME type - + * text/csv. MP Health should not care about requested MIME type and always produce JSON. + * @tpPassCrit Overall and the health check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testHealtTextCSV() throws ConfigurationException { + test("text/csv"); + } + + /** + * @tpTestDetails Negative scenario where health check contains customer data. + * HTTP GET request to /health, /health/live and /health/ready endpoints accepts invalid MIME type - + * model/vml. MP Health should not care about requested MIME type and always produce JSON. + * @tpPassCrit Overall and the health check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testHealtModelVML() throws ConfigurationException { + test("model/vml"); + } + + /** + * @tpTestDetails Negative scenario where health check contains customer data. + * HTTP GET request to /health, /health/live and /health/ready endpoints accepts invalid MIME type - + * text/json. MP Health should not care about requested MIME type and always produce JSON. + * @tpPassCrit Overall and the health check status is up and checks contains expected data. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testHealtTextJSON() throws ConfigurationException { + test("text/json"); + } + + private void test(String mimeType) throws ConfigurationException { + testHealthEndpoint(mimeType); + testLiveEndpoint(mimeType); + testReadyEndpoint(mimeType); + } + + private void testHealthEndpoint(String mimeType) throws ConfigurationException { + given() + .baseUri(HealthUrlProvider.healthEndpoint()) + .accept(mimeType) + .get() + .then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(4), // BothHealthCheck contains both annotations: @Liveness and @Readiness + "checks.status", hasItems("UP"), + "checks.status", not(hasItems("DOWN")), + "checks.name", containsInAnyOrder("both", "live", "ready", "both"), + "checks.data", hasSize(4), + "checks.data[0].key", is("value"), + "checks.data[0..3].key", hasItems("value")); + } + + private void testLiveEndpoint(String mimeType) throws ConfigurationException { + given() + .baseUri(HealthUrlProvider.liveEndpoint()) + .accept(mimeType) + .get() + .then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(2), + "checks.status", hasItems("UP"), + "checks.name", containsInAnyOrder("both", "live"), + "checks.data", hasSize(2), + "checks.data[0..1].key", hasItems("value")); + } + + private void testReadyEndpoint(String mimeType) throws ConfigurationException { + given() + .baseUri(HealthUrlProvider.readyEndpoint()) + .accept(mimeType) + .get() + .then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(2), + "checks.status", hasItems("UP"), + "checks.name", containsInAnyOrder("both", "ready"), + "checks.data", hasSize(2), + "checks.data[0..1].key", hasItems("value")); + } +} diff --git a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MultiDeploymentHealthTest.java b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MultiDeploymentHealthTest.java new file mode 100644 index 00000000..0343dc05 --- /dev/null +++ b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MultiDeploymentHealthTest.java @@ -0,0 +1,92 @@ +package org.jboss.eap.qe.microprofile.health; + +import static io.restassured.RestAssured.get; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import io.restassured.http.ContentType; + +/** + * Multiple deployment scenario. + */ +@RunWith(Arquillian.class) +public class MultiDeploymentHealthTest { + + @Deployment(name = "deployment1", order = 1, testable = false) + public static Archive deployment1() { + return ShrinkWrap.create(WebArchive.class, MultiDeploymentHealthTest.class.getSimpleName() + "-1.war") + .addClasses(SimplifiedHealthCheck.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Deployment(name = "deployment2", order = 2, testable = false) + public static Archive deployment2() { + return ShrinkWrap.create(WebArchive.class, MultiDeploymentHealthTest.class.getSimpleName() + "-2.war") + .addClasses(LivenessHealthCheck.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + /** + * @tpTestDetails Customer multi-deployment scenario. HealthChecks from more deployments are registered and exposed. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + @RunAsClient + public void testHealthEndpoint() throws ConfigurationException { + get(HealthUrlProvider.healthEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(3), + "checks.status", hasItems("UP"), + "checks.status", not(hasItems("DOWN"))); + } + + /** + * @tpTestDetails Customer multi-deployment scenario. HealthChecks from more deployments are registered and exposed. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + @RunAsClient + public void testLivenessEndpoint() throws ConfigurationException { + get(HealthUrlProvider.liveEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(2), + "checks.status", hasItems("UP")); + } + + /** + * @tpTestDetails Customer multi-deployment scenario. HealthChecks from more deployments are registered and exposed. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + @RunAsClient + public void testReadinessEndpoint() throws ConfigurationException { + get(HealthUrlProvider.readyEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(1), + "checks.status", hasItems("UP")); + } + +} diff --git a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/SimplifiedHealthTest.java b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/SimplifiedHealthTest.java new file mode 100644 index 00000000..b34eb598 --- /dev/null +++ b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/SimplifiedHealthTest.java @@ -0,0 +1,83 @@ +package org.jboss.eap.qe.microprofile.health; + +import static io.restassured.RestAssured.get; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import io.restassured.http.ContentType; + +@RunAsClient +@RunWith(Arquillian.class) +public class SimplifiedHealthTest { + + @Deployment(testable = false) + public static Archive deployment() { + return ShrinkWrap.create(WebArchive.class, SimplifiedHealthTest.class + ".war") + .addClasses(SimplifiedHealthCheck.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + /** + * @tpTestDetails Smoke test for new api. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testHealthEndpoint() throws ConfigurationException { + get(HealthUrlProvider.healthEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(2), // SimplifiedHealthCheck contains both annotations: @Liveness and @Readiness + "checks.status", hasItems("UP"), + "checks.status", not(hasItems("DOWN")), + "checks.name", containsInAnyOrder("simplified", "simplified")); + } + + /** + * @tpTestDetails Smoke test for new api. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testLivenessEndpoint() throws ConfigurationException { + get(HealthUrlProvider.liveEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(1), + "checks.status", hasItems("UP"), + "checks.name", containsInAnyOrder("simplified")); + } + + /** + * @tpTestDetails Smoke test for new api. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + public void testReadinessEndpoint() throws ConfigurationException { + get(HealthUrlProvider.readyEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(1), + "checks.status", hasItems("UP"), + "checks.name", containsInAnyOrder("simplified")); + } +} diff --git a/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/SubdeploymentHealthTest.java b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/SubdeploymentHealthTest.java new file mode 100644 index 00000000..4aae119f --- /dev/null +++ b/microprofile-health/src/test/java/org/jboss/eap/qe/microprofile/health/SubdeploymentHealthTest.java @@ -0,0 +1,116 @@ +package org.jboss.eap.qe.microprofile.health; + +import static io.restassured.RestAssured.get; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +import io.restassured.http.ContentType; + +/** + * Deployment with sub-deployments scenario. + */ +@Ignore("https://issues.redhat.com/browse/WFLY-12835") +@RunWith(Arquillian.class) +public class SubdeploymentHealthTest { + + @Deployment + public static EnterpriseArchive createDeployment() { + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, + SubdeploymentHealthTest.class.getSimpleName() + ".ear"); + + ear.addAsModule(ShrinkWrap.create(WebArchive.class, "dep1.war") + .addClasses(SimplifiedHealthCheck.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")); + + ear.addAsModule(ShrinkWrap.create(JavaArchive.class, "dep2.jar") + .addClasses(LivenessHealthCheck.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")); + + ear.setApplicationXML(new StringAsset("\n" + + "\n" + + " metrics\n" + + " \n" + + " \n" + + " dep1.war\n" + + " /dep\n" + + " \n" + + " \n" + + " \n" + + " dep2.jar\n" + + " \n" + + "")); + + return ear; + } + + /** + * @tpTestDetails Customer deployment with sub-deployment scenario. HealthChecks from more sub-deployments are registered + * and exposed. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + @RunAsClient + public void testHealthEndpoint() throws ConfigurationException { + get(HealthUrlProvider.healthEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(3), + "checks.status", hasItems("UP"), + "checks.status", not(hasItems("DOWN"))); + } + + /** + * @tpTestDetails Customer deployment with sub-deployment scenario. HealthChecks from more sub-deployments are registered + * and exposed. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + @RunAsClient + public void testLivenessEndpoint() throws ConfigurationException { + get(HealthUrlProvider.liveEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(2), + "checks.status", hasItems("UP")); + } + + /** + * @tpTestDetails Customer deployment with sub-deployment scenario. HealthChecks from more sub-deployments are registered + * and exposed. + * @tpPassCrit Overall and the health check status is up. + * @tpSince EAP 7.4.0.CD19 + */ + @Test + @RunAsClient + public void testReadinessEndpoint() throws ConfigurationException { + get(HealthUrlProvider.readyEndpoint()).then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("application/json")) + .body("status", is("UP"), + "checks", hasSize(1), + "checks.status", hasItems("UP")); + } + +} diff --git a/pom.xml b/pom.xml index e50797af..a019acbf 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ 3.0.1 4.12 1.3.2 - 3.0 + 3.2 1.5.0.Final 18.0.0.Final 2.2.0.Final