diff --git a/cameleer-server-app/src/test/java/com/cameleer/server/app/controller/AgentCommandControllerIT.java b/cameleer-server-app/src/test/java/com/cameleer/server/app/controller/AgentCommandControllerIT.java index 132e34ea..22fe45be 100644 --- a/cameleer-server-app/src/test/java/com/cameleer/server/app/controller/AgentCommandControllerIT.java +++ b/cameleer-server-app/src/test/java/com/cameleer/server/app/controller/AgentCommandControllerIT.java @@ -42,6 +42,7 @@ class AgentCommandControllerIT extends AbstractPostgresIT { { "instanceId": "%s", "applicationId": "%s", + "environmentId": "default", "version": "1.0.0", "routeIds": ["route-1"], "capabilities": {} @@ -77,7 +78,7 @@ class AgentCommandControllerIT extends AbstractPostgresIT { } @Test - void sendGroupCommand_returns202WithTargetCount() throws Exception { + void sendGroupCommand_returns200WithAggregateReplies() throws Exception { String group = "cmd-it-group-" + UUID.randomUUID().toString().substring(0, 8); registerAgent("agent-g1-" + group, "Group Agent 1", group); registerAgent("agent-g2-" + group, "Group Agent 2", group); @@ -86,17 +87,20 @@ class AgentCommandControllerIT extends AbstractPostgresIT { {"type": "deep-trace", "payload": {"correlationId": "group-trace-1"}} """; + // Group dispatch is synchronous request-reply with a 10s deadline; returns + // 200 with the aggregated reply set (total/responded/timedOut). Neither agent + // holds an SSE connection in this test, so both time out but are counted. ResponseEntity response = restTemplate.postForEntity( "/api/v1/agents/groups/" + group + "/commands", new HttpEntity<>(commandJson, securityHelper.authHeaders(operatorJwt)), String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); JsonNode body = objectMapper.readTree(response.getBody()); - assertThat(body.get("targetCount").asInt()).isEqualTo(2); - assertThat(body.get("commandIds").isArray()).isTrue(); - assertThat(body.get("commandIds").size()).isEqualTo(2); + assertThat(body.get("total").asInt()).isEqualTo(2); + assertThat(body.get("timedOut").isArray()).isTrue(); + assertThat(body.get("timedOut").size()).isEqualTo(2); } @Test