From 670e458376ff3912121f37e3f9600e07d740e1b3 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Fri, 3 Apr 2026 17:03:54 +0200 Subject: [PATCH] fix: update ITs to use consolidated init.sql, remove dead code - All 7 ClickHouse integration tests now load init.sql via shared ClickHouseTestHelper instead of deleted V1-V11 migration files - Remove unused useScope exports (setApp, setRoute, setExchange, clearScope) - Remove unused CSS classes (monoCell, punchcardStack) - Update ui/README.md DS version to v0.1.28 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../server/app/ClickHouseTestHelper.java | 31 +++++++++++++ .../app/search/ClickHouseLogStoreIT.java | 6 +-- .../app/search/ClickHouseSearchIndexIT.java | 11 +---- .../ClickHouseAgentEventRepositoryIT.java | 9 +--- .../app/storage/ClickHouseDiagramStoreIT.java | 9 +--- .../storage/ClickHouseExecutionReadIT.java | 19 +------- .../storage/ClickHouseExecutionStoreIT.java | 11 +---- .../app/storage/ClickHouseStatsStoreIT.java | 45 +------------------ ui/README.md | 2 +- ui/src/hooks/useScope.ts | 30 +------------ .../DashboardTab/DashboardTab.module.css | 13 ------ 11 files changed, 47 insertions(+), 139 deletions(-) create mode 100644 cameleer3-server-app/src/test/java/com/cameleer3/server/app/ClickHouseTestHelper.java diff --git a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/ClickHouseTestHelper.java b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/ClickHouseTestHelper.java new file mode 100644 index 00000000..89b0f6cf --- /dev/null +++ b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/ClickHouseTestHelper.java @@ -0,0 +1,31 @@ +package com.cameleer3.server.app; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.jdbc.core.JdbcTemplate; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +/** + * Loads and executes the consolidated ClickHouse init.sql schema for integration tests. + */ +public final class ClickHouseTestHelper { + + private ClickHouseTestHelper() {} + + public static void executeInitSql(JdbcTemplate jdbc) throws IOException { + String sql = new ClassPathResource("clickhouse/init.sql") + .getContentAsString(StandardCharsets.UTF_8); + for (String statement : sql.split(";")) { + String trimmed = statement.trim(); + String withoutComments = trimmed.lines() + .filter(line -> !line.stripLeading().startsWith("--")) + .map(String::trim) + .filter(line -> !line.isEmpty()) + .reduce("", (a, b) -> a + b); + if (!withoutComments.isEmpty()) { + jdbc.execute(trimmed); + } + } + } +} diff --git a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/search/ClickHouseLogStoreIT.java b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/search/ClickHouseLogStoreIT.java index 41ddaaac..33c1435c 100644 --- a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/search/ClickHouseLogStoreIT.java +++ b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/search/ClickHouseLogStoreIT.java @@ -7,7 +7,7 @@ import com.cameleer3.server.core.storage.LogEntryResult; import com.zaxxer.hikari.HikariDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; +import com.cameleer3.server.app.ClickHouseTestHelper; import org.springframework.jdbc.core.JdbcTemplate; import org.testcontainers.clickhouse.ClickHouseContainer; import org.testcontainers.junit.jupiter.Container; @@ -39,9 +39,7 @@ class ClickHouseLogStoreIT { jdbc = new JdbcTemplate(ds); - String ddl = new ClassPathResource("clickhouse/V8__logs.sql") - .getContentAsString(StandardCharsets.UTF_8); - jdbc.execute(ddl); + ClickHouseTestHelper.executeInitSql(jdbc); jdbc.execute("TRUNCATE TABLE logs"); store = new ClickHouseLogStore(jdbc); diff --git a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/search/ClickHouseSearchIndexIT.java b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/search/ClickHouseSearchIndexIT.java index a0f9382c..7052799e 100644 --- a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/search/ClickHouseSearchIndexIT.java +++ b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/search/ClickHouseSearchIndexIT.java @@ -10,7 +10,7 @@ import com.cameleer3.common.model.FlatProcessorRecord; import com.zaxxer.hikari.HikariDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; +import com.cameleer3.server.app.ClickHouseTestHelper; import org.springframework.jdbc.core.JdbcTemplate; import org.testcontainers.clickhouse.ClickHouseContainer; import org.testcontainers.junit.jupiter.Container; @@ -42,14 +42,7 @@ class ClickHouseSearchIndexIT { jdbc = new JdbcTemplate(ds); - // Load DDL from classpath resources - String executionsDdl = new ClassPathResource("clickhouse/V2__executions.sql") - .getContentAsString(StandardCharsets.UTF_8); - String processorsDdl = new ClassPathResource("clickhouse/V3__processor_executions.sql") - .getContentAsString(StandardCharsets.UTF_8); - - jdbc.execute(executionsDdl); - jdbc.execute(processorsDdl); + ClickHouseTestHelper.executeInitSql(jdbc); jdbc.execute("TRUNCATE TABLE executions"); jdbc.execute("TRUNCATE TABLE processor_executions"); diff --git a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseAgentEventRepositoryIT.java b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseAgentEventRepositoryIT.java index 1b6dde25..30a9ae2f 100644 --- a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseAgentEventRepositoryIT.java +++ b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseAgentEventRepositoryIT.java @@ -4,7 +4,7 @@ import com.cameleer3.server.core.agent.AgentEventRecord; import com.zaxxer.hikari.HikariDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; +import com.cameleer3.server.app.ClickHouseTestHelper; import org.springframework.jdbc.core.JdbcTemplate; import org.testcontainers.clickhouse.ClickHouseContainer; import org.testcontainers.junit.jupiter.Container; @@ -36,12 +36,7 @@ class ClickHouseAgentEventRepositoryIT { jdbc = new JdbcTemplate(ds); - String ddl = new ClassPathResource("clickhouse/V7__agent_events.sql") - .getContentAsString(StandardCharsets.UTF_8); - jdbc.execute(ddl); - // Apply identity column renames (subset of V9 migration) - jdbc.execute("ALTER TABLE agent_events RENAME COLUMN agent_id TO instance_id"); - jdbc.execute("ALTER TABLE agent_events RENAME COLUMN app_id TO application_id"); + ClickHouseTestHelper.executeInitSql(jdbc); jdbc.execute("TRUNCATE TABLE agent_events"); repo = new ClickHouseAgentEventRepository(jdbc); diff --git a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseDiagramStoreIT.java b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseDiagramStoreIT.java index 35343391..5a1f876f 100644 --- a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseDiagramStoreIT.java +++ b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseDiagramStoreIT.java @@ -7,7 +7,7 @@ import com.cameleer3.server.core.ingestion.TaggedDiagram; import com.zaxxer.hikari.HikariDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; +import com.cameleer3.server.app.ClickHouseTestHelper; import org.springframework.jdbc.core.JdbcTemplate; import org.testcontainers.clickhouse.ClickHouseContainer; import org.testcontainers.junit.jupiter.Container; @@ -38,12 +38,7 @@ class ClickHouseDiagramStoreIT { jdbc = new JdbcTemplate(ds); - String ddl = new ClassPathResource("clickhouse/V6__route_diagrams.sql") - .getContentAsString(StandardCharsets.UTF_8); - jdbc.execute(ddl); - // Apply identity column renames (subset of V9 migration) - jdbc.execute("ALTER TABLE route_diagrams RENAME COLUMN agent_id TO instance_id"); - jdbc.execute("ALTER TABLE route_diagrams RENAME COLUMN application_name TO application_id"); + ClickHouseTestHelper.executeInitSql(jdbc); jdbc.execute("TRUNCATE TABLE route_diagrams"); store = new ClickHouseDiagramStore(jdbc); diff --git a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseExecutionReadIT.java b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseExecutionReadIT.java index 542e9cdc..ed3ef3cd 100644 --- a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseExecutionReadIT.java +++ b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseExecutionReadIT.java @@ -10,7 +10,7 @@ import com.cameleer3.server.core.storage.ExecutionStore.ProcessorRecord; import com.zaxxer.hikari.HikariDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; +import com.cameleer3.server.app.ClickHouseTestHelper; import org.springframework.jdbc.core.JdbcTemplate; import org.testcontainers.clickhouse.ClickHouseContainer; import org.testcontainers.junit.jupiter.Container; @@ -42,22 +42,7 @@ class ClickHouseExecutionReadIT { ds.setPassword(clickhouse.getPassword()); jdbc = new JdbcTemplate(ds); - // Load DDL for both tables - String execDdl = new ClassPathResource("clickhouse/V2__executions.sql") - .getContentAsString(StandardCharsets.UTF_8); - String procDdl = new ClassPathResource("clickhouse/V3__processor_executions.sql") - .getContentAsString(StandardCharsets.UTF_8); - // Also load V5 for replay fields - String replayDdl = new ClassPathResource("clickhouse/V5__replay_fields.sql") - .getContentAsString(StandardCharsets.UTF_8); - - jdbc.execute(execDdl); - jdbc.execute(procDdl); - // V5 has ALTER TABLE statements — execute each separately - for (String stmt : replayDdl.split(";")) { - String trimmed = stmt.trim(); - if (!trimmed.isEmpty()) jdbc.execute(trimmed); - } + ClickHouseTestHelper.executeInitSql(jdbc); jdbc.execute("TRUNCATE TABLE executions"); jdbc.execute("TRUNCATE TABLE processor_executions"); diff --git a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseExecutionStoreIT.java b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseExecutionStoreIT.java index 6f2a5a24..c74155c8 100644 --- a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseExecutionStoreIT.java +++ b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseExecutionStoreIT.java @@ -6,7 +6,7 @@ import com.cameleer3.common.model.FlatProcessorRecord; import com.zaxxer.hikari.HikariDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; +import com.cameleer3.server.app.ClickHouseTestHelper; import org.springframework.jdbc.core.JdbcTemplate; import org.testcontainers.clickhouse.ClickHouseContainer; import org.testcontainers.junit.jupiter.Container; @@ -38,14 +38,7 @@ class ClickHouseExecutionStoreIT { jdbc = new JdbcTemplate(ds); - // Load DDL from classpath resources - String executionsDdl = new ClassPathResource("clickhouse/V2__executions.sql") - .getContentAsString(StandardCharsets.UTF_8); - String processorsDdl = new ClassPathResource("clickhouse/V3__processor_executions.sql") - .getContentAsString(StandardCharsets.UTF_8); - - jdbc.execute(executionsDdl); - jdbc.execute(processorsDdl); + ClickHouseTestHelper.executeInitSql(jdbc); jdbc.execute("TRUNCATE TABLE executions"); jdbc.execute("TRUNCATE TABLE processor_executions"); diff --git a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseStatsStoreIT.java b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseStatsStoreIT.java index be37ff6c..f184ffeb 100644 --- a/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseStatsStoreIT.java +++ b/cameleer3-server-app/src/test/java/com/cameleer3/server/app/storage/ClickHouseStatsStoreIT.java @@ -7,7 +7,7 @@ import com.cameleer3.server.core.storage.StatsStore.PunchcardCell; import com.zaxxer.hikari.HikariDataSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.core.io.ClassPathResource; +import com.cameleer3.server.app.ClickHouseTestHelper; import org.springframework.jdbc.core.JdbcTemplate; import org.testcontainers.clickhouse.ClickHouseContainer; import org.testcontainers.junit.jupiter.Container; @@ -43,48 +43,7 @@ class ClickHouseStatsStoreIT { jdbc = new JdbcTemplate(ds); - // Load DDL from classpath resources (V2, V3, V4 create tables with old column names) - String executionsDdl = new ClassPathResource("clickhouse/V2__executions.sql") - .getContentAsString(StandardCharsets.UTF_8); - String processorsDdl = new ClassPathResource("clickhouse/V3__processor_executions.sql") - .getContentAsString(StandardCharsets.UTF_8); - String statsDdl = new ClassPathResource("clickhouse/V4__stats_tables_and_mvs.sql") - .getContentAsString(StandardCharsets.UTF_8); - String renameDdl = new ClassPathResource("clickhouse/V9__rename_identity_columns.sql") - .getContentAsString(StandardCharsets.UTF_8); - - jdbc.execute(executionsDdl); - jdbc.execute(processorsDdl); - - // Drop MVs first (they reference the stats tables), then recreate everything - jdbc.execute("DROP TABLE IF EXISTS stats_1m_all_mv"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_app_mv"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_route_mv"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_processor_mv"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_processor_detail_mv"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_all"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_app"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_route"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_processor"); - jdbc.execute("DROP TABLE IF EXISTS stats_1m_processor_detail"); - - // Create stats tables and MVs (using old column names from V4) - String cleanedStatsDdl = statsDdl.replaceAll("--[^\n]*", ""); - for (String stmt : cleanedStatsDdl.split(";")) { - String trimmed = stmt.trim(); - if (!trimmed.isEmpty()) { - jdbc.execute(trimmed); - } - } - - // Apply identity column renames (V9 migration) - String cleanedRenameDdl = renameDdl.replaceAll("--[^\n]*", ""); - for (String stmt : cleanedRenameDdl.split(";")) { - String trimmed = stmt.trim(); - if (!trimmed.isEmpty()) { - jdbc.execute(trimmed); - } - } + ClickHouseTestHelper.executeInitSql(jdbc); // Truncate base tables jdbc.execute("TRUNCATE TABLE executions"); diff --git a/ui/README.md b/ui/README.md index e0de5b44..e2fa0a88 100644 --- a/ui/README.md +++ b/ui/README.md @@ -1,6 +1,6 @@ # Cameleer3 UI -React SPA built with [@cameleer/design-system](https://gitea.siegeln.net/cameleer/design-system) v0.1.26, TanStack Query, and Zustand. +React SPA built with [@cameleer/design-system](https://gitea.siegeln.net/cameleer/design-system) v0.1.28, TanStack Query, and Zustand. ## Development diff --git a/ui/src/hooks/useScope.ts b/ui/src/hooks/useScope.ts index 39db1eeb..296b587f 100644 --- a/ui/src/hooks/useScope.ts +++ b/ui/src/hooks/useScope.ts @@ -36,33 +36,5 @@ export function useScope() { navigate(parts.join('/')); }, [navigate, scope.appId, scope.routeId]); - const setApp = useCallback((appId: string | undefined) => { - if (!appId) { - navigate(`/${tab}`); - } else { - navigate(`/${tab}/${appId}`); - } - }, [navigate, tab]); - - const setRoute = useCallback((appId: string, routeId: string | undefined) => { - if (!routeId) { - navigate(`/${tab}/${appId}`); - } else { - navigate(`/${tab}/${appId}/${routeId}`); - } - }, [navigate, tab]); - - const setExchange = useCallback((appId: string, routeId: string, exchangeId: string | undefined) => { - if (!exchangeId) { - navigate(`/${tab}/${appId}/${routeId}`); - } else { - navigate(`/${tab}/${appId}/${routeId}/${exchangeId}`); - } - }, [navigate, tab]); - - const clearScope = useCallback(() => { - navigate(`/${tab}`); - }, [navigate, tab]); - - return { scope, setTab, setApp, setRoute, setExchange, clearScope }; + return { scope, setTab }; } diff --git a/ui/src/pages/DashboardTab/DashboardTab.module.css b/ui/src/pages/DashboardTab/DashboardTab.module.css index f9f9abe2..8b68135c 100644 --- a/ui/src/pages/DashboardTab/DashboardTab.module.css +++ b/ui/src/pages/DashboardTab/DashboardTab.module.css @@ -77,13 +77,6 @@ gap: 16px; } -/* Cells */ -.monoCell { - font-size: 12px; - font-family: var(--font-mono); - color: var(--text-primary); -} - .appNameCell { display: flex; align-items: center; @@ -134,12 +127,6 @@ gap: 16px; } -.punchcardStack { - display: flex; - flex-direction: column; - gap: 16px; -} - /* Toggle button row */ .toggleRow { display: flex;