-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
saimu.msm
committed
Aug 10, 2023
1 parent
d286036
commit 77704b0
Showing
5 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...home-web/src/test/java/io/holoinsight/server/home/web/controller/QueryFacadeImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Alipay.com Inc. Copyright (c) 2004-2018 All Rights Reserved. | ||
*/ | ||
|
||
package io.holoinsight.server.home.web.controller; | ||
|
||
import io.holoinsight.server.common.J; | ||
import io.holoinsight.server.common.dao.entity.MetricInfo; | ||
import io.holoinsight.server.common.model.DataQueryRequest; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author masaimu | ||
* @version 2023-08-10 14:56:00 | ||
*/ | ||
public class QueryFacadeImplTest { | ||
|
||
@Test | ||
public void name() { | ||
String json = | ||
"{\"start\":1691644303000,\"end\":1691647903000,\"name\":\"a\",\"metric\":\"k8s_pod_mem_util\",\"groupBy\":[\"app\",\"hostname\",\"workspace\",\"pod\",\"ip\",\"namespace\"],\"filters\":[{\"type\":\"literal_or\",\"name\":\"app\",\"value\":\"holoinsight-server|aaaaa\"},{\"type\":\"literal\",\"name\":\"应用ID\",\"value\":\"111111111\"},{\"type\":\"literal\",\"name\":\"fake应用ID\",\"value\":\"22222222\"}]}"; | ||
DataQueryRequest.QueryDataSource queryDataSource = | ||
J.fromJson(json, DataQueryRequest.QueryDataSource.class); | ||
MetricInfo metricInfo = new MetricInfo(); | ||
metricInfo.setTags(J.toJson(Arrays.asList("app", "应用ID"))); | ||
QueryFacadeImpl queryFacade = new QueryFacadeImpl(); | ||
queryFacade.parseQl(queryDataSource, metricInfo); | ||
System.out.println(queryDataSource.ql); | ||
Assert.assertTrue(StringUtils.equals( | ||
"select count(1) as value from k8s_pod_mem_util where `period` <= 1691647903000 and `period` >= 1691644303000 and `app` in ('holoinsight-server','aaaaa') and `应用ID` = '111111111' group by `app` order by `period` acs", | ||
queryDataSource.ql)); | ||
|
||
json = | ||
"{\"start\":1691644303000,\"end\":1691647903000,\"name\":\"a\",\"metric\":\"k8s_pod_mem_util\",\"groupBy\":[\"app\",\"hostname\",\"workspace\",\"pod\",\"ip\",\"namespace\"],\"filters\":[{\"type\":\"literal_or\",\"name\":\"app\",\"value\":\"holoinsight-server|aaaaa\"},{\"type\":\"literal\",\"name\":\"应用ID\",\"value\":\"111111111\"},{\"type\":\"literal\",\"name\":\"fake应用ID\",\"value\":\"22222222\"}],\"select\":{\"app\":null,\"dd\":\"distinct(`aaa`)\"}}"; | ||
queryDataSource = J.fromJson(json, DataQueryRequest.QueryDataSource.class); | ||
metricInfo = new MetricInfo(); | ||
metricInfo.setTags(J.toJson(Arrays.asList("app", "应用ID"))); | ||
queryFacade = new QueryFacadeImpl(); | ||
queryFacade.parseQl(queryDataSource, metricInfo); | ||
System.out.println(queryDataSource.ql); | ||
Assert.assertTrue(StringUtils.equals( | ||
"select `app` , distinct(`aaa`) as `dd` from k8s_pod_mem_util where `period` <= 1691647903000 and `period` >= 1691644303000 and `app` in ('holoinsight-server','aaaaa') and `应用ID` = '111111111' group by `app` order by `period` acs", | ||
queryDataSource.ql)); | ||
} | ||
} |