refactor(events): remove dead non-paginated query path
AgentEventService.queryEvents, AgentEventRepository.query, and the ClickHouse implementation have had no callers since /agents/events became cursor-paginated. Remove them along with their dedicated IT tests. queryPage and its tests remain as the single query path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.cameleer.server.app.storage;
|
||||
|
||||
import com.cameleer.server.core.agent.AgentEventRecord;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -10,10 +9,8 @@ import org.testcontainers.clickhouse.ClickHouseContainer;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -65,95 +62,6 @@ class ClickHouseAgentEventRepositoryIT {
|
||||
assertThat(count).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void query_byAppId_filtersCorrectly() {
|
||||
repo.insert("agent-1", "app-x", "default", "CONNECTED", "");
|
||||
repo.insert("agent-2", "app-y", "default", "DISCONNECTED", "");
|
||||
|
||||
List<AgentEventRecord> results = repo.query("app-x", null, null, null, null, 100);
|
||||
|
||||
assertThat(results).hasSize(1);
|
||||
assertThat(results.get(0).applicationId()).isEqualTo("app-x");
|
||||
assertThat(results.get(0).instanceId()).isEqualTo("agent-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void query_byAgentId_filtersCorrectly() {
|
||||
repo.insert("agent-alpha", "app-shared", "default", "CONNECTED", "");
|
||||
repo.insert("agent-beta", "app-shared", "default", "CONNECTED", "");
|
||||
|
||||
List<AgentEventRecord> results = repo.query(null, "agent-alpha", null, null, null, 100);
|
||||
|
||||
assertThat(results).hasSize(1);
|
||||
assertThat(results.get(0).instanceId()).isEqualTo("agent-alpha");
|
||||
}
|
||||
|
||||
@Test
|
||||
void query_byTimeRange_filtersCorrectly() {
|
||||
Instant t1 = Instant.parse("2026-01-01T10:00:00Z");
|
||||
Instant t2 = Instant.parse("2026-01-01T11:00:00Z");
|
||||
Instant t3 = Instant.parse("2026-01-01T12:00:00Z");
|
||||
|
||||
insertAt("agent-1", "app-a", "CONNECTED", "early", t1);
|
||||
insertAt("agent-1", "app-a", "HEARTBEAT", "mid", t2);
|
||||
insertAt("agent-1", "app-a", "DISCONNECTED", "late", t3);
|
||||
|
||||
// Query [t2, t3) — should return only the middle event
|
||||
List<AgentEventRecord> results = repo.query(null, null, null, t2, t3, 100);
|
||||
|
||||
assertThat(results).hasSize(1);
|
||||
assertThat(results.get(0).eventType()).isEqualTo("HEARTBEAT");
|
||||
}
|
||||
|
||||
@Test
|
||||
void query_respectsLimit() {
|
||||
Instant base = Instant.parse("2026-02-01T00:00:00Z");
|
||||
for (int i = 0; i < 10; i++) {
|
||||
insertAt("agent-1", "app-a", "HEARTBEAT", "beat-" + i, base.plusSeconds(i));
|
||||
}
|
||||
|
||||
List<AgentEventRecord> results = repo.query(null, null, null, null, null, 3);
|
||||
|
||||
assertThat(results).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void query_returnsZeroId() {
|
||||
repo.insert("agent-1", "app-a", "default", "CONNECTED", "");
|
||||
|
||||
List<AgentEventRecord> results = repo.query(null, null, null, null, null, 10);
|
||||
|
||||
assertThat(results).hasSize(1);
|
||||
assertThat(results.get(0).id()).isEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void query_noFilters_returnsAllEvents() {
|
||||
repo.insert("agent-1", "app-a", "default", "CONNECTED", "");
|
||||
repo.insert("agent-2", "app-b", "default", "DISCONNECTED", "");
|
||||
|
||||
List<AgentEventRecord> results = repo.query(null, null, null, null, null, 100);
|
||||
|
||||
assertThat(results).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void query_resultsOrderedByTimestampDesc() {
|
||||
Instant t1 = Instant.parse("2026-03-01T08:00:00Z");
|
||||
Instant t2 = Instant.parse("2026-03-01T09:00:00Z");
|
||||
Instant t3 = Instant.parse("2026-03-01T10:00:00Z");
|
||||
|
||||
insertAt("agent-1", "app-a", "FIRST", "", t1);
|
||||
insertAt("agent-1", "app-a", "SECOND", "", t2);
|
||||
insertAt("agent-1", "app-a", "THIRD", "", t3);
|
||||
|
||||
List<AgentEventRecord> results = repo.query(null, null, null, null, null, 100);
|
||||
|
||||
assertThat(results.get(0).eventType()).isEqualTo("THIRD");
|
||||
assertThat(results.get(1).eventType()).isEqualTo("SECOND");
|
||||
assertThat(results.get(2).eventType()).isEqualTo("FIRST");
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryPage_emptyTable_returnsEmptyPage() {
|
||||
com.cameleer.server.core.agent.AgentEventPage page =
|
||||
|
||||
Reference in New Issue
Block a user