mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
[improvement][Headless] Remove headless build.xml and add tag query testing. (#706)
This commit is contained in:
@@ -90,7 +90,7 @@
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptors>
|
||||
<descriptor>/src/main/build/build.xml</descriptor>
|
||||
<descriptor>../../assembly/build/build.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
|
||||
<id>bin</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<fileSets>
|
||||
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/main/bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<fileMode>0777</fileMode>
|
||||
<directoryMode>0755</directoryMode>
|
||||
</fileSet>
|
||||
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<outputDirectory>conf</outputDirectory>
|
||||
<fileMode>0777</fileMode>
|
||||
<directoryMode>0755</directoryMode>
|
||||
</fileSet>
|
||||
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<includes>
|
||||
<include>*.jar</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
</assembly>
|
||||
@@ -43,11 +43,15 @@ public class BaseTest extends BaseApplication {
|
||||
}
|
||||
|
||||
protected QueryStructReq buildQueryStructReq(List<String> groups) {
|
||||
return buildQueryStructReq(groups, QueryType.METRIC);
|
||||
}
|
||||
|
||||
protected QueryStructReq buildQueryStructReq(List<String> groups, QueryType queryType) {
|
||||
QueryStructReq queryStructReq = new QueryStructReq();
|
||||
for (Long modelId : DataUtils.getMetricAgentIModelIds()) {
|
||||
queryStructReq.addModelId(modelId);
|
||||
}
|
||||
queryStructReq.setQueryType(QueryType.METRIC);
|
||||
queryStructReq.setQueryType(queryType);
|
||||
Aggregator aggregator = new Aggregator();
|
||||
aggregator.setFunc(AggOperatorEnum.SUM);
|
||||
aggregator.setColumn("pv");
|
||||
@@ -55,7 +59,6 @@ public class BaseTest extends BaseApplication {
|
||||
|
||||
if (CollectionUtils.isNotEmpty(groups)) {
|
||||
queryStructReq.setGroups(groups);
|
||||
queryStructReq.setGroups(Arrays.asList("department"));
|
||||
}
|
||||
|
||||
DateConf dateConf = new DateConf();
|
||||
@@ -71,5 +74,4 @@ public class BaseTest extends BaseApplication {
|
||||
queryStructReq.setOrders(orders);
|
||||
return queryStructReq;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,4 +45,5 @@ public class ExplainTest extends BaseTest {
|
||||
assertTrue(explain.getSql().contains("department"));
|
||||
assertTrue(explain.getSql().contains("pv"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.tencent.supersonic.headless;
|
||||
import static java.time.LocalDate.now;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.QueryColumn;
|
||||
@@ -12,6 +13,18 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
public class QueryBySqlTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testDetailQuery() throws Exception {
|
||||
SemanticQueryResp semanticQueryResp = queryBySql("SELECT 用户,访问次数 FROM 超音数PVUV统计 WHERE 用户='alice' ");
|
||||
|
||||
assertEquals(2, semanticQueryResp.getColumns().size());
|
||||
QueryColumn firstColumn = semanticQueryResp.getColumns().get(0);
|
||||
assertEquals("用户", firstColumn.getName());
|
||||
QueryColumn secondColumn = semanticQueryResp.getColumns().get(1);
|
||||
assertEquals("访问次数", secondColumn.getName());
|
||||
assertTrue(semanticQueryResp.getResultList().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSumQuery() throws Exception {
|
||||
SemanticQueryResp semanticQueryResp = queryBySql("SELECT SUM(访问次数) AS 访问次数 FROM 超音数PVUV统计 ");
|
||||
@@ -62,7 +75,7 @@ public class QueryBySqlTest extends BaseTest {
|
||||
public void testCacheQuery() throws Exception {
|
||||
SemanticQueryResp result1 = queryBySql("SELECT 部门, SUM(访问次数) AS 访问次数 FROM 超音数PVUV统计 GROUP BY 部门 ");
|
||||
SemanticQueryResp result2 = queryBySql("SELECT 部门, SUM(访问次数) AS 访问次数 FROM 超音数PVUV统计 GROUP BY 部门 ");
|
||||
assertEquals(result1, result2);
|
||||
assertTrue(result1 == result2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.tencent.supersonic.headless;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.Filter;
|
||||
import com.tencent.supersonic.common.pojo.QueryColumn;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.common.pojo.exception.InvalidPermissionException;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.QueryStructReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
|
||||
@@ -18,6 +20,21 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
public class QueryByStructTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testDetailQuery() throws Exception {
|
||||
QueryStructReq queryStructReq = buildQueryStructReq(Arrays.asList("user_name", "department"),
|
||||
QueryType.TAG);
|
||||
SemanticQueryResp semanticQueryResp = queryService.queryByReq(queryStructReq, User.getFakeUser());
|
||||
assertEquals(3, semanticQueryResp.getColumns().size());
|
||||
QueryColumn firstColumn = semanticQueryResp.getColumns().get(0);
|
||||
assertEquals("用户", firstColumn.getName());
|
||||
QueryColumn secondColumn = semanticQueryResp.getColumns().get(1);
|
||||
assertEquals("部门", secondColumn.getName());
|
||||
QueryColumn thirdColumn = semanticQueryResp.getColumns().get(2);
|
||||
assertEquals("访问次数", thirdColumn.getName());
|
||||
assertTrue(semanticQueryResp.getResultList().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSumQuery() throws Exception {
|
||||
QueryStructReq queryStructReq = buildQueryStructReq(null);
|
||||
@@ -68,7 +85,7 @@ public class QueryByStructTest extends BaseTest {
|
||||
QueryStructReq queryStructReq2 = buildQueryStructReq(Arrays.asList("department"));
|
||||
SemanticQueryResp result1 = queryService.queryByReq(queryStructReq1, User.getFakeUser());
|
||||
SemanticQueryResp result2 = queryService.queryByReq(queryStructReq2, User.getFakeUser());
|
||||
assertEquals(result1, result2);
|
||||
assertTrue(result1 == result2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user