From e952af24e7e95daf775325350ec269fdc4e4d03b Mon Sep 17 00:00:00 2001
From: Lambert Rao <101875596+Lambert-Rao@users.noreply.github.com>
Date: Tue, 20 Feb 2024 14:12:00 +0800
Subject: [PATCH] [ISSUE #30] modify mappers and add test (#38)
* test: add mappers' tests.
improved connection, connector, client, meta, health mappers and add their unit tests.
* fix: rename database name
rename test database name to `eventmesh_dashboard_test`
* fix: modify text default value into an literal expression
* fix: remove endtime field from client mapper insert method
* style: unify mapper style
array format when using dynamic scripts (")
+ @Insert({
+ ""})
void batchInsert(List connectionEntityList);
- @Update("UPDATE connection SET status = #{status}, end_time = NOW() WHERE id = #{id}")
+ @Update("UPDATE connection SET status = 1, end_time = NOW() WHERE id = #{id}")
void endConnectionById(ConnectionEntity connectionEntity);
- @Delete("DELETE FROM connection WHERE cluster_id = #{clusterId}")
- void deleteAllByClusterId(ConnectionEntity connectionEntity);
-
- @Delete("DELETE FROM connection WHERE id = #{id}")
- void deleteById(ConnectionEntity connectionEntity);
-
- @Delete("")
- void batchDelete(List connectionEntityList);
+ //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 07913275..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
@@ -19,7 +19,6 @@
import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity;
-import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
@@ -38,22 +37,22 @@ public interface ConnectorMapper {
ConnectorEntity selectById(ConnectorEntity connectorEntity);
@Select("SELECT * FROM connector WHERE cluster_id = #{clusterId}")
- ConnectorEntity selectByClusterId(ConnectorEntity connectorEntity);
+ List selectByClusterId(ConnectorEntity connectorEntity);
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
- @Insert("INSERT INTO connector (cluster_id, name, class_name, type, status, pod_state, config_ids) "
- + "VALUES (#{connectClusterId}, #{name}, #{className}, #{type}, #{status}, #{podState}, #{configIds})")
+ @Insert("INSERT INTO connector (cluster_id,name, class_name, type, status, pod_state, config_ids) "
+ + "VALUES (#{clusterId}, #{name}, #{className}, #{type}, #{status}, #{podState}, #{configIds})")
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}")
@@ -65,18 +64,17 @@ public interface ConnectorMapper {
@Update("UPDATE connector SET config_ids = #{configIds} WHERE id = #{id}")
void updateConfigIds(ConnectorEntity connectorEntity);
- @Delete("DELETE FROM connector WHERE id = #{id}")
- void deleteById(ConnectorEntity connectorEntity);
+ @Update("UPDATE connector SET status = 0 WHERE cluster_id = #{clusterId}")
+ void deActiveById(ConnectorEntity connectorEntity);
- @Delete("DELETE FROM connector WHERE cluster_id = #{clusterId}")
- void deleteByClusterId(ConnectorEntity connectorEntity);
-
- @Delete("")
- void batchDelete(List connectorEntities);
+ @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
new file mode 100644
index 00000000..d5d5aab5
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.mapper.health;
+
+import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
+
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Options;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+/**
+ * Mapper for health check result
+ */
+@Mapper
+public interface HealthCheckResultMapper {
+
+ @Select("SELECT * FROM health_check_result WHERE id = #{id}")
+ HealthCheckResultEntity selectById(HealthCheckResultEntity healthCheckResultEntity);
+
+ @Select("SELECT * FROM health_check_result WHERE cluster_id = #{clusterId} AND type = #{type} AND type_id = #{typeId}")
+ List selectByClusterIdAndTypeAndTypeId(HealthCheckResultEntity healthCheckResultEntity);
+
+ @Select("SELECT * FROM health_check_result WHERE cluster_id = #{clusterId} AND type = #{type}")
+ List selectByClusterIdAndType(HealthCheckResultEntity healthCheckResultEntity);
+
+ @Select("SELECT * FROM health_check_result WHERE cluster_id = #{clusterId} AND create_time > #{startTime} AND create_time < #{endTime}")
+ List selectByClusterIdAndCreateTimeRange(@Param("clusterId") Long clusterId,
+ @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);
+
+ @Options(useGeneratedKeys = true, keyProperty = "id")
+ @Insert("INSERT INTO health_check_result(type,type_id, cluster_id, status,result_desc)"
+ + " VALUES( #{type}, #{typeId}, #{clusterId}, #{status}, #{resultDesc})")
+ void insert(HealthCheckResultEntity healthCheckResultEntity);
+
+ @Insert({
+ ""
+ })
+ void batchInsert(List healthCheckResultEntityList);
+
+ @Update("UPDATE health_check_result SET status = #{status}, result_desc = #{resultDesc} WHERE id = #{id}")
+ void update(HealthCheckResultEntity healthCheckResultEntity);
+
+ @Update({
+ ""})
+ void batchUpdate(List healthCheckResultEntityList);
+
+ @Select({
+ ""
+ })
+ List getIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId(List healthCheckResultEntityList);
+
+}
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/meta/MetaMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java
index f22bf74a..ab57fc11 100644
--- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java
@@ -34,7 +34,7 @@ public interface MetaMapper {
@Select("SELECT * FROM meta WHERE id = #{id}")
MetaEntity selectById(MetaEntity metaEntity);
- @Select("SELECT * FROM meta WHERE cluster_id = #{clusterId}")
+ @Select("SELECT * FROM meta WHERE cluster_id = #{clusterId} LIMIT 1")
MetaEntity selectByClusterId(MetaEntity metaEntity);
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
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/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java
index 780ee990..cf22a831 100644
--- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java
@@ -61,7 +61,7 @@ public void replaceAllConnections(List connectionEntityList) {
List existingConnections = connectionMapper.selectByClusterId(connectionEntity);
// Collect connections that are not in the new list
- List connectionsToDelete = existingConnections.stream()
+ List connectionsToInactive = existingConnections.stream()
.filter(existingConnection -> !newConnections.contains(existingConnection))
.collect(Collectors.toList());
@@ -71,8 +71,8 @@ public void replaceAllConnections(List connectionEntityList) {
.collect(Collectors.toList());
// Delete connections in batch
- if (!connectionsToDelete.isEmpty()) {
- connectionMapper.batchDelete(connectionsToDelete);
+ if (!connectionsToInactive.isEmpty()) {
+ connectionMapper.batchEndConnectionById(connectionsToInactive);
}
// Insert new connections in batch
diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java
new file mode 100644
index 00000000..19e3715e
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.service.health;
+
+import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+/**
+ * Service providing data of HealthCheckResult.
+ */
+public interface HealthDataService {
+ HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity healthCheckResultEntity);
+
+ void batchInsertHealthCheckResult(List healthCheckResultEntityList);
+
+ List queryHealthCheckResultByClusterIdAndTypeAndTypeId(HealthCheckResultEntity entity);
+
+ void batchUpdateCheckResult(List healthCheckResultEntityList);
+
+ void batchUpdateCheckResultByClusterIdAndTypeAndTypeId(List healthCheckResultEntityList);
+
+ List queryHealthCheckResultByClusterIdAndTimeRange(Long clusterId, Timestamp startTime, Timestamp endTime);
+}
diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataServiceMemoryStorage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataServiceMemoryStorage.java
new file mode 100644
index 00000000..85a2667f
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataServiceMemoryStorage.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.service.health;
+
+import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class HealthDataServiceMemoryStorage {
+
+ private static final List cache = new ArrayList<>();
+ private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+
+
+ public HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity healthCheckResultEntity) {
+ lock.writeLock().lock();
+ try {
+ healthCheckResultEntity.setCreateTime(new Timestamp(System.currentTimeMillis()));
+ cache.add(healthCheckResultEntity);
+ return healthCheckResultEntity;
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+
+ public void batchInsertHealthCheckResult(List healthCheckResultEntityList) {
+ lock.writeLock().lock();
+ try {
+ for (HealthCheckResultEntity entity : healthCheckResultEntityList) {
+ entity.setCreateTime(new Timestamp(System.currentTimeMillis()));
+ cache.add(entity);
+ }
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+
+ public List queryHealthCheckResultByClusterIdAndTimeRange(Long clusterId, Timestamp startTime, Timestamp endTime) {
+ lock.readLock().lock();
+ try {
+ List result = new ArrayList<>();
+ for (HealthCheckResultEntity entity : cache) {
+ if (entity.getClusterId().equals(clusterId) && entity.getCreateTime().after(startTime) && entity.getCreateTime().before(endTime)) {
+ result.add(entity);
+ }
+ }
+ return result;
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
+ public List popAll() {
+ lock.writeLock().lock();
+ try {
+ List result = new ArrayList<>(cache);
+ cache.clear();
+ return result;
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java
new file mode 100644
index 00000000..f1593cc9
--- /dev/null
+++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.service.health.impl;
+
+import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
+import org.apache.eventmesh.dashboard.console.mapper.health.HealthCheckResultMapper;
+import org.apache.eventmesh.dashboard.console.service.health.HealthDataService;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class HealthDataServiceDatabaseImpl implements HealthDataService {
+
+ @Autowired
+ private HealthCheckResultMapper healthCheckResultMapper;
+
+ @Override
+ public HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity healthCheckResultEntity) {
+ healthCheckResultMapper.insert(healthCheckResultEntity);
+ return healthCheckResultEntity;
+ }
+
+ @Override
+ public void batchInsertHealthCheckResult(List healthCheckResultEntityList) {
+ healthCheckResultMapper.batchInsert(healthCheckResultEntityList);
+ }
+
+ @Override
+ public List queryHealthCheckResultByClusterIdAndTypeAndTypeId(HealthCheckResultEntity entity) {
+ return healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(entity);
+ }
+
+ @Override
+ public void batchUpdateCheckResult(List healthCheckResultEntityList) {
+ healthCheckResultMapper.batchUpdate(healthCheckResultEntityList);
+ }
+
+ @Override
+ public void batchUpdateCheckResultByClusterIdAndTypeAndTypeId(List healthCheckResultEntityList) {
+ List idsNeedToBeUpdate = healthCheckResultMapper.getIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId(
+ healthCheckResultEntityList);
+ idsNeedToBeUpdate.forEach(entity -> {
+ healthCheckResultEntityList.forEach(updateEntity -> {
+ if (entity.getClusterId().equals(updateEntity.getClusterId()) && entity.getType().equals(updateEntity.getType())
+ && entity.getTypeId().equals(updateEntity.getTypeId())) {
+ updateEntity.setId(entity.getId());
+ }
+ });
+ });
+ healthCheckResultMapper.batchUpdate(healthCheckResultEntityList);
+ }
+
+
+ @Override
+ public List queryHealthCheckResultByClusterIdAndTimeRange(Long clusterId, Timestamp startTime, Timestamp endTime) {
+ return healthCheckResultMapper.selectByClusterIdAndCreateTimeRange(clusterId, startTime, endTime);
+ }
+}
diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml
index 0ff18a15..d411315a 100644
--- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml
+++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml
@@ -30,9 +30,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://localhost:3306/eventmesh-dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
- username: root
- password: 123456
+ url: jdbc:mysql://localhost:3306/eventmesh_dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
+ username: ${DB_USERNAME}
+ password: ${DB_PASSWORD}
initial-size: 1
max-active: 50
diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
index 96cf1e3f..96d4a849 100644
--- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
+++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql
@@ -14,13 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+DROP TABLE IF EXISTS `group`;
CREATE TABLE `group`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`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 '创建时间',
@@ -31,10 +32,10 @@ CREATE TABLE `group`
KEY `cluster_id` (`cluster_id`, `name`)
) ENGINE = InnoDB
AUTO_INCREMENT = 322
- DEFAULT CHARSET = utf8mb3 COMMENT ='Group信息表'
-
+ DEFAULT CHARSET = utf8mb3 COMMENT ='Group信息表';
+DROP TABLE IF EXISTS `group_member`;
CREATE TABLE `group_member`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
@@ -51,21 +52,21 @@ CREATE TABLE `group_member`
KEY `cluster_id` (`cluster_id`, `topic_name`, `group_name`)
) ENGINE = InnoDB
AUTO_INCREMENT = 257
- DEFAULT CHARSET = utf8mb3 COMMENT ='GroupMember信息表'
-
+ DEFAULT CHARSET = utf8mb3 COMMENT ='GroupMember信息表';
+DROP TABLE IF EXISTS `operation_log`;
CREATE TABLE `operation_log`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`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`),
@@ -73,10 +74,10 @@ CREATE TABLE `operation_log`
KEY `idx_status` (`status`)
) ENGINE = InnoDB
AUTO_INCREMENT = 68
- DEFAULT CHARSET = utf8mb3 COMMENT ='操作记录信息表'
-
+ DEFAULT CHARSET = utf8mb3 COMMENT ='操作记录信息表';
+DROP TABLE IF EXISTS `topic`;
CREATE TABLE `topic`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
@@ -86,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',
@@ -95,8 +96,7 @@ CREATE TABLE `topic`
KEY `cluster_id` (`cluster_id`, `topic_name`)
) ENGINE = InnoDB
AUTO_INCREMENT = 562
- DEFAULT CHARSET = utf8mb3 COMMENT ='Topic信息表'
-
+ DEFAULT CHARSET = utf8mb3 COMMENT ='Topic信息表';
DROP TABLE IF EXISTS `client`;
@@ -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 '修改时间',
@@ -121,7 +121,7 @@ CREATE TABLE `client`
PRIMARY KEY (`id`),
INDEX `idx_cluster_id` (`cluster_id`)
) ENGINE = InnoDB
- DEFAULT CHARSET = utf8 COMMENT ='客户端信息表';
+ DEFAULT CHARSET = utf8 COMMENT ='client is an SDK application that can produce or consume events.';
@@ -135,7 +135,7 @@ CREATE TABLE `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',
+ `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`),
@@ -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 '修改时间',
@@ -168,22 +168,22 @@ CREATE TABLE `connection`
INDEX `idx_source_id` (`source_id`),
INDEX `idx_sink_id` (`sink_id`)
) ENGINE = InnoDB
- DEFAULT CHARSET = utf8 COMMENT ='client和connector连接关系,这里的client包括runtime';
+ DEFAULT CHARSET = utf8 COMMENT ='connection from event source to event sink. event source can be a source connector or a producer client.';
DROP TABLE IF EXISTS `health_check_result`;
CREATE TABLE `health_check_result`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
- `dimension` int(11) NOT NULL DEFAULT '0' COMMENT '检查维度(0:未知,1:Cluster,2:Runtime,3:Topic,4:Group)',
- `config_name` varchar(192) NOT NULL DEFAULT '' COMMENT '配置名',
+ `type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查维度(0:未知, 1:Cluster, 2:Runtime, 3:Topic, 4:Storage)',
+ `type_id` bigint(20) unsigned NOT NULL COMMENT '对应检查维度的实例id',
`cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群ID',
- `res_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称',
- `passed` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查通过(0:未通过,1:通过)',
+ `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查状态(0:未通过,1:通过,2:正在检查,3:超时)',
+ `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`),
INDEX `idx_cluster_id` (`cluster_id`),
- UNIQUE KEY `uniq_dimension_config_cluster_res` (`dimension`, `config_name`, `cluster_id`, `res_name`)
+ INDEX `idx_type` (`type`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8 COMMENT ='健康检查结果';
diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java
new file mode 100644
index 00000000..8388de66
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.mapper.client;
+
+import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
+import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity;
+import org.apache.eventmesh.dashboard.console.enums.StatusEnum;
+
+import java.util.List;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+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.jdbc.Sql;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = EventMeshDashboardApplication.class)
+@ActiveProfiles("test")
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"})
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:client-test.sql")
+class ClientMapperTest {
+
+ @Autowired
+ private ClientMapper clientMapper;
+
+ @Test
+ public void testSelectById() {
+ ClientEntity clientEntity = new ClientEntity();
+ clientEntity.setId(1L);
+ ClientEntity result = clientMapper.selectById(clientEntity);
+ Assertions.assertEquals("java", result.getLanguage());
+ Assertions.assertEquals(3, result.getClusterId());
+ }
+
+ @Test
+ public void testSelectByClusterId() {
+ ClientEntity clientEntity = new ClientEntity();
+ clientEntity.setClusterId(3L);
+ List results = clientMapper.selectByClusterId(clientEntity);
+ Assertions.assertEquals(3, results.size());
+ Assertions.assertEquals("java", results.get(0).getLanguage());
+ Assertions.assertEquals("go", results.get(2).getLanguage());
+ }
+
+ @Test
+ public void testInsert() {
+ ClientEntity clientEntity = new ClientEntity();
+ clientEntity.setHost("127.0.0.1");
+ clientEntity.setClusterId(4L);
+ clientEntity.setName("clientName");
+ clientEntity.setDescription("");
+ clientEntity.setPid(1L);
+ clientEntity.setPort(8080);
+ clientEntity.setStatusEntity(StatusEnum.ACTIVE);
+ clientEntity.setConfigIds("");
+ clientEntity.setLanguage("rust");
+ clientEntity.setPlatform("");
+ clientEntity.setProtocol("http");
+ clientMapper.insert(clientEntity);
+
+ ClientEntity result = clientMapper.selectById(clientEntity);
+ Assertions.assertEquals("127.0.0.1", result.getHost());
+
+ Assertions.assertEquals(2, clientMapper.selectByClusterId(clientEntity).size());
+ }
+
+ @Test
+ public void testDeactivate() {
+ ClientEntity clientEntity = new ClientEntity();
+ clientEntity.setId(1L);
+ clientMapper.deActive(clientEntity);
+ ClientEntity result = clientMapper.selectById(clientEntity);
+ Assertions.assertEquals(0, result.getStatus());
+ Assertions.assertNotEquals(result.getCreateTime(), result.getEndTime());
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java
new file mode 100644
index 00000000..7087e007
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.mapper.connection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
+import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity;
+
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+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.jdbc.Sql;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = EventMeshDashboardApplication.class)
+@ActiveProfiles("test")
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"})
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:connection-test.sql")
+class ConnectionMapperTest {
+
+ @Autowired
+ private ConnectionMapper connectionMapper;
+
+ @Test
+ public void testSelectAll() {
+ assertEquals(6, connectionMapper.selectAll().size());
+ }
+
+ @Test
+ public void testSelectByClusterId() {
+ ConnectionEntity connectionEntity = new ConnectionEntity();
+ connectionEntity.setClusterId(1L);
+ assertEquals(3, connectionMapper.selectByClusterId(connectionEntity).size());
+ }
+
+ @Test
+ public void testSelectByClusterIdSourceTypeAndSourceId() {
+ ConnectionEntity connectionEntity = new ConnectionEntity();
+ connectionEntity.setClusterId(1L);
+ connectionEntity.setSourceId(1L);
+ connectionEntity.setSourceType("connector");
+ List results = connectionMapper.selectByClusterIdSourceTypeAndSourceId(connectionEntity);
+ assertEquals(1, results.size());
+ assertEquals("connector", results.get(0).getSinkType());
+ assertEquals(1, results.get(0).getSinkId());
+ }
+
+ @Test
+ public void testSelectByClusterIdSinkTypeAndSinkId() {
+ ConnectionEntity connectionEntity = new ConnectionEntity();
+ connectionEntity.setClusterId(1L);
+ connectionEntity.setSinkId(2L);
+ connectionEntity.setSinkType("connector");
+ List results = connectionMapper.selectByClusterIdSinkTypeAndSinkId(connectionEntity);
+ assertEquals(1, results.size());
+ assertEquals("connector", results.get(0).getSourceType());
+ assertEquals(2, results.get(0).getSourceId());
+ }
+
+ @Test
+ public void testInsert() {
+ ConnectionEntity connectionEntity = new ConnectionEntity(1L, 1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
+ connectionMapper.insert(connectionEntity);
+ assertEquals(7, connectionMapper.selectAll().size());
+ }
+
+ @Test
+ public void testBatchInsert() {
+ ConnectionEntity connectionEntity1 = new ConnectionEntity(1L, 1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
+ ConnectionEntity connectionEntity2 = new ConnectionEntity(1L, 1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description");
+ connectionMapper.batchInsert(Arrays.asList(connectionEntity1, connectionEntity2));
+ assertEquals(8, connectionMapper.selectAll().size());
+ }
+
+ @Test
+ public void testEndConnectionById() {
+ ConnectionEntity connectionEntity = new ConnectionEntity();
+ connectionEntity.setId(1L);
+ connectionMapper.endConnectionById(connectionEntity);
+ List results = connectionMapper.selectAll();
+ ConnectionEntity result = results.get(0);
+ assertEquals(1, result.getStatus());
+ assertNotNull(result.getEndTime());
+ }
+
+ @Test
+ public void testBatchEndConnection() {
+ ConnectionEntity connectionEntity1 = new ConnectionEntity();
+ connectionEntity1.setId(1L);
+ ConnectionEntity connectionEntity2 = new ConnectionEntity();
+ connectionEntity2.setId(2L);
+ connectionMapper.batchEndConnectionById(Arrays.asList(connectionEntity1, connectionEntity2));
+
+ List all = connectionMapper.selectAll();
+ assertEquals(1, all.get(0).getStatus());
+ assertEquals(1, all.get(1).getStatus());
+ assertNotEquals(all.get(0).getCreateTime(), all.get(0).getEndTime());
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java
new file mode 100644
index 00000000..0bb360b1
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.mapper.connector;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
+import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+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.jdbc.Sql;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = EventMeshDashboardApplication.class)
+@ActiveProfiles("test")
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"})
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:connector-test.sql")
+class ConnectorMapperTest {
+
+ @Autowired
+ private ConnectorMapper connectorMapper;
+
+ @Test
+ public void testSelectById() {
+ ConnectorEntity connectorEntity = new ConnectorEntity();
+ connectorEntity.setId(1L);
+
+ connectorEntity = connectorMapper.selectById(connectorEntity);
+
+ assertNotNull(connectorEntity);
+ assertEquals(1L, connectorEntity.getClusterId());
+ assertEquals("the", connectorEntity.getClassName());
+ }
+
+ @Test
+ public void testSelectByClusterId() {
+ ConnectorEntity connectorEntity = new ConnectorEntity();
+ connectorEntity.setClusterId(1L);
+
+ List results = connectorMapper.selectByClusterId(connectorEntity);
+
+ assertEquals(3, results.size());
+ assertEquals("quick", results.get(1).getClassName());
+ }
+
+ @Test
+ public void testInsert() {
+ ConnectorEntity connectorEntity = new ConnectorEntity(1L, 1L, "test", "test", "test", 0, 2, "test");
+ connectorMapper.insert(connectorEntity);
+
+ assertNotNull(connectorEntity);
+ assertEquals(6, connectorEntity.getId());
+ }
+
+ @Test
+ public void testBatchInsert() {
+ ConnectorEntity connectorEntity1 = new ConnectorEntity(1L, 1L, "test", "test", "test", 0, 2, "test");
+ ConnectorEntity connectorEntity2 = new ConnectorEntity(1L, 1L, "test", "test", "test", 0, 2, "test");
+ ConnectorEntity connectorEntity3 = new ConnectorEntity(1L, 1L, "test", "test", "test", 0, 2, "test");
+ List connectorEntityList = new ArrayList<>();
+ connectorEntityList.add(connectorEntity1);
+ connectorEntityList.add(connectorEntity2);
+ connectorEntityList.add(connectorEntity3);
+
+ connectorMapper.batchInsert(connectorEntityList);
+
+ ConnectorEntity connectorEntity = new ConnectorEntity();
+ connectorEntity.setClusterId(1L);
+ List results = connectorMapper.selectByClusterId(connectorEntity);
+ assertEquals(6, results.size());
+ }
+
+ @Test
+ public void testUpdateK8sStatus() {
+ ConnectorEntity connectorEntity = new ConnectorEntity();
+ connectorEntity.setId(1L);
+ connectorEntity.setPodState(3);
+ connectorMapper.updatePodState(connectorEntity);
+
+ connectorEntity = connectorMapper.selectById(connectorEntity);
+ assertEquals(3, connectorEntity.getPodState());
+ }
+
+ @Test
+ public void testUpdateConfigIds() {
+ ConnectorEntity connectorEntity = new ConnectorEntity();
+ connectorEntity.setId(1L);
+ connectorEntity.setConfigIds("1,3,4,5,6,7");
+ connectorMapper.updateConfigIds(connectorEntity);
+
+ connectorEntity = connectorMapper.selectById(connectorEntity);
+ assertEquals("1,3,4,5,6,7", connectorEntity.getConfigIds());
+ }
+
+ @Test
+ public void testDeActiveById() {
+ ConnectorEntity connectorEntity = new ConnectorEntity();
+ connectorEntity.setId(1L);
+ connectorMapper.deActiveById(connectorEntity);
+
+ connectorEntity = connectorMapper.selectById(connectorEntity);
+ assertEquals(1, connectorEntity.getStatus());
+ }
+}
\ No newline at end of file
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
new file mode 100644
index 00000000..d91cd229
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.mapper.health;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
+import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+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.jdbc.Sql;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = EventMeshDashboardApplication.class)
+@ActiveProfiles("test")
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"})
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:health-test.sql")
+class HealthCheckResultMapperTest {
+
+ @Autowired
+ private HealthCheckResultMapper healthCheckResultMapper;
+
+ @Test
+ public void testSelectById() {
+ HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity();
+ healthCheckResultEntity.setId(1L);
+ healthCheckResultEntity = healthCheckResultMapper.selectById(healthCheckResultEntity);
+ assertEquals(1, healthCheckResultEntity.getId());
+ assertEquals(0, healthCheckResultEntity.getStatus());
+ }
+
+ @Test
+ public void testSelectByClusterIdAndTypeAndTypeId() {
+ HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1L, 1, 1L, "", 1);
+ healthCheckResultEntity = healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(healthCheckResultEntity).get(0);
+ assertEquals(1, healthCheckResultEntity.getId());
+ assertEquals(0, healthCheckResultEntity.getStatus());
+ }
+
+ @Test
+ public void testSelectByClusterIdAndType() {
+ HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1L, 1, 1L, "", 1);
+ List results = healthCheckResultMapper.selectByClusterIdAndType(healthCheckResultEntity);
+ assertEquals(2, results.size());
+ }
+
+ @Test
+ public void testSelectByClusterIdAndTimeRange() throws ParseException {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ Date startDate = dateFormat.parse("2024-02-02 10:56:50");
+ Timestamp startTimestamp = new Timestamp(startDate.getTime());
+ Date endDate = dateFormat.parse("2024-02-03 10:56:52");
+ Timestamp endTimestamp = new Timestamp(endDate.getTime());
+ List results = healthCheckResultMapper.selectByClusterIdAndCreateTimeRange(1L, startTimestamp, endTimestamp);
+ assertEquals(4, results.size());
+ }
+
+ @Test
+ public void testInsert() {
+ HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 5L, 1, 5L, "", 1);
+ healthCheckResultMapper.insert(healthCheckResultEntity);
+ healthCheckResultEntity = healthCheckResultMapper.selectById(healthCheckResultEntity);
+ assertEquals(7, healthCheckResultEntity.getId());
+ }
+
+ @Test
+ public void testBatchInsert() {
+ HealthCheckResultEntity healthCheckResultEntity1 = new HealthCheckResultEntity(1L, 1L, 1, 5L, "", 1);
+ HealthCheckResultEntity healthCheckResultEntity2 = new HealthCheckResultEntity(1L, 1L, 1, 6L, "", 1);
+ healthCheckResultMapper.batchInsert(Arrays.asList(healthCheckResultEntity1, healthCheckResultEntity2));
+ List results = healthCheckResultMapper.selectByClusterIdAndType(healthCheckResultEntity1);
+ assertEquals(4, results.size());
+ }
+
+ @Test
+ public void testUpdate() {
+ HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(1L, 1L, 1, 1L, "reason", 0);
+ healthCheckResultMapper.update(healthCheckResultEntity);
+ healthCheckResultEntity = healthCheckResultMapper.selectByClusterIdAndTypeAndTypeId(healthCheckResultEntity).get(0);
+ assertEquals(0, healthCheckResultEntity.getStatus());
+ }
+
+ @Test
+ public void testBatchUpdate() {
+ HealthCheckResultEntity healthCheckResultEntity1 = new HealthCheckResultEntity(1L, 1L, 1, 1L, "reason", 0);
+ HealthCheckResultEntity healthCheckResultEntity2 = new HealthCheckResultEntity(2L, 1L, 1, 1L, "reason", 0);
+ healthCheckResultMapper.batchUpdate(Arrays.asList(healthCheckResultEntity1, healthCheckResultEntity2));
+ healthCheckResultEntity1 = healthCheckResultMapper.selectById(healthCheckResultEntity1);
+ healthCheckResultEntity2 = healthCheckResultMapper.selectById(healthCheckResultEntity2);
+
+ assertEquals(0, healthCheckResultEntity1.getStatus());
+ assertEquals(0, healthCheckResultEntity2.getStatus());
+ }
+
+ @Test
+ public void testUpdateByClusterIdAndTypeAndTypeId() {
+ HealthCheckResultEntity entity1 = new HealthCheckResultEntity(null, 1L, 1, 1L, "reason", 2);
+ HealthCheckResultEntity entity2 = new HealthCheckResultEntity(null, 1L, 1, 1L, "reason", 2);
+ healthCheckResultMapper.batchInsert(Arrays.asList(entity1, entity2));
+
+ List toBeUpdate = healthCheckResultMapper.getIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId(
+ Arrays.asList(entity1, entity2));
+
+ toBeUpdate.forEach(entity -> entity.setStatus(2));
+
+ healthCheckResultMapper.batchUpdate(toBeUpdate);
+ entity1.setId(7L);
+ assertEquals(2, healthCheckResultMapper.selectById(entity1).getStatus());
+ entity2.setId(1L);
+ assertEquals(0, healthCheckResultMapper.selectById(entity2).getStatus());
+ }
+
+}
\ No newline at end of file
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
new file mode 100644
index 00000000..42e58f46
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.mapper.meta;
+
+import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication;
+import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+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.jdbc.Sql;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = EventMeshDashboardApplication.class)
+@ActiveProfiles("test")
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"})
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:meta-test.sql")
+class MetaMapperTest {
+
+ @Autowired
+ private MetaMapper metaMapper;
+
+ @Test
+ public void testSelectByClusterId() {
+ MetaEntity metaEntity = new MetaEntity();
+ metaEntity.setClusterId(1L);
+ metaEntity = metaMapper.selectByClusterId(metaEntity);
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java
new file mode 100644
index 00000000..78cee9d1
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.dashboard.console.service.connection.impl;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity;
+
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+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.jdbc.Sql;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+
+
+@ExtendWith(SpringExtension.class)
+@ActiveProfiles("test")
+@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:connection-test.sql")
+@SpringBootTest
+public class ConnectionDataServiceDatabaseImplTest {
+
+ @Autowired
+ private ConnectionDataServiceDatabaseImpl connectionServiceDatabaseImpl;
+
+ @Test
+ public void testGetAllConnectionsByClusterId() {
+ List connectionEntityList = connectionServiceDatabaseImpl.getAllConnectionsByClusterId(1L);
+ assertEquals(3, connectionEntityList.size());
+ }
+
+ @Test
+ public void testGetAllConnections() {
+ List connectionEntityList = connectionServiceDatabaseImpl.getAllConnections();
+ assertEquals(6, connectionEntityList.size());
+ }
+
+ @Test
+ public void testReplaceAllConnections() {
+ List connectionEntityList = connectionServiceDatabaseImpl.getAllConnectionsByClusterId(1L);
+ //change ClusterId into 2
+ connectionEntityList.forEach(connectionEntity -> connectionEntity.setClusterId(2L));
+ connectionServiceDatabaseImpl.replaceAllConnections(connectionEntityList);
+ assertEquals(8, connectionServiceDatabaseImpl.getAllConnections().size());
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/test/resources/application-test.yml b/eventmesh-dashboard-console/src/test/resources/application-test.yml
index 1a903d3f..b70a657c 100644
--- a/eventmesh-dashboard-console/src/test/resources/application-test.yml
+++ b/eventmesh-dashboard-console/src/test/resources/application-test.yml
@@ -21,9 +21,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://localhost:3306/eventmesh-dashboard-test?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: root
+ password: password
initial-size: 1
max-active: 50
diff --git a/eventmesh-dashboard-console/src/test/resources/client-test.sql b/eventmesh-dashboard-console/src/test/resources/client-test.sql
new file mode 100644
index 00000000..4a652f81
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/resources/client-test.sql
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+DELETE
+FROM `eventmesh_dashboard_test`.client
+WHERE TRUE;
+ALTER TABLE `eventmesh_dashboard_test`.client
+ AUTO_INCREMENT = 1;
+
+insert into `eventmesh_dashboard_test`.client (id, cluster_id, name, platform, language, pid, host, port, protocol, status, config_ids, description,
+ create_time, end_time, update_time)
+values (1, 3, '', '', 'java', -1, '', -1, '', 1, '', '', '2024-02-02 15:15:15', '2024-02-02 15:15:15', '2024-02-02 15:15:15'),
+ (2, 3, '', '', 'java', -1, '', -1, '', 1, '', '', '2024-02-02 15:15:15', '2024-02-02 15:15:15', '2024-02-02 15:15:15'),
+ (3, 3, '', '', 'go', -1, '', -1, '', 1, '', '', '2024-02-02 15:15:15', '2024-02-02 15:15:15', '2024-02-02 15:15:15'),
+ (4, 4, '', '', 'go', -1, '', -1, '', 1, '', '', '2024-02-02 15:15:15', '2024-02-02 15:15:15', '2024-02-02 15:15:15');
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/test/resources/connectiontest.sql b/eventmesh-dashboard-console/src/test/resources/connection-test.sql
similarity index 90%
rename from eventmesh-dashboard-console/src/test/resources/connectiontest.sql
rename to eventmesh-dashboard-console/src/test/resources/connection-test.sql
index 641ea5fa..361700a0 100644
--- a/eventmesh-dashboard-console/src/test/resources/connectiontest.sql
+++ b/eventmesh-dashboard-console/src/test/resources/connection-test.sql
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-DELETE FROM `eventmesh-dashboard-test`.connection WHERE TRUE;
-ALTER TABLE `eventmesh-dashboard-test`.connection AUTO_INCREMENT = 1;
+DELETE FROM `eventmesh_dashboard_test`.connection WHERE TRUE;
+ALTER TABLE `eventmesh_dashboard_test`.connection AUTO_INCREMENT = 1;
-insert into `eventmesh-dashboard-test`.connection (id, cluster_id, source_type, source_id, sink_type, sink_id, runtime_id, status, topic, group_id, description, create_time, end_time, update_time)
+insert into `eventmesh_dashboard_test`.connection (id, cluster_id, source_type, source_id, sink_type, sink_id, runtime_id, status, topic, group_id, description, create_time, end_time, update_time)
values (1, 1, 'connector', 1, 'connector', 1, 1, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'),
(2, 1, 'connector', 2, 'connector', 2, 2, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'),
(3, 1, 'connector', 3, 'connector', 3, 3, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'),
diff --git a/eventmesh-dashboard-console/src/test/resources/connector-test.sql b/eventmesh-dashboard-console/src/test/resources/connector-test.sql
new file mode 100644
index 00000000..2ebdc5f5
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/resources/connector-test.sql
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+DELETE FROM `eventmesh_dashboard_test`.connection WHERE TRUE;
+ALTER TABLE `eventmesh_dashboard_test`.connection AUTO_INCREMENT = 1;
+
+insert into `eventmesh_dashboard_test`.connector (id, cluster_id, name, class_name, type, status, pod_state, config_ids, create_time, update_time)
+values (1, 1, '', 'the', '', 1, 1, '', '2024-02-02 16:43:45', '2024-02-02 16:53:02'),
+ (2, 1, '', 'quick', '', 1, 1, '', '2024-02-02 16:43:45', '2024-02-02 16:53:02'),
+ (3, 1, '', 'brown', '', 1, 2, '', '2024-02-02 16:43:45', '2024-02-02 16:53:02'),
+ (4, 2, '', 'fox', '', 1, 2, '', '2024-02-02 16:43:45', '2024-02-02 16:53:02'),
+ (5, 3, '', 'jumps', '', 1, 3, '', '2024-02-02 16:43:45', '2024-02-02 16:53:02');
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/test/resources/health-test.sql b/eventmesh-dashboard-console/src/test/resources/health-test.sql
new file mode 100644
index 00000000..45c3aebc
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/resources/health-test.sql
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+DELETE FROM `eventmesh_dashboard_test`.health_check_result WHERE TRUE;
+ALTER TABLE `eventmesh_dashboard_test`.health_check_result AUTO_INCREMENT = 1;
+
+insert into `eventmesh_dashboard_test`.health_check_result (id, type, type_id, cluster_id, status, result_desc, create_time, update_time)
+values (1, 1, 1, 1, 0, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'),
+ (2, 2, 2, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'),
+ (3, 3, 3, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'),
+ (4, 4, 4, 1, 1, '', '2024-02-02 18:56:50', '2024-02-02 18:56:50'),
+ (5, 1, 2, 1, 1, '', '2024-02-04 18:56:50', '2024-02-02 19:33:13'),
+ (6, 4, 2, 2, 0, '', '2024-02-04 18:56:50', '2024-02-02 19:33:13');
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/test/resources/meta-test.sql b/eventmesh-dashboard-console/src/test/resources/meta-test.sql
new file mode 100644
index 00000000..66a63549
--- /dev/null
+++ b/eventmesh-dashboard-console/src/test/resources/meta-test.sql
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+DELETE FROM `eventmesh_dashboard_test`.meta WHERE TRUE;
+ALTER TABLE `eventmesh_dashboard_test`.meta AUTO_INCREMENT = 1;
+
+insert into `eventmesh_dashboard_test`.meta (id, name, type, version, cluster_id, host, port, role, username, params, status, create_time, update_time)
+values (1, '1', 'nacos', '1.0', 1, '', -1, '-1', '', '', 0, '2024-02-03 10:30:02', '2024-02-03 10:30:02'),
+ (2, '2', 'zookeeper', '1.0', 1, '', -1, '-1', '', '', 0, '2024-02-03 10:30:02', '2024-02-03 10:30:02');
\ No newline at end of file
diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/scheduler/health/HealthCheckScheduler.java b/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql
similarity index 79%
rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/scheduler/health/HealthCheckScheduler.java
rename to eventmesh-dashboard-console/src/test/resources/use-test-schema.sql
index 7263f7cd..db0c0a26 100644
--- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/scheduler/health/HealthCheckScheduler.java
+++ b/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql
@@ -15,14 +15,4 @@
* limitations under the License.
*/
-package org.apache.eventmesh.dashboard.console.scheduler.health;
-
-import org.springframework.stereotype.Component;
-
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-@Component
-public class HealthCheckScheduler {
-
-}
+USE `eventmesh_dashboard_test`;