You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by do...@apache.org on 2022/03/12 08:39:16 UTC
[incubator-inlong] branch master updated: [INLONG-2960][Audit] Unit tests error when execute mvn test command (#3085)
This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 30565a1 [INLONG-2960][Audit] Unit tests error when execute mvn test command (#3085)
30565a1 is described below
commit 30565a1c0152a5bd4380ddee265b3ae624a880a0
Author: healchow <he...@gmail.com>
AuthorDate: Sat Mar 12 16:39:09 2022 +0800
[INLONG-2960][Audit] Unit tests error when execute mvn test command (#3085)
---
.../inlong/audit/source/DefaultServiceDecoder.java | 4 +-
.../apache/inlong/audit/source/ServiceDecoder.java | 4 --
.../org/apache/inlong/audit/db/DruidConfig.java | 3 +-
.../apache/inlong/audit/db/dao/AuditDataDao.java | 3 ++
.../audit/service/AuditMsgConsumerServer.java | 24 ++++-------
.../inlong/audit/service/ElasticsearchService.java | 30 ++++++--------
.../src/main/resources/sql/apache_inlong_audit.sql | 46 +++++++++++++++++++++
.../inlong/audit/service/AuditStoreTest.java | 36 +++++++----------
.../audit/service/ElasticsearchServiceTest.java | 47 ++++++++--------------
...tion.properties => application-test.properties} | 13 +++---
10 files changed, 110 insertions(+), 100 deletions(-)
diff --git a/inlong-audit/audit-proxy/src/main/java/org/apache/inlong/audit/source/DefaultServiceDecoder.java b/inlong-audit/audit-proxy/src/main/java/org/apache/inlong/audit/source/DefaultServiceDecoder.java
index 26c230f..23bb2a2 100644
--- a/inlong-audit/audit-proxy/src/main/java/org/apache/inlong/audit/source/DefaultServiceDecoder.java
+++ b/inlong-audit/audit-proxy/src/main/java/org/apache/inlong/audit/source/DefaultServiceDecoder.java
@@ -26,12 +26,10 @@ import org.apache.inlong.audit.protocol.AuditApi.BaseCommand;
public class DefaultServiceDecoder implements ServiceDecoder {
- private static final Logger LOG = LoggerFactory
- .getLogger(DefaultServiceDecoder.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultServiceDecoder.class);
@Override
public BaseCommand extractData(ChannelBuffer cb, Channel channel) throws Exception {
-
/*[cmd size] | [cmd]*/
if (null == cb) {
LOG.error("cb == null");
diff --git a/inlong-audit/audit-proxy/src/main/java/org/apache/inlong/audit/source/ServiceDecoder.java b/inlong-audit/audit-proxy/src/main/java/org/apache/inlong/audit/source/ServiceDecoder.java
index f42ae30..786b2cf 100644
--- a/inlong-audit/audit-proxy/src/main/java/org/apache/inlong/audit/source/ServiceDecoder.java
+++ b/inlong-audit/audit-proxy/src/main/java/org/apache/inlong/audit/source/ServiceDecoder.java
@@ -23,15 +23,11 @@ import org.jboss.netty.channel.Channel;
/**
* decoder interface definition
- *
*/
public interface ServiceDecoder {
/**
* extract data from buffer and convert it into map.
- * @param cb
- * @param channel
- * @return
*/
BaseCommand extractData(ChannelBuffer cb, Channel channel) throws Exception;
}
diff --git a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/DruidConfig.java b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/DruidConfig.java
index 5285a67..99d85b7 100644
--- a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/DruidConfig.java
+++ b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/DruidConfig.java
@@ -41,7 +41,6 @@ public class DruidConfig {
@Bean
@ConditionalOnMissingBean
public DataSource druidDataSource() {
-
LOGGER.info("druidDataSource url = {} ", properties.getUrl());
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(properties.getDriverClassName());
@@ -66,7 +65,7 @@ public class DruidConfig {
druidDataSource.setFilters(properties.getFilters());
druidDataSource.init();
} catch (SQLException e) {
- LOGGER.error("druidDataSource has error e = {}", e);
+ LOGGER.error("init druidDataSource failed: ", e);
}
return druidDataSource;
}
diff --git a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/dao/AuditDataDao.java b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/dao/AuditDataDao.java
index 203708f..5332bd6 100644
--- a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/dao/AuditDataDao.java
+++ b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/dao/AuditDataDao.java
@@ -18,7 +18,10 @@
package org.apache.inlong.audit.db.dao;
import org.apache.inlong.audit.db.entities.AuditDataPo;
+import org.springframework.stereotype.Repository;
+@Repository
public interface AuditDataDao {
+
int insert(AuditDataPo auditDataPo);
}
diff --git a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/AuditMsgConsumerServer.java b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/AuditMsgConsumerServer.java
index f1a7110..a98054b 100644
--- a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/AuditMsgConsumerServer.java
+++ b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/AuditMsgConsumerServer.java
@@ -19,12 +19,12 @@ package org.apache.inlong.audit.service;
import com.google.gson.Gson;
import org.apache.commons.lang.StringUtils;
-import org.apache.inlong.audit.protocol.AuditData;
import org.apache.inlong.audit.config.PulsarConfig;
import org.apache.inlong.audit.config.StoreConfig;
import org.apache.inlong.audit.db.dao.AuditDataDao;
import org.apache.inlong.audit.db.entities.AuditDataPo;
import org.apache.inlong.audit.db.entities.ESDataPo;
+import org.apache.inlong.audit.protocol.AuditData;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageListener;
@@ -37,6 +37,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -46,30 +47,21 @@ import java.util.concurrent.TimeUnit;
@Service
public class AuditMsgConsumerServer implements InitializingBean {
- private static final Logger LOG = LoggerFactory
- .getLogger(AuditMsgConsumerServer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AuditMsgConsumerServer.class);
+ private final Gson gson = new Gson();
+ private final ConcurrentHashMap<String, List<Consumer<byte[]>>> topicConsumerMap = new ConcurrentHashMap<>();
@Autowired
private PulsarConfig pulsarConfig;
-
@Autowired
private AuditDataDao auditDataDao;
-
@Autowired
private ElasticsearchService esService;
-
@Autowired
private StoreConfig storeConfig;
- private PulsarClient pulsarClient;
-
- private Gson gson = new Gson();
-
- private ConcurrentHashMap<String, List<Consumer<byte[]>>> topicConsumerMap =
- new ConcurrentHashMap<String, List<Consumer<byte[]>>>();
-
- public void afterPropertiesSet() throws Exception {
- pulsarClient = getOrCreatePulsarClient(pulsarConfig.getPulsarServerUrl());
+ public void afterPropertiesSet() {
+ PulsarClient pulsarClient = getOrCreatePulsarClient(pulsarConfig.getPulsarServerUrl());
if (storeConfig.isElasticsearchStore()) {
esService.startTimerRoutine();
}
@@ -166,7 +158,7 @@ public class AuditMsgConsumerServer implements InitializingBean {
}
protected void handleMessage(Message<byte[]> msg) throws Exception {
- String body = new String(msg.getData(), "UTF-8");
+ String body = new String(msg.getData(), StandardCharsets.UTF_8);
AuditData msgBody = gson.fromJson(body, AuditData.class);
if (storeConfig.isMysqlStore()) {
AuditDataPo po = new AuditDataPo();
diff --git a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/ElasticsearchService.java b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/ElasticsearchService.java
index 3920e57..ca57356 100644
--- a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/ElasticsearchService.java
+++ b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/ElasticsearchService.java
@@ -57,14 +57,11 @@ import java.util.concurrent.TimeUnit;
@Service
public class ElasticsearchService implements AutoCloseable {
- private static final Logger LOG = LoggerFactory
- .getLogger(ElasticsearchService.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchService.class);
private static ScheduledExecutorService timerService = Executors.newScheduledThreadPool(1);
-
- private List<ESDataPo> datalist = new ArrayList<>();
private final Semaphore semaphore = new Semaphore(1);
-
+ private List<ESDataPo> datalist = new ArrayList<>();
@Autowired
@Qualifier("restClient")
private RestHighLevelClient client;
@@ -77,9 +74,9 @@ public class ElasticsearchService implements AutoCloseable {
@Override
public void run() {
try {
- deleteTimeoutIndexs();
+ deleteTimeoutIndices();
} catch (IOException e) {
- LOG.error("deleteTimeoutIndexs has err {}", e);
+ LOG.error("deleteTimeoutIndices has err: ", e);
}
}
}), 1, 1, TimeUnit.DAYS);
@@ -90,7 +87,7 @@ public class ElasticsearchService implements AutoCloseable {
try {
bulkInsert();
} catch (IOException e) {
- LOG.error("bulkInsert has err {}", e);
+ LOG.error("bulkInsert has err: ", e);
}
}
}), esConfig.getBulkInterval(), esConfig.getBulkInterval(), TimeUnit.SECONDS);
@@ -105,7 +102,7 @@ public class ElasticsearchService implements AutoCloseable {
LOG.error("failed to bulk insert");
}
} catch (IOException e) {
- LOG.error("bulkInsert has err {}", e);
+ LOG.error("bulkInsert has err: ", e);
}
}
try {
@@ -113,7 +110,7 @@ public class ElasticsearchService implements AutoCloseable {
datalist.add(data);
semaphore.release();
} catch (InterruptedException e) {
- LOG.error("datalist semaphore has err {}", e);
+ LOG.error("datalist semaphore has err: ", e);
}
}
@@ -138,8 +135,7 @@ public class ElasticsearchService implements AutoCloseable {
protected boolean existsIndex(String index) throws IOException {
GetIndexRequest getIndexRequest = new GetIndexRequest();
getIndexRequest.indices(index);
- boolean isExits = client.indices().exists(getIndexRequest, RequestOptions.DEFAULT);
- return isExits;
+ return client.indices().exists(getIndexRequest, RequestOptions.DEFAULT);
}
protected boolean bulkInsert() throws IOException {
@@ -175,19 +171,19 @@ public class ElasticsearchService implements AutoCloseable {
semaphore.release();
return bulkResponse.status().equals(RestStatus.OK);
} catch (InterruptedException e) {
- LOG.error("datalist semaphore has err {}", e);
+ LOG.error("datalist semaphore has err: ", e);
}
return false;
}
- protected void deleteTimeoutIndexs() throws IOException {
+ protected void deleteTimeoutIndices() throws IOException {
List<String> auditIdList = esConfig.getAuditIdList();
if (auditIdList.isEmpty()) {
return;
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DATE, 0 - esConfig.getIndexDeleteDay());
+ calendar.add(Calendar.DATE, -esConfig.getIndexDeleteDay());
Date deleteDay = calendar.getTime();
String preIndex = formatter.format(deleteDay);
for (String auditId : auditIdList) {
@@ -213,11 +209,11 @@ public class ElasticsearchService implements AutoCloseable {
}
@Override
- public void close() throws Exception {
+ public void close() {
try {
bulkInsert();
} catch (IOException e) {
- LOG.error("bulkInsert has err {}", e);
+ LOG.error("bulkInsert has err: ", e);
}
timerService.shutdown();
}
diff --git a/inlong-audit/audit-store/src/main/resources/sql/apache_inlong_audit.sql b/inlong-audit/audit-store/src/main/resources/sql/apache_inlong_audit.sql
new file mode 100644
index 0000000..47d7227
--- /dev/null
+++ b/inlong-audit/audit-store/src/main/resources/sql/apache_inlong_audit.sql
@@ -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.
+ */
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET time_zone = "+00:00";
+
+-- ----------------------------
+-- database for Manager Web
+-- ----------------------------
+CREATE DATABASE IF NOT EXISTS apache_inlong_audit;
+USE apache_inlong_audit;
+
+CREATE TABLE `audit_data`
+(
+ `id` int(32) not null primary key auto_increment COMMENT 'id',
+ `ip` varchar(32) NOT NULL DEFAULT '' COMMENT 'client ip',
+ `docker_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'client docker id',
+ `thread_id` varchar(50) NOT NULL DEFAULT '' COMMENT 'client thread id',
+ `sdk_ts` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'sdk timestamp',
+ `packet_id` BIGINT NOT NULL DEFAULT '0' COMMENT '' COMMENT 'packet id',
+ `log_ts` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'log timestamp',
+ `inlong_group_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'inlong group id',
+ `inlong_stream_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'inlong stream id',
+ `audit_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'audit id',
+ `count` BIGINT NOT NULL DEFAULT '0' COMMENT 'msg count',
+ `size` BIGINT NOT NULL DEFAULT '0' COMMENT 'msg size',
+ `delay` BIGINT NOT NULL DEFAULT '0' COMMENT 'msg delay',
+ `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
+ INDEX ip_packet (`ip`, `inlong_group_id`, `inlong_stream_id`, `log_ts`)
+);
diff --git a/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/AuditStoreTest.java b/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/AuditStoreTest.java
index 60b23b0..e75ae33 100644
--- a/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/AuditStoreTest.java
+++ b/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/AuditStoreTest.java
@@ -18,10 +18,8 @@
package org.apache.inlong.audit.service;
import org.apache.pulsar.client.api.Consumer;
-import org.apache.pulsar.client.impl.ConsumerImpl;
import org.apache.pulsar.client.impl.PulsarClientImpl;
import org.apache.pulsar.client.impl.conf.ClientConfigurationData;
-import org.apache.pulsar.client.impl.conf.ConsumerConfigurationData;
import org.apache.pulsar.client.util.ExecutorProvider;
import org.apache.pulsar.shade.io.netty.channel.EventLoop;
import org.apache.pulsar.shade.io.netty.util.Timer;
@@ -29,42 +27,37 @@ import org.mockito.Mockito;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.concurrent.CompletableFuture;
-
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class AuditStoreTest {
- private ConsumerConfigurationData consumerConf;
-
- private AuditMsgConsumerServer auditMsgConsumerServer;
-
private PulsarClientImpl client;
+ private AuditMsgConsumerServer auditMsgConsumerServer;
static <T> PulsarClientImpl createPulsarClientMock() {
- PulsarClientImpl clientMock = mock(PulsarClientImpl.class, Mockito.RETURNS_DEEP_STUBS);
-
+ PulsarClientImpl mockClient = mock(PulsarClientImpl.class, Mockito.RETURNS_DEEP_STUBS);
ClientConfigurationData clientConf = new ClientConfigurationData();
- when(clientMock.getConfiguration()).thenReturn(clientConf);
- when(clientMock.timer()).thenReturn(mock(Timer.class));
+ when(mockClient.getConfiguration()).thenReturn(clientConf);
+ when(mockClient.timer()).thenReturn(mock(Timer.class));
- when(clientMock.externalExecutorProvider()).thenReturn(mock(ExecutorProvider.class));
- when(clientMock.eventLoopGroup().next()).thenReturn(mock(EventLoop.class));
+ when(mockClient.externalExecutorProvider()).thenReturn(mock(ExecutorProvider.class));
+ when(mockClient.eventLoopGroup().next()).thenReturn(mock(EventLoop.class));
- return clientMock;
+ return mockClient;
}
@BeforeMethod
- public void setUp() {
- consumerConf = new ConsumerConfigurationData<>();
- PulsarClientImpl client = createPulsarClientMock();
+ public void setUp() throws Exception {
+ client = createPulsarClientMock();
ClientConfigurationData clientConf = client.getConfiguration();
clientConf.setOperationTimeoutMs(100);
clientConf.setStatsIntervalSeconds(0);
- CompletableFuture<Consumer<ConsumerImpl>> subscribeFuture = new CompletableFuture<>();
- consumerConf.setSubscriptionName("test-sub");
- auditMsgConsumerServer = new AuditMsgConsumerServer();
+
+ Consumer<byte[]> consumer = client.newConsumer().subscribe();
+ auditMsgConsumerServer = mock(AuditMsgConsumerServer.class);
+ when(auditMsgConsumerServer.createConsumer(any(), any())).thenReturn(consumer);
}
@Test
@@ -72,4 +65,5 @@ public class AuditStoreTest {
String topic = "non-persistent://public/default/audit-test";
auditMsgConsumerServer.createConsumer(client, topic);
}
+
}
diff --git a/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/ElasticsearchServiceTest.java b/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/ElasticsearchServiceTest.java
index 588b0f0..47abff7 100644
--- a/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/ElasticsearchServiceTest.java
+++ b/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/ElasticsearchServiceTest.java
@@ -17,13 +17,13 @@
package org.apache.inlong.audit.service;
-import org.apache.inlong.audit.Application;
import org.apache.inlong.audit.db.entities.ESDataPo;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.testng.Assert;
@@ -34,14 +34,13 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
+@ActiveProfiles(value = {"test"})
+@SpringBootTest(classes = ElasticsearchServiceTest.class)
public class ElasticsearchServiceTest {
-// @Autowired
private static ElasticsearchService elasticsearchService;
- private String index1 = "20220112_1";
- private String index2 = "20220112_10";
+ private final String index = "20220112_1";
@BeforeClass
public static void setUp() throws IOException {
@@ -53,23 +52,23 @@ public class ElasticsearchServiceTest {
@Test
public void testExistsIndex() throws IOException {
- boolean res = elasticsearchService.createIndex(index1);
- Assert.assertEquals(res, true);
+ boolean res = elasticsearchService.createIndex(index);
+ Assert.assertTrue(res);
- res = elasticsearchService.existsIndex(index1);
- Assert.assertEquals(res, true);
+ res = elasticsearchService.existsIndex(index);
+ Assert.assertTrue(res);
}
@Test
public void testInsertData() {
- for (int i = 0; i < 11; i++) {
+ for (int i = 0; i < 5; i++) {
ESDataPo po = new ESDataPo();
po.setIp("0.0.0.0");
po.setThreadId(String.valueOf(i));
po.setDockerId(String.valueOf(i));
po.setSdkTs(new Date().getTime());
po.setLogTs(new Date());
- po.setAuditId("3");
+ po.setAuditId("1");
po.setCount(i);
po.setDelay(i);
po.setInlongGroupId(String.valueOf(i));
@@ -77,34 +76,20 @@ public class ElasticsearchServiceTest {
po.setSize(i);
po.setPacketId(i);
elasticsearchService.insertData(po);
- ESDataPo po2 = new ESDataPo();
- po2.setIp("0.0.0.0");
- po2.setThreadId(String.valueOf(i));
- po2.setDockerId(String.valueOf(i));
- po2.setSdkTs(new Date().getTime());
- po2.setLogTs(new Date());
- po2.setAuditId("2");
- po2.setCount(i);
- po2.setDelay(i);
- po2.setInlongGroupId(String.valueOf(i));
- po2.setInlongStreamId(String.valueOf(i));
- po2.setSize(i);
- po2.setPacketId(i);
- elasticsearchService.insertData(po2);
}
}
@Test
public void testDeleteSingleIndex() throws IOException {
- boolean res = elasticsearchService.createIndex(index1);
- Assert.assertEquals(res, true);
- res = elasticsearchService.deleteSingleIndex(index1);
- Assert.assertEquals(res, true);
+ boolean res = elasticsearchService.createIndex(index);
+ Assert.assertTrue(res);
+ res = elasticsearchService.deleteSingleIndex(index);
+ Assert.assertTrue(res);
}
@Test
- public void testDeleteTimeoutIndexs() throws IOException {
- elasticsearchService.deleteTimeoutIndexs();
+ public void testDeleteTimeoutIndices() throws IOException {
+ elasticsearchService.deleteTimeoutIndices();
}
}
diff --git a/inlong-audit/audit-store/src/test/resources/application.properties b/inlong-audit/audit-store/src/test/resources/application-test.properties
similarity index 83%
rename from inlong-audit/audit-store/src/test/resources/application.properties
rename to inlong-audit/audit-store/src/test/resources/application-test.properties
index 7ab9b4a..aaf5796 100644
--- a/inlong-audit/audit-store/src/test/resources/application.properties
+++ b/inlong-audit/audit-store/src/test/resources/application-test.properties
@@ -18,13 +18,14 @@
#
# datasource config, set org.postgresql.Driver if using PostgreSQL
-spring.datasource.driver-class-name = com.mysql.jdbc.Driver
-spring.datasource.name = druidDataSource
-spring.datasource.type = com.alibaba.druid.pool.DruidDataSource
-spring.datasource.druid.driver-class-name= com.mysql.cj.jdbc.Driver
-spring.datasource.druid.url= jdbc:mysql://127.0.0.1:3306/apache_inlong_audit?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2b8&rewriteBatchedStatements=true&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.druid.driver-class-name=org.h2.Driver
+spring.datasource.schema=classpath:sql/apache_inlong_audit.sql
+
+spring.datasource.druid.url=jdbc:h2:mem:test;MODE=MYSQL;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE;
spring.datasource.druid.username=root
-spring.datasource.druid.password=inlong
+spring.datasource.druid.password=""
+
spring.datasource.druid.filters=stat,log4j,config
spring.datasource.druid.max-active=100
spring.datasource.druid.initial-size=1