Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions km-biz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
Expand Down
4 changes: 0 additions & 4 deletions km-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@
<version>3.0.2</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
10 changes: 0 additions & 10 deletions km-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${springboot.version}</version>
<scope>test</scope>
</dependency>

<!-- javax -->
<dependency>
Expand All @@ -67,10 +61,6 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
Expand Down
6 changes: 6 additions & 0 deletions km-persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
<dependency>
<groupId>io.github.zqrferrari</groupId>
<artifactId>logi-elasticsearch-client</artifactId>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
34 changes: 30 additions & 4 deletions km-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

<springboot.version>2.3.7.RELEASE</springboot.version>
<spring.version>5.3.19</spring.version>

<maven.test.skip>false</maven.test.skip>
</properties>

<dependencies>
Expand Down Expand Up @@ -101,10 +103,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
Expand Down Expand Up @@ -133,6 +131,34 @@
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
<version>${springboot.version}</version>
</dependency>

<!--testcontainers-->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.32</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>elasticsearch</artifactId>
<scope>test</scope>
</dependency>
<!--testcontainers end-->
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
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 com.xiaojukeji.know.streaming.test.km.KMBase;
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
*
* <p>
* 得使用随机端口号,这样行执行单元测试的时候,不会出现端口号占用的情况
*/
@ActiveProfiles("test")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = KnowStreaming.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class KnowStreamApplicationTest {

protected HttpHeaders headers;

public class KnowStreamApplicationTest extends KMBase {
@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);
}
// @Test
// public void test() {
// Assertions.assertNotNull(port);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

public class TopicMetricServiceTest extends KnowStreamApplicationTest {

Long clusterId = 1L;

@Autowired
private TopicMetricService topicMetricService;

@Test
public void listTopicMetricsFromESTest(){
Long clusterId = 1l;
Long endTime = System.currentTimeMillis();
Long startTime = endTime - 3600 * 1000;

Expand All @@ -47,7 +48,6 @@ public void listTopicMetricsFromESTest(){

@Test
public void pagingTopicWithLatestMetricsFromESTest(){
Long clusterId = 2l;
List<String> metricNameList = new ArrayList<>();
SearchSort sort = new SearchSort();
sort.setQueryName("LogSize");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.xiaojukeji.know.streaming.km.core.service.cluster;

import com.xiaojukeji.know.streaming.km.KnowStreamApplicationTest;
import com.xiaojukeji.know.streaming.km.common.bean.dto.cluster.ClusterPhyAddDTO;
import com.xiaojukeji.know.streaming.km.common.bean.entity.cluster.ClusterPhy;
import com.xiaojukeji.know.streaming.km.common.bean.entity.config.JmxConfig;
import com.xiaojukeji.know.streaming.km.common.converter.ClusterConverter;
import com.xiaojukeji.know.streaming.km.common.exception.AdminOperateException;
import com.xiaojukeji.know.streaming.km.common.exception.DuplicateException;
import com.xiaojukeji.know.streaming.km.common.exception.ParamErrorException;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Properties;

@Slf4j
public class ClusterPhyServiceTest extends KnowStreamApplicationTest {
@Autowired
private ClusterPhyService clusterPhyService;

@Test
@Order(Integer.MIN_VALUE)
void addClusterPhyTest() {
try {
Properties properties = new Properties();
JmxConfig jmxConfig = new JmxConfig();
jmxConfig.setOpenSSL(false);

ClusterPhyAddDTO dto = new ClusterPhyAddDTO();
dto.setName("test");
dto.setDescription("");
dto.setKafkaVersion(kafkaVersion());
dto.setJmxProperties(jmxConfig);
dto.setClientProperties(properties);
dto.setZookeeper(zookeeperUrl());
dto.setBootstrapServers(bootstrapServers());
Assertions.assertEquals(1,
clusterPhyService.addClusterPhy(ClusterConverter.convert2ClusterPhyPO(dto), "root"));
} catch (ParamErrorException | DuplicateException | AdminOperateException e) {
throw new RuntimeException(e);
}
}

@Test
void listAllClustersTest() {
List<ClusterPhy> clusterPhies = clusterPhyService.listAllClusters();
Assertions.assertNotNull(clusterPhies);
log.info("集群列表:{}", clusterPhies);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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 lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

Expand All @@ -14,8 +15,11 @@
import java.util.List;
import java.util.Map;

@Slf4j
public class BrokerMetricESDAOTest extends KnowStreamApplicationTest {

Long clusterId = 1L;

@Autowired
private BrokerMetricESDAO brokerMetriceESDAO;

Expand All @@ -25,15 +29,15 @@ public void buildSortDslTest(){
SearchSort def = new SearchSort("timestamp", true);
String sortDsl = brokerMetriceESDAO.buildSortDsl(sort, def);

System.out.println(sortDsl);
log.info(sortDsl);
}

@Test
public void buildRangeDslTest(){
SearchRange sort = new SearchRange("age", 1232321f, 45345345345f);
String sortDsl = brokerMetriceESDAO.buildRangeDsl(sort);

System.out.println(sortDsl);
log.info(sortDsl);
}

@Test
Expand All @@ -44,12 +48,11 @@ public void buildMatchDslTest(){

String matchDsl = brokerMetriceESDAO.buildMatchDsl(matches);

System.out.println(matchDsl);
log.info(matchDsl);
}

@Test
public void getBrokerMetricsPointTest(){
Long clusterId = 2L;
Integer brokerId = 1;
List<String> metrics = Arrays.asList("BytesIn", "BytesIn_min_5");
Long endTime = System.currentTimeMillis();
Expand All @@ -63,7 +66,6 @@ public void getBrokerMetricsPointTest(){

@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();
Expand All @@ -74,7 +76,6 @@ public void listBrokerMetricesByBrokerIdsTest(){

@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;
Expand All @@ -84,7 +85,6 @@ public void listBrokerMetricsByTopTest(){

@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

public class ClusterMetricESDAOTest extends KnowStreamApplicationTest {

Long clusterId = 1L;

@Autowired
private ClusterMetricESDAO clusterMetricESDAO;

Expand All @@ -34,7 +36,6 @@ public void listClusterMetricsByClusterIdsTest(){
*/
@Test
public void getClusterMetricsPointTest(){
Long clusterId = 1L;
List<String> metrics = Arrays.asList(
"Connections", "BytesIn_min_15", "PartitionURP",
"HealthScore_Topics", "EventQueueSize", "ActiveControllerCount",
Expand Down Expand Up @@ -67,7 +68,6 @@ public void getClusterMetricsPointTest(){
*/
@Test
public void getClusterLatestMetricsTest(){
Long clusterId = 1L;
List<String> metrics = Collections.emptyList();

ClusterMetricPO clusterLatestMetrics = clusterMetricESDAO.getClusterLatestMetrics(clusterId, metrics);
Expand Down
Loading