diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d53c7e19..aac6fa1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: services: mysql: - image: mysql:8 + image: mysql:8.0 env: # The MySQL docker container requires these environment variables to be set, so we can create and migrate the test database. MYSQL_DATABASE: eventmesh_dashboard_test diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index 759c8b7c..ac0bc7cd 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -81,7 +81,7 @@ org.apache.eventmesh eventmesh-sdk-java - 1.9.0-release + 1.10.0-release junit diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckTypeEnum.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java similarity index 88% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckTypeEnum.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java index eb7ddce1..3ee990bb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckTypeEnum.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckType.java @@ -21,7 +21,7 @@ import lombok.Getter; @AllArgsConstructor -public enum HealthCheckTypeEnum { +public enum HealthCheckType { UNKNOWN(0, "unknown"), CLUSTER(1, "cluster"), @@ -38,7 +38,7 @@ public enum HealthCheckTypeEnum { private final String name; public static Integer toNumber(String name) { - for (HealthCheckTypeEnum healthCheckTypeEnum : HealthCheckTypeEnum.values()) { + for (HealthCheckType healthCheckTypeEnum : HealthCheckType.values()) { if (healthCheckTypeEnum.name.equals(name)) { return healthCheckTypeEnum.number; } @@ -47,7 +47,7 @@ public static Integer toNumber(String name) { } public static String toName(Integer number) { - for (HealthCheckTypeEnum healthCheckTypeEnum : HealthCheckTypeEnum.values()) { + for (HealthCheckType healthCheckTypeEnum : HealthCheckType.values()) { if (healthCheckTypeEnum.number.equals(number)) { return healthCheckTypeEnum.name; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java index 5b84ea19..3adab3b2 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java @@ -42,11 +42,11 @@ public interface ClientMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Insert( "INSERT INTO `client` (`cluster_id`, `name`, `platform`," - + " `language`, `pid`, `host`, `port`, `protocol`," - + " `status`, `config_ids`, `description`) " + + "`language`, `pid`, `host`, `port`, `protocol`," + + "`status`, `config_ids`, `description`) " + "VALUES (#{clusterId}, #{name}, #{platform}," - + " #{language}, #{pid}, #{host}, #{port}, #{protocol}," - + " #{status}, #{configIds}, #{description})") + + "#{language}, #{pid}, #{host}, #{port}, #{protocol}," + + "#{status}, #{configIds}, #{description})") void insert(ClientEntity clientEntity); @Update("UPDATE `client` SET status = 0, end_time = NOW() WHERE id = #{id}") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java index 8d91a635..fc6756a2 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java @@ -58,24 +58,22 @@ public List selectByClusterIdSinkTypeAndSinkIdAndCreateTimeRan @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("INSERT INTO connection (cluster_id, source_type, source_id," - + " sink_type, sink_id, runtime_id, status, topic, group_id, description)" + @Insert("INSERT INTO connection (cluster_id, source_type, source_id," + " sink_type, sink_id, runtime_id, status, topic, group_id, description)" + " VALUES ( #{clusterId}, #{sourceType}, #{sourceId}, " + " #{sinkType}, #{sinkId}, #{runtimeId}, #{status}, #{topic}, #{groupId}, #{description})") void insert(ConnectionEntity connectionEntity); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("") + @Insert({ + ""}) void batchInsert(List connectionEntityList); @Update("UPDATE connection SET status = 1, end_time = NOW() WHERE id = #{id}") @@ -83,9 +81,11 @@ public List selectByClusterIdSinkTypeAndSinkIdAndCreateTimeRan //batch end @Update({ - ""}) + ""}) void batchEndConnectionById(List connectionEntityList); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java index 53a34660..2f5101a3 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java @@ -45,14 +45,14 @@ public interface ConnectorMapper { void insert(ConnectorEntity connectorEntity); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("") + @Insert({ + ""}) void batchInsert(List connectorEntityList); @Update("UPDATE connector SET status = #{status} WHERE id = #{id}") @@ -69,11 +69,11 @@ public interface ConnectorMapper { @Update({ "" }) void batchDeActive(List connectorEntities); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java index f1a91ede..78128619 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java @@ -55,19 +55,19 @@ public interface OprGroupMapper { @Select("select * from `group` where id=#{id} and is_delete=0") GroupEntity selectGroupById(GroupEntity groupEntity); - @Select("") + @Select({ + ""}) List selectGroup(GroupEntity groupEntity); - } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java index 3179effc..aac0a592 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java @@ -59,21 +59,22 @@ public interface OprGroupMemberMapper { @Select("select * from group_member where id=#{id} and is_delete=0") GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); - @Select("") + @Select({ + ""}) List selectMember(GroupMemberEntity groupMemberEntity); @Update("update group_member set state=#{state} where topic_name=#{topicName}") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java index 574f9eef..d5d5aab5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java @@ -55,11 +55,11 @@ List selectByClusterIdAndCreateTimeRange(@Param("cluste @Insert({ "" }) void batchInsert(List healthCheckResultEntityList); @@ -68,10 +68,12 @@ List selectByClusterIdAndCreateTimeRange(@Param("cluste void update(HealthCheckResultEntity healthCheckResultEntity); @Update({ - ""}) + ""}) void batchUpdate(List healthCheckResultEntityList); @Select({ diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java index d6c96f72..8f2dbf4e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java @@ -33,21 +33,22 @@ @Mapper public interface OprLogMapper { - @Select("") + @Select({ + ""}) List getLogList(LogEntity logEntity); @Insert("insert into operation_log ( cluster_id, operation_type,target_Type, description,operation_user,result_content)" diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java index 8a396be6..42d68d0d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java @@ -35,18 +35,19 @@ @Mapper public interface TopicMapper { - @Select("") + @Select({ + ""}) List getTopicList(TopicEntity topicEntity); @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) " diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index 776df864..96d4a849 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -21,7 +21,7 @@ CREATE TABLE `group` `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群id', `name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Group名称', `member_count` int unsigned NOT NULL DEFAULT '0' COMMENT '成员数', - `members` text COMMENT 'group的member列表', + `members` varchar(1024) COMMENT 'group的member列表', `type` tinyint NOT NULL COMMENT 'group类型 0:consumer 1:producer', `state` varchar(64) NOT NULL DEFAULT '' COMMENT '状态', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', @@ -62,11 +62,11 @@ CREATE TABLE `operation_log` `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '物理集群ID', `operation_type` varchar(192) NOT NULL DEFAULT '' COMMENT '操作类型,如:启动,停止,重启,添加,删除,修改', `status` int NOT NULL DEFAULT '0' COMMENT '操作状态 0:未知,1:执行中,2:成功,3:失败', - `content` text COMMENT '备注信息', + `content` varchar(1024) COMMENT '备注信息', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `end_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', `operation_user` varchar(192) DEFAULT NULL, - `result` text, + `result` varchar(1024), `target_type` varchar(192) NOT NULL, `is_delete` int NOT NULL DEFAULT '0', PRIMARY KEY (`id`), @@ -87,7 +87,7 @@ CREATE TABLE `topic` `storage_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'StorageId', `retention_ms` bigint NOT NULL DEFAULT '-2' COMMENT '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', `type` tinyint NOT NULL DEFAULT '0' COMMENT 'Topic类型,默认0,0:普通,1:EventMesh内部', - `description` text COMMENT '备注信息', + `description` varchar(1024) DEFAULT '' COMMENT '备注信息', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(尽量与Topic实际创建时间一致)', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间(尽量与Topic实际创建时间一致)', `is_delete` int NOT NULL DEFAULT '0', @@ -112,8 +112,8 @@ CREATE TABLE `client` `port` int(16) NOT NULL DEFAULT '-1' COMMENT '客户端端口', `protocol` varchar(192) NOT NULL DEFAULT '' COMMENT '协议类型', `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', - `config_ids` text NOT NULL DEFAULT ('') COMMENT 'csv config id list, like:1,3,7', - `description` text NOT NULL DEFAULT ('') COMMENT '客户端描述', + `config_ids` varchar(1024) NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', + `description` varchar(1024) NOT NULL DEFAULT '' COMMENT '客户端描述', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', @@ -128,16 +128,16 @@ CREATE TABLE `client` DROP TABLE IF EXISTS `connector`; CREATE TABLE `connector` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称', - `class_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector类', - `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Connector类型', - `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', - `pod_state` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'k8s pod状态。0: pending;1: running;2: success;3: failed;4: unknown', - `config_ids` text NOT NULL DEFAULT ('') COMMENT 'csv config id list, like:1,3,7', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', + `name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称', + `class_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector类', + `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Connector类型', + `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', + `pod_state` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'k8s pod状态。0: pending;1: running;2: success;3: failed;4: unknown', + `config_ids` varchar(1024) NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`), INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB @@ -156,7 +156,7 @@ CREATE TABLE `connection` `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', `topic` varchar(192) NOT NULL DEFAULT '' COMMENT 'topic name', `group_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'GroupID', - `description` text NOT NULL DEFAULT ('') COMMENT '客户端描述', + `description` varchar(1024) NOT NULL DEFAULT '' COMMENT '客户端描述', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', @@ -178,7 +178,7 @@ CREATE TABLE `health_check_result` `type_id` bigint(20) unsigned NOT NULL COMMENT '对应检查维度的实例id', `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群ID', `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查状态(0:未通过,1:通过,2:正在检查,3:超时)', - `result_desc` text NOT NULL DEFAULT ('') COMMENT '检查结果描述', + `result_desc` varchar(1024) NOT NULL DEFAULT '' COMMENT '检查结果描述', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java index 49cd6ed1..d91cd229 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java @@ -32,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java index e4fb11c1..42e58f46 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java @@ -17,8 +17,6 @@ package org.apache.eventmesh.dashboard.console.mapper.meta; -import static org.junit.jupiter.api.Assertions.*; - import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; import org.junit.jupiter.api.Test; @@ -26,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/eventmesh-dashboard-console/src/test/resources/application-test.yml b/eventmesh-dashboard-console/src/test/resources/application-test.yml index e959485b..b70a657c 100644 --- a/eventmesh-dashboard-console/src/test/resources/application-test.yml +++ b/eventmesh-dashboard-console/src/test/resources/application-test.yml @@ -21,7 +21,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + url: jdbc:mysql://localhost:3306/eventmesh_dashboard_test?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true username: root password: password diff --git a/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql b/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql index 9006b5e2..db0c0a26 100644 --- a/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql +++ b/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql @@ -15,5 +15,4 @@ * limitations under the License. */ -CREATE DATABASE IF NOT EXISTS `eventmesh_dashboard_test`; -USE `eventmesh_dashboard_test` +USE `eventmesh_dashboard_test`;