Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,32 @@ public void testResourcesRead() {

}

@Test
public void testUnsupportedMethodReturnsMethodNotFound() {
String jsonBody = """
{
"jsonrpc": "2.0",
"id": 8,
"method": "prompts/list"
}
""";

RestAssured
.given()
.contentType(ContentType.JSON)
.body(jsonBody)
.when()
.post("/q/dev-mcp")
.then()
.statusCode(200)
.log().all()
.body("id", CoreMatchers.equalTo(8))
.body("jsonrpc", CoreMatchers.equalTo("2.0"))
.body("error.code", CoreMatchers.equalTo(-32601))
.body("error.message", CoreMatchers.containsString("prompts/list"));

}

@Test
public void testResourcesReadWithInvalidUri() {
String jsonBody = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ private void handleMCPJsonRPCRequest(RoutingContext ctx) {
if (jsonRpcRouter.isEnabled(jsonRpcRequest)) {
jsonRpcRouter.route(jsonRpcRequest, writer);
} else {
codec.writeErrorResponse(writer, jsonRpcRequest.getId(), methodName,
new McpMethodNotEnabledException("Method not enabled"));
codec.writeMethodNotFoundResponse(writer, jsonRpcRequest.getId(), methodName);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ public void testAllocatorMetricsValues() {
@Timeout(60L)
public void testEventExecutorMetricsValues() throws Exception {
VertxInternal vi = (VertxInternal) vertx;
assertEventGroup(vi.getEventLoopGroup());
assertEventGroup(vi.getAcceptorEventLoopGroup());
assertEventGroup(vi.getEventLoopGroup(), "eventLoop");
assertEventGroup(vi.getAcceptorEventLoopGroup(), "acceptor");
}

private void assertEventGroup(EventLoopGroup group) throws Exception {
private void assertEventGroup(EventLoopGroup group, String expectedExecutorTag) throws Exception {
int tasks = 0;
for (EventExecutor ee : group) {
tasks++;
Expand All @@ -198,30 +198,32 @@ private void assertEventGroup(EventLoopGroup group) throws Exception {
List<Meter> meters = registry.getMeters();
// this would return 1 for everyone
for (EventExecutor eventLoop : group) {
checkMetrics(meters, eventLoop, 1);
checkMetrics(meters, eventLoop, 1, expectedExecutorTag);
}
waitCollectingMeasures.countDown();
for (Future<Future<?>> pendingTaskCompleted : pendingTasksCompleted) {
pendingTaskCompleted.get().get();
}
// this would return 0 for everyone
for (EventExecutor eventLoop : group) {
checkMetrics(meters, eventLoop, 0);
checkMetrics(meters, eventLoop, 0, expectedExecutorTag);
}
}

private void checkMetrics(List<Meter> meters, EventExecutor executor, int expected) {
private void checkMetrics(List<Meter> meters, EventExecutor executor, int expected, String expectedExecutorTag) {
if (executor instanceof SingleThreadEventExecutor) {
SingleThreadEventExecutor stee = (SingleThreadEventExecutor) executor;

int pendingTasks = stee.pendingTasks();
Assertions.assertEquals(expected, pendingTasks);

Tag tag = Tag.of("name", stee.threadProperties().name());
Set<Tag> tags = Set.of(tag);
Tag nameTag = Tag.of("name", stee.threadProperties().name());
Tag executorTag = Tag.of("executor", expectedExecutorTag);
Set<Tag> tags = Set.of(nameTag, executorTag);

Double metricsValue = getValue(meters, tags);
Assertions.assertNotNull(metricsValue);
Assertions.assertNotNull(metricsValue,
"Expected gauge with tags " + tags + " but not found");
int mvInt = metricsValue.intValue();
Assertions.assertEquals(expected, mvInt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Singleton;

import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.netty4.NettyEventExecutorMetrics;
import io.vertx.core.Vertx;
Expand All @@ -15,14 +16,14 @@ public class VertxNettyEventExecutorMetricsProvider {
@Singleton
public MeterBinder vertxEventLoopGroupMetrics(Vertx vertx) {
VertxInternal vi = (VertxInternal) vertx;
return new NettyEventExecutorMetrics(vi.getEventLoopGroup());
return new NettyEventExecutorMetrics(vi.getEventLoopGroup(), Tags.of("executor", "eventLoop"));
}

@Produces
@Singleton
public MeterBinder vertxAcceptorEventLoopGroupMetrics(Vertx vertx) {
VertxInternal vi = (VertxInternal) vertx;
return new NettyEventExecutorMetrics(vi.getAcceptorEventLoopGroup());
return new NettyEventExecutorMetrics(vi.getAcceptorEventLoopGroup(), Tags.of("executor", "acceptor"));
}

}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
<jakarta.persistence-api.version>3.2.0</jakarta.persistence-api.version> <!-- version controlled by Hibernate ORM's needs -->
<jakarta.data-api.version>1.0.1</jakarta.data-api.version> <!-- version controlled by Hibernate ORM's needs -->
<antlr.version>4.13.2</antlr.version> <!-- version controlled by Hibernate ORM's needs -->
<bytebuddy.version>1.17.8</bytebuddy.version> <!-- version controlled by Hibernate ORM's needs -->
<bytebuddy.version>1.18.7</bytebuddy.version> <!-- version controlled by Hibernate ORM's needs -->
<geolatte.version>1.10</geolatte.version> <!-- version controlled by Hibernate ORM's needs -->
<hibernate-models.version>1.0.1</hibernate-models.version> <!-- version controlled by Hibernate ORM's needs -->
<hibernate-models.version>1.1.0</hibernate-models.version> <!-- version controlled by Hibernate ORM's needs -->
<hibernate-reactive.version>3.3.0.Final</hibernate-reactive.version> <!-- highly sensitive to Hibernate ORM upgrades -->
<hibernate-validator.version>9.1.0.Final</hibernate-validator.version>
<hibernate-search.version>8.3.0.Final</hibernate-search.version>
Expand Down
Loading