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

MP Health test development #87

Merged
merged 1 commit into from
Dec 13, 2019
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
5 changes: 5 additions & 0 deletions microprofile-health/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>tooling-server-configuration</artifactId>
<groupId>org.jboss.eap.qe</groupId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
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.health.tools.HealthUrlProvider;
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;
Expand All @@ -22,39 +22,38 @@

@RunAsClient
@RunWith(Arquillian.class)
public class MicroProfileHealthDeprecatedTest {

@ContainerResource
ManagementClient managementClient;
public class HealthDeprecatedTest {

@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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
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.health.tools.HealthUrlProvider;
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;
Expand All @@ -21,32 +21,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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,56 @@
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.health.tools.HealthUrlProvider;
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;

import io.restassured.http.ContentType;

@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 checks exposed under {@code /health} endpoint contain 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 checks exposed under {@code /health/live} endpoint contain 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"),
Expand All @@ -74,9 +71,15 @@ public void testLivenessEndpoint() {
"checks.data[0..1].key", hasItems("value"));
}

/**
* @tpTestDetails Customer scenario where readiness checks exposed under {@code /health/ready} endpoint contain 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"),
Expand Down
Loading