forked from quarkus-qe/quarkus-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now Quarkus can expose endpoints for metrics and health on a separate network interface. We verify, that this is supported, and we can use custom port, switch HTTPS on and off and change api path. This requires supports on the side of the FW and enabling one of the disabled tests. Test plans for the change: https://github.com/quarkus-qe/quarkus-test-plans/blob/main/QUARKUS-2738.md Related links: quarkusio/quarkus#30506 https://issues.redhat.com/browse/QUARKUS-2738
- Loading branch information
Showing
14 changed files
with
296 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkus.ts.qe</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../..</relativePath> | ||
</parent> | ||
<artifactId>http-management</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Quarkus QE TS: HTTP: Management Interface</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-smallrye-health</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-micrometer-registry-prometheus</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-smallrye-openapi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus.qe</groupId> | ||
<artifactId>quarkus-test-openshift</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<profiles> | ||
<profile> | ||
<id>deploy-to-openshift-using-extension</id> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-openshift</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> |
16 changes: 16 additions & 0 deletions
16
http/management/src/main/java/io/quarkus/qe/HttpResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.qe; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("/ping") | ||
public class HttpResource { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String pong() { | ||
return "pong"; | ||
} | ||
} |
Binary file added
BIN
+2.35 KB
http/management/src/main/resources/META-INF/resources/server.keystore
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Only run tests annotated with @QuarkusTest | ||
quarkus.test.type=quarkus-test | ||
quarkus.management.enabled=true |
57 changes: 57 additions & 0 deletions
57
http/management/src/test/java/io/quarkus/qe/LocalEndpointsIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.quarkus.qe; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.junit.jupiter.api.MethodOrderer; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestMethodOrder; | ||
|
||
import io.quarkus.test.bootstrap.RestService; | ||
import io.quarkus.test.scenarios.QuarkusScenario; | ||
import io.quarkus.test.services.QuarkusApplication; | ||
import io.restassured.response.Response; | ||
|
||
@QuarkusScenario | ||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
public class LocalEndpointsIT { | ||
|
||
@QuarkusApplication | ||
static final RestService app = new RestService(); | ||
|
||
@Test | ||
@Order(1) | ||
public void greeting() { | ||
Response response = app.given().get("/ping"); | ||
assertEquals(200, response.statusCode()); | ||
assertEquals("pong", response.body().asString()); | ||
} | ||
|
||
@Test | ||
public void health() { | ||
app.management().get("q/health").then().statusCode(HttpStatus.SC_OK); | ||
} | ||
|
||
@Test | ||
public void oldHealth() { | ||
app.given().get("q/health").then().statusCode(HttpStatus.SC_NOT_FOUND); | ||
} | ||
|
||
@Test | ||
public void metrics() { | ||
Response response = app.management().get("q/metrics"); | ||
assertEquals(200, response.statusCode()); | ||
String metric = null; | ||
String body = response.body().asString(); | ||
for (String line : body.split("\n")) { | ||
if (line.contains("http_server_requests_seconds_count") && line.contains("SUCCESS")) { | ||
metric = line; | ||
} | ||
} | ||
assertNotNull(metric, "Metric 'http_server_requests_seconds_count' was not found in the response: " + body); | ||
assertTrue(metric.endsWith("1.0"), "requests count is wrong: " + metric); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
http/management/src/test/java/io/quarkus/qe/LocalOptionsIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package io.quarkus.qe; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.bootstrap.RestService; | ||
import io.quarkus.test.scenarios.QuarkusScenario; | ||
import io.quarkus.test.services.QuarkusApplication; | ||
import io.restassured.path.json.JsonPath; | ||
import io.restassured.response.Response; | ||
|
||
@QuarkusScenario | ||
public class LocalOptionsIT { | ||
|
||
@QuarkusApplication | ||
static final RestService app = new RestService(); | ||
|
||
@QuarkusApplication | ||
static final RestService custom = new RestService() | ||
.withProperty("quarkus.management.port", "9002"); | ||
|
||
@QuarkusApplication | ||
static final RestService tls = new RestService() | ||
.withProperty("quarkus.management.port", "9003") | ||
.withProperty("quarkus.management.ssl.certificate.key-store-file", "META-INF/resources/server.keystore") | ||
.withProperty("quarkus.management.ssl.certificate.key-store-password", "password"); | ||
|
||
@QuarkusApplication | ||
static final RestService unmanaged = new RestService() | ||
.withProperty("quarkus.management.enabled", "false"); | ||
|
||
@QuarkusApplication | ||
static final RestService redirected = new RestService() | ||
.withProperty("quarkus.management.port", "9004") | ||
.withProperty("quarkus.http.root-path", "/api") | ||
.withProperty("quarkus.http.non-application-root-path", "/query") | ||
.withProperty("quarkus.management.root-path", "management"); | ||
|
||
@Test | ||
public void greeting() { | ||
for (RestService service : Arrays.asList(app, custom, tls, unmanaged)) { | ||
Response response = service.given().get("/ping"); | ||
assertEquals(200, response.statusCode()); | ||
assertEquals("pong", response.body().asString()); | ||
|
||
Response openapi = service.given().get("/q/openapi?format=json"); //openapi should be on the old interface | ||
assertEquals(200, openapi.statusCode()); | ||
JsonPath json = openapi.body().jsonPath(); | ||
assertEquals("OK", json.getString("paths.\"/ping\".get.responses.\"200\".description")); | ||
} | ||
} | ||
|
||
@Test | ||
public void unmanaged() { | ||
unmanaged.given().get("q/health").then().statusCode(HttpStatus.SC_OK); | ||
} | ||
|
||
@Test | ||
public void managed() { | ||
app.management().get("q/health").then().statusCode(HttpStatus.SC_OK); | ||
} | ||
|
||
@Test | ||
public void customPort() { | ||
custom.management() | ||
.get("q/health").then().statusCode(HttpStatus.SC_OK); | ||
} | ||
|
||
@Test | ||
public void tls() { | ||
tls.management() | ||
.relaxedHTTPSValidation() | ||
.get("q/health").then().statusCode(HttpStatus.SC_OK); | ||
} | ||
|
||
@Test | ||
public void redirected() { | ||
Response response = redirected.given().get("api/ping"); | ||
assertEquals(200, response.statusCode()); | ||
assertEquals("pong", response.body().asString()); | ||
|
||
redirected.management().get("management/health").then() | ||
.statusCode(HttpStatus.SC_OK); | ||
|
||
Response openapi = redirected.given().get("query/openapi?format=json"); | ||
assertEquals(200, openapi.statusCode()); | ||
JsonPath json = openapi.body().jsonPath(); | ||
assertEquals("OK", json.getString("paths.\"/api/ping\".get.responses.\"200\".description")); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
http/management/src/test/java/io/quarkus/qe/OpenShiftEndpointsIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.quarkus.qe; | ||
|
||
import io.quarkus.test.scenarios.OpenShiftScenario; | ||
|
||
@OpenShiftScenario | ||
public class OpenShiftEndpointsIT extends LocalEndpointsIT { | ||
} |
32 changes: 32 additions & 0 deletions
32
http/management/src/test/java/io/quarkus/qe/OpenShiftExtensionIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.quarkus.qe; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.bootstrap.RestService; | ||
import io.quarkus.test.scenarios.OpenShiftDeploymentStrategy; | ||
import io.quarkus.test.scenarios.OpenShiftScenario; | ||
import io.quarkus.test.services.QuarkusApplication; | ||
import io.restassured.response.Response; | ||
|
||
@OpenShiftScenario(deployment = OpenShiftDeploymentStrategy.UsingOpenShiftExtension) | ||
@Disabled("Requires fixing https://github.com/quarkusio/quarkus/issues/32135 and changes in the Framework") | ||
public class OpenShiftExtensionIT { | ||
@QuarkusApplication | ||
static final RestService app = new RestService(); | ||
|
||
@Test | ||
public void payload() { | ||
Response response = app.given().get("/ping"); | ||
assertEquals(200, response.statusCode()); | ||
assertEquals("pong", response.body().asString()); | ||
} | ||
|
||
@Test | ||
public void health() { | ||
app.management().get("q/health").then().statusCode(HttpStatus.SC_OK); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
http/management/src/test/java/io/quarkus/qe/OpenShiftOptionsIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.quarkus.qe; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.scenarios.OpenShiftScenario; | ||
|
||
@OpenShiftScenario | ||
public class OpenShiftOptionsIT extends LocalOptionsIT { | ||
@Test | ||
@Override | ||
@Disabled("SSL on openshift is not supported by the FW (yet)") | ||
public void tls() { | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
monitoring/micrometer-prometheus/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
quarkus.openshift.labels.app-with-metrics=quarkus-app | ||
|
||
# MP Integration | ||
quarkus.micrometer.binder.mp-metrics.enabled=true | ||
quarkus.micrometer.binder.mp-metrics.enabled=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters