-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify that we do not exceed the number of tags that can be recorded …
…for HTTP requests This commits adds tests to verify that we do not exceed the number of tags that can be recorded for HTTP requests. It tests: - Jax-RS OK, 400 and 500 - Reactive routes OK, 400 and 500 - Programmatic routes OK, 400 and 500
- Loading branch information
1 parent
fa716ef
commit add75a1
Showing
10 changed files
with
776 additions
and
1 deletion.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
.../java/io/quarkus/micrometer/deployment/pathparams/HttpPathParamLimitWithJaxRs400Test.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,111 @@ | ||
package io.quarkus.micrometer.deployment.pathparams; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.quarkus.micrometer.test.Util; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class HttpPathParamLimitWithJaxRs400Test { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("test-logging.properties") | ||
.overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-client.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-server.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.vertx.enabled", "true") | ||
.overrideConfigKey("quarkus.redis.devservices.enabled", "false") | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Util.class, | ||
Resource.class)); | ||
|
||
@Inject | ||
MeterRegistry registry; | ||
|
||
public static final int COUNT = 101; | ||
|
||
@Test | ||
void testWithResteasy400() throws InterruptedException { | ||
registry.clear(); | ||
// Test a JAX-RS endpoint with GET /jaxrs and GET /jaxrs/{message} | ||
// Verify OK response | ||
for (int i = 0; i < COUNT; i++) { | ||
RestAssured.get("/jaxrs").then().statusCode(200); | ||
RestAssured.get("/jaxrs/foo-" + i).then().statusCode(200); | ||
} | ||
|
||
// Verify metrics | ||
Util.waitForMeters(registry.find("http.server.requests").timers(), COUNT); | ||
|
||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/jaxrs").timers().iterator().next().count()); | ||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/jaxrs/{message}").timers().iterator().next().count()); | ||
|
||
// Verify method producing a 400 | ||
for (int i = 0; i < COUNT; i++) { | ||
RestAssured.get("/bad").then().statusCode(400); | ||
RestAssured.get("/bad/foo-" + i).then().statusCode(400); | ||
} | ||
|
||
Util.waitForMeters(registry.find("http.server.requests").timers(), COUNT * 2); | ||
|
||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/bad").tag("method", "GET").timers().iterator().next().count()); | ||
Assertions.assertEquals(4, registry.find("http.server.requests") | ||
.tag("method", "GET").timers().size()); // Pattern recognized | ||
|
||
} | ||
|
||
@Path("/") | ||
@Singleton | ||
public static class Resource { | ||
|
||
@GET | ||
@Path("/jaxrs") | ||
public String jaxrs() { | ||
return "hello"; | ||
} | ||
|
||
@GET | ||
@Path("/jaxrs/{message}") | ||
public String jaxrsWithPathParam(@PathParam("message") String message) { | ||
return "hello " + message; | ||
} | ||
|
||
@GET | ||
@Path("/bad") | ||
public Response bad() { | ||
return Response.status(400).build(); | ||
} | ||
|
||
@GET | ||
@Path("/bad/{message}") | ||
public Response bad(@PathParam("message") String message) { | ||
return Response.status(400).build(); | ||
} | ||
|
||
@GET | ||
@Path("/fail") | ||
public Response fail() { | ||
return Response.status(500).build(); | ||
} | ||
|
||
@GET | ||
@Path("/fail/{message}") | ||
public Response fail(@PathParam("message") String message) { | ||
return Response.status(500).build(); | ||
} | ||
|
||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
.../java/io/quarkus/micrometer/deployment/pathparams/HttpPathParamLimitWithJaxRs500Test.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,110 @@ | ||
package io.quarkus.micrometer.deployment.pathparams; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.quarkus.micrometer.test.Util; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class HttpPathParamLimitWithJaxRs500Test { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("test-logging.properties") | ||
.overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-client.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-server.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.vertx.enabled", "true") | ||
.overrideConfigKey("quarkus.redis.devservices.enabled", "false") | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Util.class, | ||
Resource.class)); | ||
|
||
@Inject | ||
MeterRegistry registry; | ||
|
||
public static final int COUNT = 101; | ||
|
||
@Test | ||
void testWithResteasy500() throws InterruptedException { | ||
registry.clear(); | ||
// Test a JAX-RS endpoint with GET /jaxrs and GET /jaxrs/{message} | ||
// Verify OK response | ||
for (int i = 0; i < COUNT; i++) { | ||
RestAssured.get("/jaxrs").then().statusCode(200); | ||
RestAssured.get("/jaxrs/foo-" + i).then().statusCode(200); | ||
} | ||
|
||
// Verify metrics | ||
Util.waitForMeters(registry.find("http.server.requests").timers(), COUNT); | ||
|
||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/jaxrs").timers().iterator().next().count()); | ||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/jaxrs/{message}").timers().iterator().next().count()); | ||
|
||
// Verify method producing a 400 | ||
for (int i = 0; i < COUNT; i++) { | ||
RestAssured.get("/fail").then().statusCode(500); | ||
RestAssured.get("/fail/foo-" + i).then().statusCode(500); | ||
} | ||
|
||
Util.waitForMeters(registry.find("http.server.requests").timers(), COUNT * 2); | ||
|
||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/fail").tag("method", "GET").timers().iterator().next().count()); | ||
Assertions.assertEquals(4, registry.find("http.server.requests") | ||
.tag("method", "GET").timers().size()); // Pattern recognized | ||
} | ||
|
||
@Path("/") | ||
@Singleton | ||
public static class Resource { | ||
|
||
@GET | ||
@Path("/jaxrs") | ||
public String jaxrs() { | ||
return "hello"; | ||
} | ||
|
||
@GET | ||
@Path("/jaxrs/{message}") | ||
public String jaxrsWithPathParam(@PathParam("message") String message) { | ||
return "hello " + message; | ||
} | ||
|
||
@GET | ||
@Path("/bad") | ||
public Response bad() { | ||
return Response.status(400).build(); | ||
} | ||
|
||
@GET | ||
@Path("/bad/{message}") | ||
public Response bad(@PathParam("message") String message) { | ||
return Response.status(400).build(); | ||
} | ||
|
||
@GET | ||
@Path("/fail") | ||
public Response fail() { | ||
return Response.status(500).build(); | ||
} | ||
|
||
@GET | ||
@Path("/fail/{message}") | ||
public Response fail(@PathParam("message") String message) { | ||
return Response.status(500).build(); | ||
} | ||
|
||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...est/java/io/quarkus/micrometer/deployment/pathparams/HttpPathParamLimitWithJaxRsTest.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,86 @@ | ||
package io.quarkus.micrometer.deployment.pathparams; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.quarkus.micrometer.test.Util; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class HttpPathParamLimitWithJaxRsTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("test-logging.properties") | ||
.overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-client.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-server.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.vertx.enabled", "true") | ||
.overrideConfigKey("quarkus.redis.devservices.enabled", "false") | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Util.class, | ||
Resource.class)); | ||
|
||
@Inject | ||
MeterRegistry registry; | ||
|
||
public static final int COUNT = 101; | ||
public static final int ARITY_LIMIT = 100; | ||
|
||
@Test | ||
void testWithResteasyOK() throws InterruptedException { | ||
registry.clear(); | ||
// Test a JAX-RS endpoint with GET /jaxrs and GET /jaxrs/{message} | ||
// Verify OK response | ||
for (int i = 0; i < COUNT; i++) { | ||
RestAssured.get("/jaxrs").then().statusCode(200); | ||
RestAssured.get("/jaxrs/foo-" + i).then().statusCode(200); | ||
} | ||
|
||
// Verify metrics | ||
Util.waitForMeters(registry.find("http.server.requests").timers(), COUNT); | ||
|
||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/jaxrs").timers().iterator().next().count()); | ||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/jaxrs/{message}").timers().iterator().next().count()); | ||
|
||
// Verify 405 responses | ||
for (int i = 0; i < COUNT; i++) { | ||
RestAssured.delete("/jaxrs").then().statusCode(405); | ||
RestAssured.patch("/jaxrs/foo-" + i).then().statusCode(405); | ||
} | ||
|
||
Util.waitForMeters(registry.find("http.server.requests").timers(), COUNT * 2); | ||
|
||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/jaxrs").tag("method", "DELETE").timers().iterator().next().count()); | ||
Assertions.assertEquals(ARITY_LIMIT - 2, registry.find("http.server.requests") | ||
.tag("method", "PATCH").timers().size()); // -2 because of the two other uri: /jaxrs and /jaxrs/{message}. | ||
} | ||
|
||
@Path("/") | ||
@Singleton | ||
public static class Resource { | ||
|
||
@GET | ||
@Path("/jaxrs") | ||
public String jaxrs() { | ||
return "hello"; | ||
} | ||
|
||
@GET | ||
@Path("/jaxrs/{message}") | ||
public String jaxrsWithPathParam(@PathParam("message") String message) { | ||
return "hello " + message; | ||
} | ||
|
||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...kus/micrometer/deployment/pathparams/HttpPathParamLimitWithProgrammaticRoutes400Test.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,86 @@ | ||
package io.quarkus.micrometer.deployment.pathparams; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.quarkus.micrometer.test.Util; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
import io.vertx.ext.web.Router; | ||
|
||
public class HttpPathParamLimitWithProgrammaticRoutes400Test { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("test-logging.properties") | ||
.overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-client.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-server.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.vertx.enabled", "true") | ||
.overrideConfigKey("quarkus.redis.devservices.enabled", "false") | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Util.class, | ||
Resource.class)); | ||
|
||
@Inject | ||
MeterRegistry registry; | ||
|
||
public static final int COUNT = 101; | ||
|
||
@Test | ||
void testWithProgrammaticRoutes400() throws InterruptedException { | ||
registry.clear(); | ||
// Verify OK response | ||
for (int i = 0; i < COUNT; i++) { | ||
RestAssured.get("/programmatic").then().statusCode(200); | ||
RestAssured.get("/programmatic/foo-" + i).then().statusCode(200); | ||
} | ||
|
||
// Verify metrics | ||
Util.waitForMeters(registry.find("http.server.requests").timers(), COUNT); | ||
|
||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/programmatic").timers().iterator().next().count()); | ||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/programmatic/{message}").timers().iterator().next().count()); | ||
|
||
// Verify 405 responses | ||
for (int i = 0; i < COUNT; i++) { | ||
RestAssured.get("/bad").then().statusCode(400); | ||
RestAssured.get("/bad/foo-" + i).then().statusCode(400); | ||
} | ||
|
||
Util.waitForMeters(registry.find("http.server.requests").timers(), COUNT * 2); | ||
|
||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("uri", "/bad").tag("method", "GET").timers().iterator().next().count()); | ||
Assertions.assertEquals(COUNT, registry.find("http.server.requests") | ||
.tag("method", "GET").timers().iterator().next().count()); | ||
} | ||
|
||
@Singleton | ||
public static class Resource { | ||
|
||
void registerProgrammaticRoutes(@Observes Router router) { | ||
router.get("/programmatic").handler(rc -> { | ||
rc.response().end("hello"); | ||
}); | ||
router.get("/programmatic/:message").handler(rc -> { | ||
rc.response().end("hello " + rc.pathParam("message")); | ||
}); | ||
|
||
router.get("/bad").handler(rc -> { | ||
rc.response().setStatusCode(400).end("hello"); | ||
}); | ||
router.get("/bad/:message").handler(rc -> { | ||
rc.response().setStatusCode(400).end("hello " + rc.pathParam("message")); | ||
}); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.