From d9533c53ea79b3dc00a401a0108b828e20962d86 Mon Sep 17 00:00:00 2001 From: lexluo09 <39718951+lexluo09@users.noreply.github.com> Date: Fri, 26 Jan 2024 17:54:46 +0800 Subject: [PATCH] [improvement][Headless] Fix the issue with test metric recommendations, integrate testing with compilation. (#692) --- launchers/standalone/pom.xml | 6 + .../src/main/resources/db/data-h2.sql | 170 ++++++++--------- .../src/main/resources/db/schema-h2.sql | 41 +++-- .../tencent/supersonic/BaseApplication.java | 10 + .../supersonic/chat/integration/BaseTest.java | 46 ++--- .../chat/integration/MetricInterpretTest.java | 13 +- .../chat/integration/MetricTest.java | 2 +- .../chat/integration/MultiTurnsTest.java | 94 ++-------- .../supersonic/chat/integration/TagTest.java | 4 +- .../chat/integration/mapper/MapperTest.java | 6 +- .../model/MetricServiceImplTest.java | 11 +- .../integration/plugin/BasePluginTest.java | 13 +- .../plugin/PluginRecognizeTest.java | 8 +- .../chat/integration/util/DataUtils.java | 6 +- .../headless/integration/BaseTest.java | 11 +- .../headless/integration/ExplainTest.java | 3 +- .../headless/integration/QueryBySqlTest.java | 2 +- .../integration/QueryByStructTest.java | 2 +- .../src/test/resources/db/data-h2.sql | 172 +++++++++--------- .../src/test/resources/db/schema-h2.sql | 41 +++-- 20 files changed, 298 insertions(+), 363 deletions(-) create mode 100644 launchers/standalone/src/test/java/com/tencent/supersonic/BaseApplication.java diff --git a/launchers/standalone/pom.xml b/launchers/standalone/pom.xml index 804410b95..b2a3c435b 100644 --- a/launchers/standalone/pom.xml +++ b/launchers/standalone/pom.xml @@ -95,6 +95,12 @@ spring-boot-starter-test test + + org.testng + testng + ${org.testng.version} + test + diff --git a/launchers/standalone/src/main/resources/db/data-h2.sql b/launchers/standalone/src/main/resources/db/data-h2.sql index 6050f794b..5860e3f0b 100644 --- a/launchers/standalone/src/main/resources/db/data-h2.sql +++ b/launchers/standalone/src/main/resources/db/data-h2.sql @@ -1,78 +1,78 @@ -- sample user -insert into s2_user (id, `name`, password, display_name, email, is_admin) values (1, 'admin','admin','admin','admin@xx.com', 1); -insert into s2_user (id, `name`, password, display_name, email) values (2, 'jack','123456','jack','jack@xx.com'); -insert into s2_user (id, `name`, password, display_name, email) values (3, 'tom','123456','tom','tom@xx.com'); -insert into s2_user (id, `name`, password, display_name, email, is_admin) values (4, 'lucy','123456','lucy','lucy@xx.com', 1); -insert into s2_user (id, `name`, password, display_name, email) values (5, 'alice','123456','alice','alice@xx.com'); +MERGE INTO s2_user (id, `name`, password, display_name, email, is_admin) values (1, 'admin','admin','admin','admin@xx.com', 1); +MERGE INTO s2_user (id, `name`, password, display_name, email) values (2, 'jack','123456','jack','jack@xx.com'); +MERGE INTO s2_user (id, `name`, password, display_name, email) values (3, 'tom','123456','tom','tom@xx.com'); +MERGE INTO s2_user (id, `name`, password, display_name, email, is_admin) values (4, 'lucy','123456','lucy','lucy@xx.com', 1); +MERGE INTO s2_user (id, `name`, password, display_name, email) values (5, 'alice','123456','alice','alice@xx.com'); -insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) -values (1, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); -insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) -values (2, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); -insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) -values (3, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); +MERGE INTO s2_available_date_info(`id`,`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) +values (1 , 1, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); +MERGE INTO s2_available_date_info(`id`,`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) +values (2 , 2, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); +MERGE INTO s2_available_date_info(`id`,`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) +values (3 , 3, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); -insert into s2_view_info(`id`, `domain_id`, `type`, `config` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) +MERGE INTO s2_view_info(`id`, `domain_id`, `type`, `config` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) values (1, 1, 'modelEdgeRelation', '[{"source":"datasource-1","target":"datasource-3","type":"polyline","id":"edge-0.305251275235679741702883718912","style":{"active":{"stroke":"rgb(95, 149, 255)","lineWidth":1},"selected":{"stroke":"rgb(95, 149, 255)","lineWidth":2,"shadowColor":"rgb(95, 149, 255)","shadowBlur":10,"text-shape":{"fontWeight":500}},"highlight":{"stroke":"rgb(95, 149, 255)","lineWidth":2,"text-shape":{"fontWeight":500}},"inactive":{"stroke":"rgb(234, 234, 234)","lineWidth":1},"disable":{"stroke":"rgb(245, 245, 245)","lineWidth":1},"stroke":"#296df3","endArrow":true},"startPoint":{"x":-94,"y":-137.5,"anchorIndex":0,"id":"-94|||-137.5"},"endPoint":{"x":-234,"y":-45,"anchorIndex":1,"id":"-234|||-45"},"sourceAnchor":2,"targetAnchor":1,"label":"模型关系编辑"},{"source":"datasource-1","target":"datasource-2","type":"polyline","id":"edge-0.466237264629309141702883756359","style":{"active":{"stroke":"rgb(95, 149, 255)","lineWidth":1},"selected":{"stroke":"rgb(95, 149, 255)","lineWidth":2,"shadowColor":"rgb(95, 149, 255)","shadowBlur":10,"text-shape":{"fontWeight":500}},"highlight":{"stroke":"rgb(95, 149, 255)","lineWidth":2,"text-shape":{"fontWeight":500}},"inactive":{"stroke":"rgb(234, 234, 234)","lineWidth":1},"disable":{"stroke":"rgb(245, 245, 245)","lineWidth":1},"stroke":"#296df3","endArrow":true},"startPoint":{"x":-12,"y":-137.5,"anchorIndex":1,"id":"-12|||-137.5"},"endPoint":{"x":85,"y":31.5,"anchorIndex":0,"id":"85|||31.5"},"sourceAnchor":1,"targetAnchor":2,"label":"模型关系编辑"}]', '2023-06-01', 'admin', '2023-06-01', 'admin'); -- sample data -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); ---demo data for semantic and chat -insert into s2_user_department (user_name, department) values ('jack','HR'); +MERGE INTO s2_user_department (user_name, department) values ('jack','HR'); -insert into s2_user_department (user_name, department) values ('jack','HR'); -insert into s2_user_department (user_name, department) values ('tom','sales'); -insert into s2_user_department (user_name, department) values ('lucy','marketing'); -insert into s2_user_department (user_name, department) values ('john','strategy'); -insert into s2_user_department (user_name, department) values ('alice','sales'); -insert into s2_user_department (user_name, department) values ('dean','marketing'); +MERGE INTO s2_user_department (user_name, department) values ('jack','HR'); +MERGE INTO s2_user_department (user_name, department) values ('tom','sales'); +MERGE INTO s2_user_department (user_name, department) values ('lucy','marketing'); +MERGE INTO s2_user_department (user_name, department) values ('john','strategy'); +MERGE INTO s2_user_department (user_name, department) values ('alice','sales'); +MERGE INTO s2_user_department (user_name, department) values ('dean','marketing'); INSERT INTO s2_pv_uv_statis (imp_date, user_name, page) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), 'lucy', 'p1'); @@ -1083,32 +1083,32 @@ INSERT INTO s2_stay_time_statis (imp_date, user_name, stay_hours, page) VALUES ( -insert into genre(g_name,rating,most_popular_in) VALUES ('tagore',8,'孟加拉国'); -insert into genre(g_name,rating,most_popular_in) VALUES ('nazrul',7,'孟加拉国'); -insert into genre(g_name,rating,most_popular_in) VALUES ('民间',9,'锡尔赫特、吉大港、库斯蒂亚'); -insert into genre(g_name,rating,most_popular_in) VALUES ('现代',8,'孟加拉国'); -insert into genre(g_name,rating,most_popular_in) VALUES ('蓝调',7,'加拿大'); -insert into genre(g_name,rating,most_popular_in) VALUES ('流行',9,'美国'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('tagore',8,'孟加拉国'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('nazrul',7,'孟加拉国'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('民间',9,'锡尔赫特、吉大港、库斯蒂亚'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('现代',8,'孟加拉国'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('蓝调',7,'加拿大'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('流行',9,'美国'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Shrikanta','印度','男性','tagore'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Prity','孟加拉国','女性','nazrul'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Farida','孟加拉国','女性','民间'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Topu','印度','女性','现代'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Enrique','美国','男性','蓝调'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Michel','英国','男性','流行'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Shrikanta','印度','男性','tagore'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Prity','孟加拉国','女性','nazrul'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Farida','孟加拉国','女性','民间'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Topu','印度','女性','现代'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Enrique','美国','男性','蓝调'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Michel','英国','男性','流行'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (1,'Shrikanta','3.78 MB','3:45','mp4'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (2,'Prity','4.12 MB','2:56','mp3'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (3,'Farida','3.69 MB','4:12','mp4'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (4,'Enrique','4.58 MB','5:23','mp4'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (5,'Michel','5.10 MB','4:34','mp3'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (6,'Topu','4.10 MB','4:30','mp4'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (1,'Shrikanta','3.78 MB','3:45','mp4'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (2,'Prity','4.12 MB','2:56','mp3'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (3,'Farida','3.69 MB','4:12','mp4'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (4,'Enrique','4.58 MB','5:23','mp4'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (5,'Michel','5.10 MB','4:34','mp3'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (6,'Topu','4.10 MB','4:30','mp4'); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'Tumi 长袍 尼罗布','Shrikanta','印度',1,'tagore',8,'孟加拉语','28-AUG-2011',1080); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'舒克诺 帕塔尔 努普尔 帕埃','Prity','孟加拉国',2,'nazrul',5,'孟加拉语','21-SEP-1997',512); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'阿米·奥帕尔·霍伊','Farida','孟加拉国',3,'民间',7,'孟加拉语','7-APR-2001',320); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'我的爱','Enrique','美国',4,'蓝调',6,'英文','24-JAN-2007',1080); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'打败它','Michel','英国',5,'流行',8,'英文','17-MAR-2002',720); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'阿杰伊阿卡什','Topu','印度',6,'现代',10,'孟加拉语','27-MAR-2004',320); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'Tumi 长袍 尼罗布','Shrikanta','印度',1,'tagore',8,'孟加拉语','28-AUG-2011',1080); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'舒克诺 帕塔尔 努普尔 帕埃','Prity','孟加拉国',2,'nazrul',5,'孟加拉语','21-SEP-1997',512); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'阿米·奥帕尔·霍伊','Farida','孟加拉国',3,'民间',7,'孟加拉语','7-APR-2001',320); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'我的爱','Enrique','美国',4,'蓝调',6,'英文','24-JAN-2007',1080); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'打败它','Michel','英国',5,'流行',8,'英文','17-MAR-2002',720); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'阿杰伊阿卡什','Topu','印度',6,'现代',10,'孟加拉语','27-MAR-2004',320); -- benchmark diff --git a/launchers/standalone/src/main/resources/db/schema-h2.sql b/launchers/standalone/src/main/resources/db/schema-h2.sql index b1ff86027..273ad467f 100644 --- a/launchers/standalone/src/main/resources/db/schema-h2.sql +++ b/launchers/standalone/src/main/resources/db/schema-h2.sql @@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS `s2_chat` ) ; -CREATE TABLE `s2_chat_query` +CREATE TABLE IF NOT EXISTS `s2_chat_query` ( `question_id` BIGINT NOT NULL AUTO_INCREMENT, `agent_id` INT NULL, @@ -41,7 +41,7 @@ CREATE TABLE `s2_chat_query` PRIMARY KEY (`question_id`) ); -CREATE TABLE `s2_chat_parse` +CREATE TABLE IF NOT EXISTS `s2_chat_parse` ( `question_id` BIGINT NOT NULL, `chat_id` BIGINT NOT NULL , @@ -53,7 +53,7 @@ CREATE TABLE `s2_chat_parse` `is_candidate` INT DEFAULT 1 COMMENT '1是candidate,0是selected' ); -CREATE TABLE `s2_chat_statistics` +CREATE TABLE IF NOT EXISTS `s2_chat_statistics` ( `question_id` BIGINT NOT NULL, `chat_id` BIGINT NOT NULL , @@ -82,7 +82,7 @@ CREATE TABLE IF NOT EXISTS `s2_chat_config` ( COMMENT ON TABLE s2_chat_config IS 'chat config information table '; -create table s2_user +create table IF NOT EXISTS s2_user ( id INT AUTO_INCREMENT, name varchar(100) not null, @@ -144,7 +144,7 @@ CREATE TABLE IF NOT EXISTS `s2_model` ( COMMENT ON TABLE s2_model IS 'model information'; -CREATE TABLE `s2_database` ( +CREATE TABLE IF NOT EXISTS `s2_database` ( `id` INT NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL , `description` varchar(500) DEFAULT NULL , @@ -161,7 +161,7 @@ CREATE TABLE `s2_database` ( ); COMMENT ON TABLE s2_database IS 'database instance table'; -create table s2_auth_groups +create table IF NOT EXISTS s2_auth_groups ( group_id INT, config varchar(2048), @@ -219,7 +219,7 @@ CREATE TABLE IF NOT EXISTS `s2_dimension` ( ); COMMENT ON TABLE s2_dimension IS 'dimension information table'; -CREATE TABLE s2_model_rela +CREATE TABLE IF NOT EXISTS s2_model_rela ( id BIGINT AUTO_INCREMENT, domain_id BIGINT, @@ -230,7 +230,7 @@ CREATE TABLE s2_model_rela PRIMARY KEY (`id`) ); -create table s2_view_info +create table IF NOT EXISTS s2_view_info ( id INT auto_increment, domain_id INT null, @@ -239,12 +239,13 @@ create table s2_view_info created_at TIMESTAMP null, created_by varchar(100) null, updated_at TIMESTAMP null, - updated_by varchar(100) not null + updated_by varchar(100) not null, + PRIMARY KEY (`id`) ); COMMENT ON TABLE s2_view_info IS 'view information table'; -CREATE TABLE `s2_query_stat_info` ( +CREATE TABLE IF NOT EXISTS `s2_query_stat_info` ( `id` INT NOT NULL AUTO_INCREMENT, `trace_id` varchar(200) DEFAULT NULL, -- query unique identifier `model_id` INT DEFAULT NULL, @@ -359,7 +360,8 @@ CREATE TABLE IF NOT EXISTS s2_agent -------demo for semantic and chat CREATE TABLE IF NOT EXISTS `s2_user_department` ( `user_name` varchar(200) NOT NULL, - `department` varchar(200) NOT NULL -- department of user + `department` varchar(200) NOT NULL, -- department of user + PRIMARY KEY (`user_name`,`department`) ); COMMENT ON TABLE s2_user_department IS 'user_department_info'; @@ -386,7 +388,8 @@ CREATE TABLE IF NOT EXISTS `singer` ( `genre` varchar(200) NOT NULL, `js_play_cnt` bigINT DEFAULT NULL, `down_cnt` bigINT DEFAULT NULL, - `favor_cnt` bigINT DEFAULT NULL + `favor_cnt` bigINT DEFAULT NULL, + PRIMARY KEY (`imp_date`, `singer_name`) ); COMMENT ON TABLE singer IS 'singer_info'; @@ -422,7 +425,8 @@ CREATE TABLE IF NOT EXISTS `artist` ( `artist_name` varchar(50) NOT NULL , -- genre name `country` varchar(20) , `gender` varchar(20) , - `g_name` varchar(50) + `g_name` varchar(50), + PRIMARY KEY (`artist_name`,`country`) ); COMMENT ON TABLE artist IS 'artist'; @@ -446,18 +450,19 @@ CREATE TABLE IF NOT EXISTS `song` ( `rating` INT , `languages` varchar(20) , `releasedate` varchar(50) , - `resolution` bigINT NOT NULL + `resolution` bigINT NOT NULL, + PRIMARY KEY (`imp_date`,`song_name`) ); COMMENT ON TABLE song IS 'song'; -CREATE TABLE s2_sys_parameter +CREATE TABLE IF NOT EXISTS s2_sys_parameter ( id INT PRIMARY KEY AUTO_INCREMENT, admin varchar(500), parameters text null ); -CREATE TABLE `s2_collect` ( +CREATE TABLE IF NOT EXISTS `s2_collect` ( `id` bigint NOT NULL AUTO_INCREMENT, `type` varchar(20) NOT NULL, `username` varchar(20) NOT NULL, @@ -467,7 +472,7 @@ CREATE TABLE `s2_collect` ( PRIMARY KEY (`id`) ); -CREATE TABLE `s2_metric_query_default_config` ( +CREATE TABLE IF NOT EXISTS `s2_metric_query_default_config` ( `id` bigint NOT NULL AUTO_INCREMENT, `metric_id` bigint , `user_name` varchar(255) NOT NULL, @@ -479,7 +484,7 @@ CREATE TABLE `s2_metric_query_default_config` ( PRIMARY KEY (`id`) ); -CREATE TABLE `s2_app` ( +CREATE TABLE IF NOT EXISTS `s2_app` ( id bigint AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), description VARCHAR(255), diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/BaseApplication.java b/launchers/standalone/src/test/java/com/tencent/supersonic/BaseApplication.java new file mode 100644 index 000000000..b751e1b53 --- /dev/null +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/BaseApplication.java @@ -0,0 +1,10 @@ +package com.tencent.supersonic; + +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +@SpringBootTest(classes = {StandaloneLauncher.class}) +@ActiveProfiles("local") +public class BaseApplication { + +} diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/BaseTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/BaseTest.java index d789eb40a..be488818e 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/BaseTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/BaseTest.java @@ -2,8 +2,7 @@ package com.tencent.supersonic.chat.integration; import static org.junit.Assert.assertEquals; -import com.tencent.supersonic.chat.integration.util.DataUtils; -import com.tencent.supersonic.StandaloneLauncher; +import com.tencent.supersonic.BaseApplication; import com.tencent.supersonic.chat.api.pojo.SchemaElement; import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo; import com.tencent.supersonic.chat.api.pojo.request.ExecuteQueryReq; @@ -12,25 +11,20 @@ import com.tencent.supersonic.chat.api.pojo.response.ParseResp; import com.tencent.supersonic.chat.api.pojo.response.QueryResult; import com.tencent.supersonic.chat.api.pojo.response.QueryState; import com.tencent.supersonic.chat.core.pojo.ChatContext; +import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.chat.server.service.AgentService; import com.tencent.supersonic.chat.server.service.ChatService; import com.tencent.supersonic.chat.server.service.ConfigService; import com.tencent.supersonic.chat.server.service.QueryService; import java.time.LocalDate; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; -import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = StandaloneLauncher.class) -@ActiveProfiles("local") -public class BaseTest { +public class BaseTest extends BaseApplication { protected final int unit = 7; protected final String startDay = LocalDate.now().plusDays(-unit).toString(); @@ -47,34 +41,37 @@ public class BaseTest { @MockBean protected AgentService agentService; - protected QueryResult submitMultiTurnChat(String queryText, Integer agentId) throws Exception { - ParseResp parseResp = submitParse(queryText, agentId); + protected QueryResult submitMultiTurnChat(String queryText, Integer agentId, Integer chatId) throws Exception { + ParseResp parseResp = submitParse(queryText, agentId, chatId); + SemanticParseInfo semanticParseInfo = parseResp.getSelectedParses().get(0); ExecuteQueryReq request = ExecuteQueryReq.builder() .agentId(agentId) .queryId(parseResp.getQueryId()) - .parseId(parseResp.getSelectedParses().get(0).getId()) + .parseId(semanticParseInfo.getId()) .chatId(parseResp.getChatId()) .queryText(parseResp.getQueryText()) .user(DataUtils.getUser()) - .parseInfo(parseResp.getSelectedParses().get(0)) + .parseInfo(semanticParseInfo) .saveAnswer(true) .build(); - - return queryService.performExecution(request); + QueryResult queryResult = queryService.performExecution(request); + queryResult.setChatContext(semanticParseInfo); + return queryResult; } protected QueryResult submitNewChat(String queryText, Integer agentId) throws Exception { ParseResp parseResp = submitParse(queryText, agentId); + SemanticParseInfo parseInfo = parseResp.getSelectedParses().get(0); ExecuteQueryReq request = ExecuteQueryReq.builder() .agentId(agentId) .queryId(parseResp.getQueryId()) - .parseId(parseResp.getSelectedParses().get(0).getId()) + .parseId(parseInfo.getId()) .chatId(parseResp.getChatId()) .queryText(parseResp.getQueryText()) .user(DataUtils.getUser()) - .parseInfo(parseResp.getSelectedParses().get(0)) + .parseInfo(parseInfo) .saveAnswer(true) .build(); @@ -83,16 +80,23 @@ public class BaseTest { ChatContext chatContext = chatService.getOrCreateContext(parseResp.getChatId()); chatContext.setParseInfo(new SemanticParseInfo()); chatService.updateContext(chatContext); - + result.setChatContext(parseInfo); return result; } - protected ParseResp submitParse(String queryText, Integer agentId) { - QueryReq queryContextReq = DataUtils.getQueryContextReq(10, queryText); + protected ParseResp submitParse(String queryText, Integer agentId, Integer chatId) { + if (Objects.isNull(chatId)) { + chatId = 10; + } + QueryReq queryContextReq = DataUtils.getQueryContextReq(chatId, queryText); queryContextReq.setAgentId(agentId); return queryService.performParsing(queryContextReq); } + protected ParseResp submitParse(String queryText, Integer agentId) { + return submitParse(queryText, agentId, 10); + } + protected ParseResp submitParseWithAgent(String queryText, Integer agentId) { QueryReq queryContextReq = DataUtils.getQueryReqWithAgent(10, queryText, agentId); return queryService.performParsing(queryContextReq); diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MetricInterpretTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MetricInterpretTest.java index 4cb625f15..78114f429 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MetricInterpretTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MetricInterpretTest.java @@ -1,20 +1,13 @@ package com.tencent.supersonic.chat.integration; -import com.tencent.supersonic.StandaloneLauncher; +import com.tencent.supersonic.BaseApplication; import com.tencent.supersonic.chat.core.query.llm.analytics.LLMAnswerResp; import com.tencent.supersonic.chat.server.service.AgentService; import com.tencent.supersonic.common.config.EmbeddingConfig; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; +import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = StandaloneLauncher.class) -@ActiveProfiles("local") -public class MetricInterpretTest { +public class MetricInterpretTest extends BaseApplication { @MockBean private AgentService agentService; diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MetricTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MetricTest.java index d96c882da..73dd8bcc1 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MetricTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MetricTest.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MetricTest extends BaseTest { diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MultiTurnsTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MultiTurnsTest.java index 732ed1b87..766a2a981 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MultiTurnsTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/MultiTurnsTest.java @@ -2,18 +2,15 @@ package com.tencent.supersonic.chat.integration; import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE; -import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo; import com.tencent.supersonic.chat.api.pojo.response.QueryResult; import com.tencent.supersonic.chat.core.query.rule.metric.MetricFilterQuery; -import com.tencent.supersonic.chat.core.query.rule.metric.MetricGroupByQuery; +import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.common.pojo.DateConf; -import com.tencent.supersonic.common.pojo.enums.QueryType; import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import org.junit.Test; +import com.tencent.supersonic.common.pojo.enums.QueryType; import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; public class MultiTurnsTest extends BaseTest { @@ -21,7 +18,8 @@ public class MultiTurnsTest extends BaseTest { @Order(1) public void queryTest_01() throws Exception { MockConfiguration.mockMetricAgent(agentService); - QueryResult actualResult = submitMultiTurnChat("alice的访问次数", DataUtils.metricAgentId); + QueryResult actualResult = submitMultiTurnChat("alice的访问次数", + DataUtils.metricAgentId, DataUtils.MULTI_TURNS_CHAT_ID); QueryResult expectedResult = new QueryResult(); SemanticParseInfo expectedParseInfo = new SemanticParseInfo(); @@ -31,9 +29,10 @@ public class MultiTurnsTest extends BaseTest { expectedParseInfo.setAggType(NONE); expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数")); + expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数")); expectedParseInfo.getDimensionFilters().add(DataUtils.getFilter("user_name", - FilterOperatorEnum.EQUALS, "alice", "用户名", 2L)); + FilterOperatorEnum.EQUALS, "alice", "用户", 2L)); expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay)); expectedParseInfo.setQueryType(QueryType.METRIC); @@ -45,7 +44,8 @@ public class MultiTurnsTest extends BaseTest { @Order(2) public void queryTest_02() throws Exception { MockConfiguration.mockMetricAgent(agentService); - QueryResult actualResult = submitMultiTurnChat("停留时长呢", DataUtils.metricAgentId); + QueryResult actualResult = submitMultiTurnChat("停留时长呢", DataUtils.metricAgentId, + DataUtils.MULTI_TURNS_CHAT_ID); QueryResult expectedResult = new QueryResult(); SemanticParseInfo expectedParseInfo = new SemanticParseInfo(); @@ -57,7 +57,7 @@ public class MultiTurnsTest extends BaseTest { expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("停留时长")); expectedParseInfo.getDimensionFilters().add(DataUtils.getFilter("user_name", - FilterOperatorEnum.EQUALS, "alice", "用户名", 2L)); + FilterOperatorEnum.EQUALS, "alice", "用户", 2L)); expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay)); expectedParseInfo.setQueryType(QueryType.METRIC); @@ -69,7 +69,8 @@ public class MultiTurnsTest extends BaseTest { @Order(3) public void queryTest_03() throws Exception { MockConfiguration.mockMetricAgent(agentService); - QueryResult actualResult = submitMultiTurnChat("lucy的如何", DataUtils.metricAgentId); + QueryResult actualResult = submitMultiTurnChat("lucy的如何", DataUtils.metricAgentId, + DataUtils.MULTI_TURNS_CHAT_ID); QueryResult expectedResult = new QueryResult(); SemanticParseInfo expectedParseInfo = new SemanticParseInfo(); @@ -81,7 +82,7 @@ public class MultiTurnsTest extends BaseTest { expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("停留时长")); expectedParseInfo.getDimensionFilters().add(DataUtils.getFilter("user_name", - FilterOperatorEnum.EQUALS, "lucy", "用户名", 2L)); + FilterOperatorEnum.EQUALS, "lucy", "用户", 2L)); expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay)); expectedParseInfo.setQueryType(QueryType.METRIC); @@ -89,73 +90,4 @@ public class MultiTurnsTest extends BaseTest { assertQueryResult(expectedResult, actualResult); } - @Test - @Order(4) - public void queryTest_04() throws Exception { - MockConfiguration.mockMetricAgent(agentService); - QueryResult actualResult = submitMultiTurnChat("按部门统计", DataUtils.metricAgentId); - - QueryResult expectedResult = new QueryResult(); - SemanticParseInfo expectedParseInfo = new SemanticParseInfo(); - expectedResult.setChatContext(expectedParseInfo); - - expectedResult.setQueryMode(MetricGroupByQuery.QUERY_MODE); - expectedParseInfo.setAggType(NONE); - - expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("停留时长")); - expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("部门")); - - expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay)); - expectedParseInfo.setQueryType(QueryType.METRIC); - - assertQueryResult(expectedResult, actualResult); - } - - @Test - @Order(5) - public void queryTest_05() throws Exception { - MockConfiguration.mockMetricAgent(agentService); - DateFormat format = new SimpleDateFormat("yyyy-mm-dd"); - DateFormat textFormat = new SimpleDateFormat("yyyy年mm月dd日"); - QueryResult actualResult = submitMultiTurnChat(textFormat.format(format.parse(startDay)), - DataUtils.metricAgentId); - - QueryResult expectedResult = new QueryResult(); - SemanticParseInfo expectedParseInfo = new SemanticParseInfo(); - expectedResult.setChatContext(expectedParseInfo); - - expectedResult.setQueryMode(MetricGroupByQuery.QUERY_MODE); - expectedParseInfo.setAggType(NONE); - - expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("停留时长")); - expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("部门")); - - expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.BETWEEN, 1, period, startDay, startDay)); - expectedParseInfo.setQueryType(QueryType.METRIC); - - assertQueryResult(expectedResult, actualResult); - } - - @Test - @Order(6) - public void queryTest_06() throws Exception { - MockConfiguration.mockMetricAgent(agentService); - QueryResult actualResult = submitMultiTurnChat("近30天", DataUtils.metricAgentId); - - QueryResult expectedResult = new QueryResult(); - SemanticParseInfo expectedParseInfo = new SemanticParseInfo(); - expectedResult.setChatContext(expectedParseInfo); - - expectedResult.setQueryMode(MetricGroupByQuery.QUERY_MODE); - expectedParseInfo.setAggType(NONE); - - expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("停留时长")); - expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("部门")); - - expectedParseInfo.setDateInfo(DataUtils.getDateConf(30, DateConf.DateMode.RECENT, "DAY")); - expectedParseInfo.setQueryType(QueryType.METRIC); - - assertQueryResult(expectedResult, actualResult); - } - } diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/TagTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/TagTest.java index 2f28ff446..abd3a7c95 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/TagTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/TagTest.java @@ -2,20 +2,20 @@ package com.tencent.supersonic.chat.integration; import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE; -import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.chat.api.pojo.SchemaElement; import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo; import com.tencent.supersonic.chat.api.pojo.request.QueryFilter; import com.tencent.supersonic.chat.api.pojo.response.QueryResult; import com.tencent.supersonic.chat.core.query.rule.metric.MetricTagQuery; import com.tencent.supersonic.chat.core.query.rule.tag.TagFilterQuery; +import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.common.pojo.DateConf; import com.tencent.supersonic.common.pojo.DateConf.DateMode; import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum; import com.tencent.supersonic.common.pojo.enums.QueryType; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TagTest extends BaseTest { diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/mapper/MapperTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/mapper/MapperTest.java index 9fdb5762f..8e5952ac1 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/mapper/MapperTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/mapper/MapperTest.java @@ -2,18 +2,18 @@ package com.tencent.supersonic.chat.integration.mapper; import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE; -import com.tencent.supersonic.chat.integration.BaseTest; -import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.chat.api.pojo.SchemaElement; import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo; import com.tencent.supersonic.chat.api.pojo.request.QueryFilter; import com.tencent.supersonic.chat.api.pojo.request.QueryReq; import com.tencent.supersonic.chat.api.pojo.response.QueryResult; import com.tencent.supersonic.chat.core.query.rule.metric.MetricTagQuery; +import com.tencent.supersonic.chat.integration.BaseTest; +import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.common.pojo.DateConf; import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum; import com.tencent.supersonic.common.pojo.enums.QueryType; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MapperTest extends BaseTest { diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/model/MetricServiceImplTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/model/MetricServiceImplTest.java index aa69ec648..e8a7038be 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/model/MetricServiceImplTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/model/MetricServiceImplTest.java @@ -1,23 +1,18 @@ package com.tencent.supersonic.chat.integration.model; import com.google.common.collect.Lists; -import com.tencent.supersonic.StandaloneLauncher; +import com.tencent.supersonic.BaseApplication; import com.tencent.supersonic.common.pojo.enums.SensitiveLevelEnum; import com.tencent.supersonic.headless.api.pojo.enums.MetricType; import com.tencent.supersonic.headless.api.pojo.response.MetricResp; import com.tencent.supersonic.headless.server.pojo.MetricFilter; import com.tencent.supersonic.headless.server.service.MetricService; +import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import java.util.List; - -@SpringBootTest(classes = StandaloneLauncher.class) -@ActiveProfiles("local") -public class MetricServiceImplTest { +public class MetricServiceImplTest extends BaseApplication { @Autowired protected MetricService metricService; diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/plugin/BasePluginTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/plugin/BasePluginTest.java index e5adb154b..7b1f96fcc 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/plugin/BasePluginTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/plugin/BasePluginTest.java @@ -1,23 +1,14 @@ package com.tencent.supersonic.chat.integration.plugin; -import com.tencent.supersonic.StandaloneLauncher; +import com.tencent.supersonic.BaseApplication; import com.tencent.supersonic.chat.api.pojo.response.QueryResult; import com.tencent.supersonic.chat.api.pojo.response.QueryState; import com.tencent.supersonic.chat.core.query.plugin.WebBase; import com.tencent.supersonic.chat.core.query.plugin.webpage.WebPageQuery; import com.tencent.supersonic.chat.core.query.plugin.webpage.WebPageResp; -import lombok.extern.slf4j.Slf4j; import org.junit.Assert; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = StandaloneLauncher.class) -@ActiveProfiles("local") -@Slf4j -public class BasePluginTest { +public class BasePluginTest extends BaseApplication { protected void assertPluginRecognizeResult(QueryResult queryResult) { Assert.assertEquals(queryResult.getQueryState(), QueryState.SUCCESS); diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/plugin/PluginRecognizeTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/plugin/PluginRecognizeTest.java index 4c03786ea..a3599d2bd 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/plugin/PluginRecognizeTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/plugin/PluginRecognizeTest.java @@ -1,6 +1,5 @@ package com.tencent.supersonic.chat.integration.plugin; -import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.chat.api.pojo.request.ExecuteQueryReq; import com.tencent.supersonic.chat.api.pojo.request.QueryFilter; import com.tencent.supersonic.chat.api.pojo.request.QueryFilters; @@ -8,12 +7,12 @@ import com.tencent.supersonic.chat.api.pojo.request.QueryReq; import com.tencent.supersonic.chat.api.pojo.response.ParseResp; import com.tencent.supersonic.chat.api.pojo.response.QueryResult; import com.tencent.supersonic.chat.core.plugin.PluginManager; +import com.tencent.supersonic.chat.integration.MockConfiguration; +import com.tencent.supersonic.chat.integration.util.DataUtils; import com.tencent.supersonic.chat.server.service.AgentService; import com.tencent.supersonic.chat.server.service.QueryService; import com.tencent.supersonic.common.config.EmbeddingConfig; -import com.tencent.supersonic.chat.integration.MockConfiguration; import org.junit.Assert; -import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.mock.mockito.MockBean; @@ -33,7 +32,6 @@ public class PluginRecognizeTest extends BasePluginTest { @Qualifier("chatQueryService") private QueryService queryService; - @Test public void webPageRecognize() throws Exception { MockConfiguration.mockEmbeddingRecognize(pluginManager, "alice最近的访问情况怎么样", "1"); MockConfiguration.mockEmbeddingUrl(embeddingConfig); @@ -51,7 +49,6 @@ public class PluginRecognizeTest extends BasePluginTest { assertPluginRecognizeResult(queryResult); } - @Test public void webPageRecognizeWithQueryFilter() throws Exception { MockConfiguration.mockEmbeddingRecognize(pluginManager, "在超音数最近的情况怎么样", "1"); MockConfiguration.mockEmbeddingUrl(embeddingConfig); @@ -76,7 +73,6 @@ public class PluginRecognizeTest extends BasePluginTest { assertPluginRecognizeResult(queryResult); } - @Test public void pluginRecognizeWithAgent() { MockConfiguration.mockEmbeddingRecognize(pluginManager, "alice最近的访问情况怎么样", "1"); MockConfiguration.mockEmbeddingUrl(embeddingConfig); diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/util/DataUtils.java b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/util/DataUtils.java index 744ffc60f..aff00556c 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/util/DataUtils.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/chat/integration/util/DataUtils.java @@ -1,5 +1,7 @@ package com.tencent.supersonic.chat.integration.util; +import static java.time.LocalDate.now; + import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; import com.tencent.supersonic.auth.api.authentication.pojo.User; @@ -14,13 +16,13 @@ import com.tencent.supersonic.chat.core.agent.RuleParserTool; import com.tencent.supersonic.common.pojo.DateConf; import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum; -import static java.time.LocalDate.now; - public class DataUtils { public static final Integer metricAgentId = 1; public static final Integer tagAgentId = 2; + public static final Integer MULTI_TURNS_CHAT_ID = 11; private static final User user_test = User.getFakeUser(); + public static User getUser() { return user_test; } diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/BaseTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/BaseTest.java index 55f491909..b0c2f3fb7 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/BaseTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/BaseTest.java @@ -1,6 +1,6 @@ package com.tencent.supersonic.headless.integration; -import com.tencent.supersonic.StandaloneLauncher; +import com.tencent.supersonic.BaseApplication; import com.tencent.supersonic.auth.api.authentication.pojo.User; import com.tencent.supersonic.headless.api.pojo.request.QuerySqlReq; import com.tencent.supersonic.headless.api.pojo.request.SemanticQueryReq; @@ -8,16 +8,9 @@ import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp; import com.tencent.supersonic.headless.server.service.QueryService; import java.util.HashSet; import java.util.Set; -import org.junit.runner.RunWith; 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.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = StandaloneLauncher.class) -@ActiveProfiles("local") -public class BaseTest { +public class BaseTest extends BaseApplication { @Autowired private QueryService queryService; diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/ExplainTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/ExplainTest.java index c450eb196..523addfc7 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/ExplainTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/ExplainTest.java @@ -1,6 +1,7 @@ package com.tencent.supersonic.headless.integration; -import org.junit.Test; + +import org.junit.jupiter.api.Test; public class ExplainTest extends BaseTest { diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/QueryBySqlTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/QueryBySqlTest.java index c9b3eb41c..ad31d39af 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/QueryBySqlTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/QueryBySqlTest.java @@ -7,7 +7,7 @@ import com.tencent.supersonic.auth.api.authentication.pojo.User; import com.tencent.supersonic.common.pojo.QueryColumn; import com.tencent.supersonic.common.pojo.exception.InvalidPermissionException; import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryBySqlTest extends BaseTest { diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/QueryByStructTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/QueryByStructTest.java index 7b4ff730a..62b16cd62 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/QueryByStructTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/integration/QueryByStructTest.java @@ -18,7 +18,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.commons.collections4.CollectionUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QueryByStructTest extends BaseTest { diff --git a/launchers/standalone/src/test/resources/db/data-h2.sql b/launchers/standalone/src/test/resources/db/data-h2.sql index 6050f794b..5096c1997 100644 --- a/launchers/standalone/src/test/resources/db/data-h2.sql +++ b/launchers/standalone/src/test/resources/db/data-h2.sql @@ -1,78 +1,80 @@ -- sample user -insert into s2_user (id, `name`, password, display_name, email, is_admin) values (1, 'admin','admin','admin','admin@xx.com', 1); -insert into s2_user (id, `name`, password, display_name, email) values (2, 'jack','123456','jack','jack@xx.com'); -insert into s2_user (id, `name`, password, display_name, email) values (3, 'tom','123456','tom','tom@xx.com'); -insert into s2_user (id, `name`, password, display_name, email, is_admin) values (4, 'lucy','123456','lucy','lucy@xx.com', 1); -insert into s2_user (id, `name`, password, display_name, email) values (5, 'alice','123456','alice','alice@xx.com'); +MERGE INTO s2_user (id, `name`, password, display_name, email, is_admin) values (1, 'admin','admin','admin','admin@xx.com', 1); +MERGE INTO s2_user (id, `name`, password, display_name, email) values (2, 'jack','123456','jack','jack@xx.com'); +MERGE INTO s2_user (id, `name`, password, display_name, email) values (3, 'tom','123456','tom','tom@xx.com'); +MERGE INTO s2_user (id, `name`, password, display_name, email, is_admin) values (4, 'lucy','123456','lucy','lucy@xx.com', 1); +MERGE INTO s2_user (id, `name`, password, display_name, email) values (5, 'alice','123456','alice','alice@xx.com'); -insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) -values (1, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); -insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) -values (2, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); -insert into s2_available_date_info(`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) -values (3, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); -insert into s2_view_info(`id`, `domain_id`, `type`, `config` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) +MERGE INTO s2_available_date_info(`id`,`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) +values (1 , 1, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); +MERGE INTO s2_available_date_info(`id`,`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) +values (2 , 2, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); +MERGE INTO s2_available_date_info(`id`,`item_id` ,`type` ,`date_format` ,`start_date` ,`end_date` ,`unavailable_date` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) +values (3 , 3, 'dimension', 'yyyy-MM-dd', DATEADD('DAY', -28, CURRENT_DATE()), DATEADD('DAY', -1, CURRENT_DATE()), '[]', '2023-06-01', 'admin', '2023-06-01', 'admin'); + + +MERGE INTO s2_view_info(`id`, `domain_id`, `type`, `config` ,`created_at` ,`created_by` ,`updated_at` ,`updated_by` ) values (1, 1, 'modelEdgeRelation', '[{"source":"datasource-1","target":"datasource-3","type":"polyline","id":"edge-0.305251275235679741702883718912","style":{"active":{"stroke":"rgb(95, 149, 255)","lineWidth":1},"selected":{"stroke":"rgb(95, 149, 255)","lineWidth":2,"shadowColor":"rgb(95, 149, 255)","shadowBlur":10,"text-shape":{"fontWeight":500}},"highlight":{"stroke":"rgb(95, 149, 255)","lineWidth":2,"text-shape":{"fontWeight":500}},"inactive":{"stroke":"rgb(234, 234, 234)","lineWidth":1},"disable":{"stroke":"rgb(245, 245, 245)","lineWidth":1},"stroke":"#296df3","endArrow":true},"startPoint":{"x":-94,"y":-137.5,"anchorIndex":0,"id":"-94|||-137.5"},"endPoint":{"x":-234,"y":-45,"anchorIndex":1,"id":"-234|||-45"},"sourceAnchor":2,"targetAnchor":1,"label":"模型关系编辑"},{"source":"datasource-1","target":"datasource-2","type":"polyline","id":"edge-0.466237264629309141702883756359","style":{"active":{"stroke":"rgb(95, 149, 255)","lineWidth":1},"selected":{"stroke":"rgb(95, 149, 255)","lineWidth":2,"shadowColor":"rgb(95, 149, 255)","shadowBlur":10,"text-shape":{"fontWeight":500}},"highlight":{"stroke":"rgb(95, 149, 255)","lineWidth":2,"text-shape":{"fontWeight":500}},"inactive":{"stroke":"rgb(234, 234, 234)","lineWidth":1},"disable":{"stroke":"rgb(245, 245, 245)","lineWidth":1},"stroke":"#296df3","endArrow":true},"startPoint":{"x":-12,"y":-137.5,"anchorIndex":1,"id":"-12|||-137.5"},"endPoint":{"x":85,"y":31.5,"anchorIndex":0,"id":"85|||31.5"},"sourceAnchor":1,"targetAnchor":2,"label":"模型关系编辑"}]', '2023-06-01', 'admin', '2023-06-01', 'admin'); -- sample data -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '周杰伦', '港台','青花瓷','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '陈奕迅', '港台','爱情转移','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '林俊杰', '港台','美人鱼','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '张碧晨', '内地','光的方向','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), '程响', '内地','人间烟火','国风',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); -INSERT INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -4, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -3, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -2, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -6, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); +MERGE INTO singer (imp_date,singer_name,act_area, song_name,genre,js_play_cnt,down_cnt,favor_cnt) VALUES (DATEADD('DAY', -7, CURRENT_DATE()), 'Taylor Swift', '欧美','Love Story','流行',1000000,1000000,1000000); ---demo data for semantic and chat -insert into s2_user_department (user_name, department) values ('jack','HR'); +MERGE INTO s2_user_department (user_name, department) values ('jack','HR'); -insert into s2_user_department (user_name, department) values ('jack','HR'); -insert into s2_user_department (user_name, department) values ('tom','sales'); -insert into s2_user_department (user_name, department) values ('lucy','marketing'); -insert into s2_user_department (user_name, department) values ('john','strategy'); -insert into s2_user_department (user_name, department) values ('alice','sales'); -insert into s2_user_department (user_name, department) values ('dean','marketing'); +MERGE INTO s2_user_department (user_name, department) values ('jack','HR'); +MERGE INTO s2_user_department (user_name, department) values ('tom','sales'); +MERGE INTO s2_user_department (user_name, department) values ('lucy','marketing'); +MERGE INTO s2_user_department (user_name, department) values ('john','strategy'); +MERGE INTO s2_user_department (user_name, department) values ('alice','sales'); +MERGE INTO s2_user_department (user_name, department) values ('dean','marketing'); INSERT INTO s2_pv_uv_statis (imp_date, user_name, page) VALUES (DATEADD('DAY', -5, CURRENT_DATE()), 'lucy', 'p1'); @@ -1083,32 +1085,32 @@ INSERT INTO s2_stay_time_statis (imp_date, user_name, stay_hours, page) VALUES ( -insert into genre(g_name,rating,most_popular_in) VALUES ('tagore',8,'孟加拉国'); -insert into genre(g_name,rating,most_popular_in) VALUES ('nazrul',7,'孟加拉国'); -insert into genre(g_name,rating,most_popular_in) VALUES ('民间',9,'锡尔赫特、吉大港、库斯蒂亚'); -insert into genre(g_name,rating,most_popular_in) VALUES ('现代',8,'孟加拉国'); -insert into genre(g_name,rating,most_popular_in) VALUES ('蓝调',7,'加拿大'); -insert into genre(g_name,rating,most_popular_in) VALUES ('流行',9,'美国'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('tagore',8,'孟加拉国'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('nazrul',7,'孟加拉国'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('民间',9,'锡尔赫特、吉大港、库斯蒂亚'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('现代',8,'孟加拉国'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('蓝调',7,'加拿大'); +MERGE INTO genre(g_name,rating,most_popular_in) VALUES ('流行',9,'美国'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Shrikanta','印度','男性','tagore'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Prity','孟加拉国','女性','nazrul'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Farida','孟加拉国','女性','民间'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Topu','印度','女性','现代'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Enrique','美国','男性','蓝调'); -insert into artist(artist_name,country,gender,g_name) VALUES ('Michel','英国','男性','流行'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Shrikanta','印度','男性','tagore'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Prity','孟加拉国','女性','nazrul'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Farida','孟加拉国','女性','民间'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Topu','印度','女性','现代'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Enrique','美国','男性','蓝调'); +MERGE INTO artist(artist_name,country,gender,g_name) VALUES ('Michel','英国','男性','流行'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (1,'Shrikanta','3.78 MB','3:45','mp4'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (2,'Prity','4.12 MB','2:56','mp3'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (3,'Farida','3.69 MB','4:12','mp4'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (4,'Enrique','4.58 MB','5:23','mp4'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (5,'Michel','5.10 MB','4:34','mp3'); -insert into files(f_id,artist_name,file_size,duration,formats) VALUES (6,'Topu','4.10 MB','4:30','mp4'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (1,'Shrikanta','3.78 MB','3:45','mp4'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (2,'Prity','4.12 MB','2:56','mp3'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (3,'Farida','3.69 MB','4:12','mp4'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (4,'Enrique','4.58 MB','5:23','mp4'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (5,'Michel','5.10 MB','4:34','mp3'); +MERGE INTO files(f_id,artist_name,file_size,duration,formats) VALUES (6,'Topu','4.10 MB','4:30','mp4'); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'Tumi 长袍 尼罗布','Shrikanta','印度',1,'tagore',8,'孟加拉语','28-AUG-2011',1080); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'舒克诺 帕塔尔 努普尔 帕埃','Prity','孟加拉国',2,'nazrul',5,'孟加拉语','21-SEP-1997',512); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'阿米·奥帕尔·霍伊','Farida','孟加拉国',3,'民间',7,'孟加拉语','7-APR-2001',320); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'我的爱','Enrique','美国',4,'蓝调',6,'英文','24-JAN-2007',1080); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'打败它','Michel','英国',5,'流行',8,'英文','17-MAR-2002',720); -insert into song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'阿杰伊阿卡什','Topu','印度',6,'现代',10,'孟加拉语','27-MAR-2004',320); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'Tumi 长袍 尼罗布','Shrikanta','印度',1,'tagore',8,'孟加拉语','28-AUG-2011',1080); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'舒克诺 帕塔尔 努普尔 帕埃','Prity','孟加拉国',2,'nazrul',5,'孟加拉语','21-SEP-1997',512); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'阿米·奥帕尔·霍伊','Farida','孟加拉国',3,'民间',7,'孟加拉语','7-APR-2001',320); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'我的爱','Enrique','美国',4,'蓝调',6,'英文','24-JAN-2007',1080); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'打败它','Michel','英国',5,'流行',8,'英文','17-MAR-2002',720); +MERGE INTO song(imp_date,song_name,artist_name,country,f_id,g_name,rating,languages,releasedate,resolution) VALUES (DATEADD('DAY', 0, CURRENT_DATE()),'阿杰伊阿卡什','Topu','印度',6,'现代',10,'孟加拉语','27-MAR-2004',320); -- benchmark diff --git a/launchers/standalone/src/test/resources/db/schema-h2.sql b/launchers/standalone/src/test/resources/db/schema-h2.sql index b1ff86027..273ad467f 100644 --- a/launchers/standalone/src/test/resources/db/schema-h2.sql +++ b/launchers/standalone/src/test/resources/db/schema-h2.sql @@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS `s2_chat` ) ; -CREATE TABLE `s2_chat_query` +CREATE TABLE IF NOT EXISTS `s2_chat_query` ( `question_id` BIGINT NOT NULL AUTO_INCREMENT, `agent_id` INT NULL, @@ -41,7 +41,7 @@ CREATE TABLE `s2_chat_query` PRIMARY KEY (`question_id`) ); -CREATE TABLE `s2_chat_parse` +CREATE TABLE IF NOT EXISTS `s2_chat_parse` ( `question_id` BIGINT NOT NULL, `chat_id` BIGINT NOT NULL , @@ -53,7 +53,7 @@ CREATE TABLE `s2_chat_parse` `is_candidate` INT DEFAULT 1 COMMENT '1是candidate,0是selected' ); -CREATE TABLE `s2_chat_statistics` +CREATE TABLE IF NOT EXISTS `s2_chat_statistics` ( `question_id` BIGINT NOT NULL, `chat_id` BIGINT NOT NULL , @@ -82,7 +82,7 @@ CREATE TABLE IF NOT EXISTS `s2_chat_config` ( COMMENT ON TABLE s2_chat_config IS 'chat config information table '; -create table s2_user +create table IF NOT EXISTS s2_user ( id INT AUTO_INCREMENT, name varchar(100) not null, @@ -144,7 +144,7 @@ CREATE TABLE IF NOT EXISTS `s2_model` ( COMMENT ON TABLE s2_model IS 'model information'; -CREATE TABLE `s2_database` ( +CREATE TABLE IF NOT EXISTS `s2_database` ( `id` INT NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL , `description` varchar(500) DEFAULT NULL , @@ -161,7 +161,7 @@ CREATE TABLE `s2_database` ( ); COMMENT ON TABLE s2_database IS 'database instance table'; -create table s2_auth_groups +create table IF NOT EXISTS s2_auth_groups ( group_id INT, config varchar(2048), @@ -219,7 +219,7 @@ CREATE TABLE IF NOT EXISTS `s2_dimension` ( ); COMMENT ON TABLE s2_dimension IS 'dimension information table'; -CREATE TABLE s2_model_rela +CREATE TABLE IF NOT EXISTS s2_model_rela ( id BIGINT AUTO_INCREMENT, domain_id BIGINT, @@ -230,7 +230,7 @@ CREATE TABLE s2_model_rela PRIMARY KEY (`id`) ); -create table s2_view_info +create table IF NOT EXISTS s2_view_info ( id INT auto_increment, domain_id INT null, @@ -239,12 +239,13 @@ create table s2_view_info created_at TIMESTAMP null, created_by varchar(100) null, updated_at TIMESTAMP null, - updated_by varchar(100) not null + updated_by varchar(100) not null, + PRIMARY KEY (`id`) ); COMMENT ON TABLE s2_view_info IS 'view information table'; -CREATE TABLE `s2_query_stat_info` ( +CREATE TABLE IF NOT EXISTS `s2_query_stat_info` ( `id` INT NOT NULL AUTO_INCREMENT, `trace_id` varchar(200) DEFAULT NULL, -- query unique identifier `model_id` INT DEFAULT NULL, @@ -359,7 +360,8 @@ CREATE TABLE IF NOT EXISTS s2_agent -------demo for semantic and chat CREATE TABLE IF NOT EXISTS `s2_user_department` ( `user_name` varchar(200) NOT NULL, - `department` varchar(200) NOT NULL -- department of user + `department` varchar(200) NOT NULL, -- department of user + PRIMARY KEY (`user_name`,`department`) ); COMMENT ON TABLE s2_user_department IS 'user_department_info'; @@ -386,7 +388,8 @@ CREATE TABLE IF NOT EXISTS `singer` ( `genre` varchar(200) NOT NULL, `js_play_cnt` bigINT DEFAULT NULL, `down_cnt` bigINT DEFAULT NULL, - `favor_cnt` bigINT DEFAULT NULL + `favor_cnt` bigINT DEFAULT NULL, + PRIMARY KEY (`imp_date`, `singer_name`) ); COMMENT ON TABLE singer IS 'singer_info'; @@ -422,7 +425,8 @@ CREATE TABLE IF NOT EXISTS `artist` ( `artist_name` varchar(50) NOT NULL , -- genre name `country` varchar(20) , `gender` varchar(20) , - `g_name` varchar(50) + `g_name` varchar(50), + PRIMARY KEY (`artist_name`,`country`) ); COMMENT ON TABLE artist IS 'artist'; @@ -446,18 +450,19 @@ CREATE TABLE IF NOT EXISTS `song` ( `rating` INT , `languages` varchar(20) , `releasedate` varchar(50) , - `resolution` bigINT NOT NULL + `resolution` bigINT NOT NULL, + PRIMARY KEY (`imp_date`,`song_name`) ); COMMENT ON TABLE song IS 'song'; -CREATE TABLE s2_sys_parameter +CREATE TABLE IF NOT EXISTS s2_sys_parameter ( id INT PRIMARY KEY AUTO_INCREMENT, admin varchar(500), parameters text null ); -CREATE TABLE `s2_collect` ( +CREATE TABLE IF NOT EXISTS `s2_collect` ( `id` bigint NOT NULL AUTO_INCREMENT, `type` varchar(20) NOT NULL, `username` varchar(20) NOT NULL, @@ -467,7 +472,7 @@ CREATE TABLE `s2_collect` ( PRIMARY KEY (`id`) ); -CREATE TABLE `s2_metric_query_default_config` ( +CREATE TABLE IF NOT EXISTS `s2_metric_query_default_config` ( `id` bigint NOT NULL AUTO_INCREMENT, `metric_id` bigint , `user_name` varchar(255) NOT NULL, @@ -479,7 +484,7 @@ CREATE TABLE `s2_metric_query_default_config` ( PRIMARY KEY (`id`) ); -CREATE TABLE `s2_app` ( +CREATE TABLE IF NOT EXISTS `s2_app` ( id bigint AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), description VARCHAR(255),