mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-02 18:32:08 +08:00
初始化3.0.0版本
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.xiaojukeji.know.streaming.km;
|
||||
|
||||
import com.xiaojukeji.know.streaming.km.rest.KnowStreaming;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* @author d06679
|
||||
* @date 2019/4/11
|
||||
*
|
||||
* 得使用随机端口号,这样行执行单元测试的时候,不会出现端口号占用的情况
|
||||
*/
|
||||
@ActiveProfiles("test")
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = KnowStreaming.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class KnowStreamApplicationTest {
|
||||
|
||||
protected HttpHeaders headers;
|
||||
|
||||
@LocalServerPort
|
||||
private Integer port;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
// 获取 springboot server 监听的端口号
|
||||
// port = applicationContext.getWebServer().getPort();
|
||||
System.out.println( String.format("port is : [%d]", port));
|
||||
//
|
||||
// headers = new HttpHeaders();
|
||||
// headers.add("X-SSO-USER", "zengqiao");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Assertions.assertNotNull(port);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.xiaojukeji.know.streaming.km.core;
|
||||
|
||||
import com.xiaojukeji.know.streaming.km.KnowStreamApplicationTest;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.dto.metrices.MetricsTopicDTO;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.metrics.TopicMetrics;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.result.PaginationResult;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.result.Result;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchFuzzy;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchPage;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchSort;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.vo.metrics.line.MetricMultiLinesVO;
|
||||
import com.xiaojukeji.know.streaming.km.core.service.topic.TopicMetricService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TopicMetricServiceTest extends KnowStreamApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private TopicMetricService topicMetricService;
|
||||
|
||||
@Test
|
||||
public void listTopicMetricsFromESTest(){
|
||||
Long clusterId = 1l;
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 3600 * 1000;
|
||||
|
||||
MetricsTopicDTO dto = new MetricsTopicDTO();
|
||||
dto.setStartTime(startTime);
|
||||
dto.setEndTime(endTime);
|
||||
dto.setTopNu(0);
|
||||
|
||||
List<String> metricName = new ArrayList<>();
|
||||
metricName.add("LogSize");
|
||||
dto.setMetricsNames(metricName);
|
||||
|
||||
List<String> topicName = new ArrayList<>();
|
||||
topicName.add("__consumer_offsets");
|
||||
dto.setTopics(topicName);
|
||||
|
||||
Result<List<MetricMultiLinesVO>> ret = topicMetricService.listTopicMetricsFromES(clusterId, dto);
|
||||
|
||||
assert ret.successful();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pagingTopicWithLatestMetricsFromESTest(){
|
||||
Long clusterId = 2l;
|
||||
List<String> metricNameList = new ArrayList<>();
|
||||
SearchSort sort = new SearchSort();
|
||||
sort.setQueryName("LogSize");
|
||||
|
||||
SearchFuzzy fuzzy = new SearchFuzzy();
|
||||
SearchPage page = new SearchPage();
|
||||
|
||||
PaginationResult<TopicMetrics> result = topicMetricService.pagingTopicWithLatestMetricsFromES(
|
||||
clusterId, metricNameList, sort, fuzzy, null, null, page);
|
||||
assert result.successful();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.xiaojukeji.know.streaming.km.persistence.es;
|
||||
|
||||
import com.xiaojukeji.know.streaming.km.KnowStreamApplicationTest;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchTerm;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchRange;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchSort;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.vo.metrics.point.MetricPointVO;
|
||||
import com.xiaojukeji.know.streaming.km.persistence.es.dao.BrokerMetricESDAO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BrokerMetricESDAOTest extends KnowStreamApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private BrokerMetricESDAO brokerMetriceESDAO;
|
||||
|
||||
@Test
|
||||
public void buildSortDslTest(){
|
||||
SearchSort sort = new SearchSort("age", true);
|
||||
SearchSort def = new SearchSort("timestamp", true);
|
||||
String sortDsl = brokerMetriceESDAO.buildSortDsl(sort, def);
|
||||
|
||||
System.out.println(sortDsl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildRangeDslTest(){
|
||||
SearchRange sort = new SearchRange("age", 1232321f, 45345345345f);
|
||||
String sortDsl = brokerMetriceESDAO.buildRangeDsl(sort);
|
||||
|
||||
System.out.println(sortDsl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildMatchDslTest(){
|
||||
List<SearchTerm> matches = new ArrayList<>();
|
||||
matches.add(new SearchTerm("abc", "3"));
|
||||
matches.add(new SearchTerm("dce", "345"));
|
||||
|
||||
String matchDsl = brokerMetriceESDAO.buildMatchDsl(matches);
|
||||
|
||||
System.out.println(matchDsl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBrokerMetricsPointTest(){
|
||||
Long clusterId = 2L;
|
||||
Integer brokerId = 1;
|
||||
List<String> metrics = Arrays.asList("BytesIn", "BytesIn_min_5");
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
Map<String/*metric*/, MetricPointVO> metricPointVOS = brokerMetriceESDAO.getBrokerMetricsPoint(
|
||||
clusterId, brokerId, metrics, "avg", startTime, endTime);
|
||||
|
||||
assert null != metricPointVOS;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listBrokerMetricesByBrokerIdsTest(){
|
||||
Long clusterId = 123L;
|
||||
List<String> metrics = Arrays.asList("BytesInPerSec_min_1", "BytesInPerSec_min_15");
|
||||
List<Long> brokerIds = Arrays.asList(1L);
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
brokerMetriceESDAO.listBrokerMetricsByBrokerIds(clusterId, metrics, "avg", brokerIds, startTime, endTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listBrokerMetricsByTopTest(){
|
||||
Long clusterId = 123L;
|
||||
List<String> metrics = Arrays.asList("BytesInPerSec_min_1", "BytesInPerSec_min_15");
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
brokerMetriceESDAO.listBrokerMetricsByTop(clusterId, new ArrayList<>(), metrics, "avg", 5, startTime, endTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTopBrokerIdsTest(){
|
||||
Long clusterId = 123L;
|
||||
List<String> metrics = Arrays.asList("BytesInPerSec_min_1", "BytesInPerSec_min_15");
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
brokerMetriceESDAO.getTopNBrokerIds(clusterId, metrics, "avg", 5, startTime, endTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.xiaojukeji.know.streaming.km.persistence.es;
|
||||
|
||||
import com.xiaojukeji.know.streaming.km.KnowStreamApplicationTest;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchTerm;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchPage;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchRange;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchSort;
|
||||
import com.xiaojukeji.know.streaming.km.persistence.es.dao.ClusterMetricESDAO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ClusterMetricESDAOTest extends KnowStreamApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private ClusterMetricESDAO clusterMetricESDAO;
|
||||
|
||||
@Test
|
||||
public void listClusterMetricsByClusterIdsTest(){
|
||||
List<String> metrics = Arrays.asList("BytesIn_min_1", "BytesOut_min_1");
|
||||
List<Long> clusterIds = Arrays.asList(123L);
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
clusterMetricESDAO.listClusterMetricsByClusterIds(metrics, "avg", clusterIds, startTime, endTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pagingClusterWithLatestMetricsTest(){
|
||||
List<Long> clusterIds = new ArrayList<>();
|
||||
List<String> metricList = new ArrayList<>();
|
||||
List<SearchTerm> searchMatches = new ArrayList<>();
|
||||
SearchTerm match = new SearchTerm("Zookeepers", "3");
|
||||
match.setMetric(true);
|
||||
searchMatches.add(match);
|
||||
|
||||
SearchSort sort = new SearchSort("Replicas", true);
|
||||
sort.setMetric(true);
|
||||
|
||||
SearchRange range = new SearchRange("Brokers", 1, 100);
|
||||
range.setMetric(true);
|
||||
|
||||
SearchPage page = new SearchPage();
|
||||
|
||||
// clusterMetricESDAO.pagingClusterWithLatestMetrics(searchMatches, sort, range);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.xiaojukeji.know.streaming.km.persistence.es;
|
||||
|
||||
import com.google.common.collect.Table;
|
||||
import com.xiaojukeji.know.streaming.km.KnowStreamApplicationTest;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.group.GroupTopic;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchTerm;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.topic.TopicPartitionKS;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.po.metrice.GroupMetricPO;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.vo.metrics.point.MetricPointVO;
|
||||
import com.xiaojukeji.know.streaming.km.common.enums.AggTypeEnum;
|
||||
import com.xiaojukeji.know.streaming.km.persistence.es.dao.GroupMetricESDAO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class GroupMetricESDAOTest extends KnowStreamApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private GroupMetricESDAO groupMetricESDAO;
|
||||
|
||||
@Test
|
||||
public void listLatestMetricsAggByGroupTopicTest(){
|
||||
Long clusterPhyId = 2L;
|
||||
List<GroupTopic> groupTopicList = new ArrayList<>();
|
||||
groupTopicList.add(new GroupTopic("g-know-streaming-123456", "know-streaming-test-251"));
|
||||
groupTopicList.add(new GroupTopic("test_group", "know-streaming-test-251"));
|
||||
|
||||
List<String> metrics = Arrays.asList("OffsetConsumed", "Lag");
|
||||
AggTypeEnum aggType = AggTypeEnum.AVG;
|
||||
|
||||
List<GroupMetricPO> groupMetricPOS = groupMetricESDAO.listLatestMetricsAggByGroupTopic(clusterPhyId, groupTopicList, metrics, aggType);
|
||||
|
||||
assert !CollectionUtils.isEmpty(groupMetricPOS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listGroupTopicPartitionsTest(){
|
||||
Long clusterId = 2L;
|
||||
String groupName = "g-know-streaming-123456";
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 24 * 3600 * 1000;
|
||||
Set<TopicPartitionKS> topicPartitionKS = groupMetricESDAO.listGroupTopicPartitions(clusterId, groupName, startTime, endTime);
|
||||
|
||||
assert null != topicPartitionKS;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listPartitionLatestMetricsTest(){
|
||||
Long clusterId = 2L;
|
||||
String groupName = "test_group_20220421";
|
||||
String topicName = "know-streaming-test-251";
|
||||
List<GroupMetricPO> groupMetricPOS = groupMetricESDAO.listPartitionLatestMetrics(clusterId, groupName, topicName, null);
|
||||
|
||||
assert !CollectionUtils.isEmpty(groupMetricPOS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void countMetricValueTest(){
|
||||
Long clusterId = 3L;
|
||||
String groupName = "test_group";
|
||||
|
||||
SearchTerm searchTerm = new SearchTerm("HealthCheckTotal", "1", false);
|
||||
searchTerm.setMetric(true);
|
||||
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 24 * 3600 * 1000;
|
||||
Integer i = groupMetricESDAO.countMetricValue(clusterId, groupName, searchTerm, startTime, endTime);
|
||||
assert null != i;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listGroupMetricsTest(){
|
||||
Long clusterId = 2L;
|
||||
String groupName = "g-know-streaming-123456";
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 24 * 3600 * 1000;
|
||||
List<TopicPartitionKS> topicPartitionKS = new ArrayList<>();
|
||||
topicPartitionKS.add(new TopicPartitionKS("know-streaming-test-251", 4));
|
||||
|
||||
List<String> metrics = new ArrayList<>();
|
||||
metrics.add("OffsetConsumed");
|
||||
|
||||
Table<String/*metric*/, String/*topic&partition*/, List<MetricPointVO>> multiLinesVOS = groupMetricESDAO.listGroupMetrics(
|
||||
clusterId,groupName,topicPartitionKS, metrics, "avg", startTime, endTime);
|
||||
assert null != multiLinesVOS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xiaojukeji.know.streaming.km.persistence.es;
|
||||
|
||||
import com.xiaojukeji.know.streaming.km.KnowStreamApplicationTest;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.po.metrice.PartitionMetricPO;
|
||||
import com.xiaojukeji.know.streaming.km.persistence.es.dao.PartitionMetricESDAO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PartitionMetricESDAOTest extends KnowStreamApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private PartitionMetricESDAO partitionMetricESDAO;
|
||||
|
||||
@Test
|
||||
public void listPartitionLatestMetricsByTopicTest(){
|
||||
Long clusterPhyId = 2L;
|
||||
String topic = "__consumer_offsets";
|
||||
|
||||
List<PartitionMetricPO> partitionMetricPOS = partitionMetricESDAO.listPartitionLatestMetricsByTopic(
|
||||
clusterPhyId, topic, new ArrayList<>());
|
||||
|
||||
assert null != partitionMetricPOS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xiaojukeji.know.streaming.km.persistence.es;
|
||||
|
||||
import com.xiaojukeji.know.streaming.km.KnowStreamApplicationTest;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.po.metrice.ReplicationMetricPO;
|
||||
import com.xiaojukeji.know.streaming.km.persistence.es.dao.ReplicationMetricESDAO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ReplicationMetricESDAOTest extends KnowStreamApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private ReplicationMetricESDAO replicationMetricESDAO;
|
||||
|
||||
@Test
|
||||
public void getReplicationLatestMetricsTest(){
|
||||
Long clusterPhyId = 2l;
|
||||
Integer brokerId = 1;
|
||||
String topic = "know-streaming-test-251";
|
||||
Integer partitionId = 1;
|
||||
ReplicationMetricPO replicationMetricPO = replicationMetricESDAO.getReplicationLatestMetrics(
|
||||
clusterPhyId, brokerId, topic, partitionId, new ArrayList<>());
|
||||
|
||||
assert null != replicationMetricPO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.xiaojukeji.know.streaming.km.persistence.es;
|
||||
|
||||
import com.google.common.collect.Table;
|
||||
import com.xiaojukeji.know.streaming.km.KnowStreamApplicationTest;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchFuzzy;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchTerm;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.search.SearchSort;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.po.metrice.TopicMetricPO;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.vo.metrics.point.MetricPointVO;
|
||||
import com.xiaojukeji.know.streaming.km.persistence.es.dao.TopicMetricESDAO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TopicMetricESDAOTest extends KnowStreamApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private TopicMetricESDAO topicMetricESDAO;
|
||||
|
||||
@Test
|
||||
public void listTopicMaxMinMetricsTest(){
|
||||
Long clusterId = 2L;
|
||||
String topic = "know-streaming-test-251";
|
||||
String topic1 = "topic_test01";
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
List<TopicMetricPO> ret = topicMetricESDAO.listTopicMaxMinMetrics(
|
||||
clusterId, Arrays.asList(topic, topic1), "BytesIn", false, startTime, endTime);
|
||||
assert null != ret;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTopicsAggsMetricsValueTest(){
|
||||
Long clusterId = 2L;
|
||||
String topic = "know-streaming-test-251";
|
||||
String topic1 = "topic_test01";
|
||||
List<String> metrics = Arrays.asList("BytesIn", "BytesIn_min_5");
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
Table<String/*topics*/, String/*metric*/, MetricPointVO> ret = topicMetricESDAO.getTopicsAggsMetricsValue(
|
||||
clusterId, Arrays.asList(topic, topic1), metrics, "max", startTime, endTime);
|
||||
assert null != ret;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listTopicWithLatestMetricsTest(){
|
||||
Long clusterId = 2L;
|
||||
SearchSort sort = new SearchSort("LogSize", true);
|
||||
sort.setMetric(true);
|
||||
|
||||
SearchFuzzy fuzzy = new SearchFuzzy("topic", "know");
|
||||
List<SearchTerm> terms = new ArrayList<>();
|
||||
|
||||
List<TopicMetricPO> topicMetricPOS = topicMetricESDAO.listTopicWithLatestMetrics(clusterId, sort, fuzzy, null, terms);
|
||||
|
||||
assert !CollectionUtils.isEmpty(topicMetricPOS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTopicLatestMetricByBrokerIdTest(){
|
||||
Long clusterId = 2L;
|
||||
String topic = "know-streaming-test-251";
|
||||
Integer brokerId = 1;
|
||||
|
||||
TopicMetricPO topicMetricPO = topicMetricESDAO.getTopicLatestMetricByBrokerId(clusterId, topic, brokerId, new ArrayList<>());
|
||||
|
||||
assert null != topicMetricPO;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTopicLatestMetricTest(){
|
||||
Long clusterId = 2L;
|
||||
String topic = "know-streaming-test-251";
|
||||
|
||||
TopicMetricPO topicMetricPO = topicMetricESDAO.getTopicLatestMetric(clusterId, topic, new ArrayList<>());
|
||||
|
||||
assert null != topicMetricPO;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listTopicLatestMetricTest(){
|
||||
Long clusterId = 2L;
|
||||
String topic = "know-streaming-test-251";
|
||||
String topic1 = "know-streaming-123";
|
||||
String topic2 = "1209test";
|
||||
List<String> metrics = Arrays.asList("BytesIn", "BytesIn_min_5");
|
||||
|
||||
|
||||
List<TopicMetricPO> topicMetricPO = topicMetricESDAO.listTopicLatestMetric(clusterId, Arrays.asList(topic,topic1,topic2), metrics);
|
||||
|
||||
assert null != topicMetricPO;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listBrokerMetricsByTopicsTest(){
|
||||
Long clusterId = 2L;
|
||||
List<String> metrics = Arrays.asList("BytesIn", "BytesIn_min_5");
|
||||
List<String> topics = Arrays.asList("QAtest_1_13", "__consumer_offsets");
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
topicMetricESDAO.listTopicMetricsByTopics(clusterId, metrics, "avg", topics, startTime, endTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void countMetricValueOccurrencesTest(){
|
||||
Long clusterPhyId = 2L;
|
||||
String topic = "__consumer_offsets";
|
||||
String metricName = "HealthCheckPassed";
|
||||
Float metricValue = 2f;
|
||||
boolean equalMetricValue = true;
|
||||
|
||||
SearchTerm searchMatch = new SearchTerm(metricName, metricValue.toString(), equalMetricValue);
|
||||
searchMatch.setMetric(true);
|
||||
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - 4 * 60 * 60 * 1000;
|
||||
|
||||
Integer i = topicMetricESDAO.countMetricValue(clusterPhyId, topic, searchMatch, startTime, endTime);
|
||||
|
||||
assert null != i;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user