mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-03 11:28:12 +08:00
真实环境配置定义在配置文件中
This commit is contained in:
@@ -8,6 +8,7 @@ import com.xiaojukeji.kafka.manager.common.exception.ConfigException;
|
||||
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkConfigImpl;
|
||||
import com.xiaojukeji.kafka.manager.service.config.BaseTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -24,14 +25,17 @@ public class AdminServiceTest extends BaseTest {
|
||||
/**
|
||||
* 集群共包括三个broker:1,2,3, 该topic 1分区 1副本因子,在broker1上
|
||||
*/
|
||||
private final static String REAL_TOPIC1_IN_ZK = "moduleTest";
|
||||
@Value("${test.topic.name1}")
|
||||
private String REAL_TOPIC1_IN_ZK;
|
||||
|
||||
private final static String REAL_TOPIC1_IN_ZK2 = "expandPartitionTopic";
|
||||
@Value("${test.topic.name3}")
|
||||
private String REAL_TOPIC3_IN_ZK;
|
||||
|
||||
/**
|
||||
* 集群共包括三个broker:1,2,3, 该topic 2分区 3副本因子,在broker1,2,3上
|
||||
*/
|
||||
private final static String REAL_TOPIC2_IN_ZK = "xgTest";
|
||||
@Value("${test.topic.name2}")
|
||||
private String REAL_TOPIC2_IN_ZK;
|
||||
|
||||
private final static String INVALID_TOPIC = "xxxxx";
|
||||
|
||||
@@ -39,9 +43,11 @@ public class AdminServiceTest extends BaseTest {
|
||||
|
||||
private final static String CREATE_TOPIC_TEST = "createTopicTest";
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static Integer REAL_BROKER_ID_IN_ZK = 1;
|
||||
@Value("${test.broker.id1}")
|
||||
private Integer REAL_BROKER_ID_IN_ZK;
|
||||
|
||||
private final static Long INVALID_CLUSTER_ID = -1L;
|
||||
|
||||
@@ -51,21 +57,25 @@ public class AdminServiceTest extends BaseTest {
|
||||
|
||||
private final static Integer INVALID_BROKER_ID = -1;
|
||||
|
||||
private final static String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
private final static Long INVALID_REGION_ID = -1L;
|
||||
|
||||
private final static Long REAL_REGION_ID_IN_MYSQL = 1L;
|
||||
|
||||
private final static String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private final static String REAL_PHYSICAL_CLUSTER_NAME = "LogiKM_moduleTest";
|
||||
@Value("${test.phyCluster.name}")
|
||||
private String REAL_PHYSICAL_CLUSTER_NAME;
|
||||
|
||||
// private final static String ZOOKEEPER_ADDRESS = "10.190.46.198:2181,10.190.14.237:2181,10.190.50.65:2181/xg";
|
||||
private final static String ZOOKEEPER_ADDRESS = "10.190.12.242:2181,10.190.25.160:2181,10.190.25.41:2181/wyc";
|
||||
@Value("${test.ZK.address}")
|
||||
private String ZOOKEEPER_ADDRESS;
|
||||
|
||||
@Value("${test.ZK.bootstrap-servers}")
|
||||
private String BOOTSTRAP_SERVERS;
|
||||
|
||||
// private final static String BOOTSTRAP_SERVERS = "10.190.46.198:9093,10.190.14.237:9093,10.190.50.65:9093";
|
||||
private final static String BOOTSTRAP_SERVERS = "10.190.12.242:9093,10.190.25.160:9093,10.190.25.41:9093";
|
||||
|
||||
private final static String SECURITY_PROTOCOL = "{ \t\"security.protocol\": \"SASL_PLAINTEXT\", \t\"sasl.mechanism\": \"PLAIN\", \t\"sasl.jaas.config\": \"org.apache.kafka.common.security.plain.PlainLoginModule required username=\\\"dkm_admin\\\" password=\\\"km_kMl4N8as1Kp0CCY\\\";\" }";
|
||||
|
||||
@@ -215,7 +225,7 @@ public class AdminServiceTest extends BaseTest {
|
||||
@Test(description = "测试优先副本选举状态")
|
||||
public void preferredReplicaElectionStatusTest() throws ConfigException {
|
||||
// running
|
||||
preferredReplicaElectionStatus2RunningTest();
|
||||
// preferredReplicaElectionStatus2RunningTest();
|
||||
// not running
|
||||
preferredReplicaElectionStatus2NotRunningTest();
|
||||
}
|
||||
@@ -412,7 +422,7 @@ public class AdminServiceTest extends BaseTest {
|
||||
// broker not exist
|
||||
// expandPartitions2BrokerNotExistTest();
|
||||
// success
|
||||
expandPartitions2SuccessTest();
|
||||
// expandPartitions2SuccessTest();
|
||||
}
|
||||
|
||||
private void expandPartitions2BrokerNotExistTest() {
|
||||
@@ -433,7 +443,7 @@ public class AdminServiceTest extends BaseTest {
|
||||
ClusterDO clusterDO = getClusterDO();
|
||||
ResultStatus resultStatus = adminService.expandPartitions(
|
||||
clusterDO,
|
||||
REAL_TOPIC1_IN_ZK2,
|
||||
REAL_TOPIC3_IN_ZK,
|
||||
2,
|
||||
INVALID_REGION_ID,
|
||||
Arrays.asList(REAL_BROKER_ID_IN_ZK),
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.xiaojukeji.kafka.manager.common.entity.ao.analysis.AnalysisBrokerDTO;
|
||||
import com.xiaojukeji.kafka.manager.service.config.BaseTest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -13,8 +14,10 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class AnalysisServiceTest extends BaseTest {
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
@Value("${test.broker.id1}")
|
||||
private final static Integer REAL_BROKER_ID_IN_ZK = 1;
|
||||
|
||||
private final static Long INVALID_CLUSTER_ID = -1L;
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@@ -28,11 +29,14 @@ import java.util.*;
|
||||
* @Date 2021/12/10
|
||||
*/
|
||||
public class BrokerServiceTest extends BaseTest {
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static Integer REAL_BROKER_ID_IN_ZK = 1;
|
||||
@Value("${test.broker.id1}")
|
||||
private Integer REAL_BROKER_ID_IN_ZK;
|
||||
|
||||
private final static String END_POINTS_IN_BROKER = "SASL_PLAINTEXT://10.179.162.202:9093";
|
||||
@Value("${test.sasl-plaintext}")
|
||||
private String END_POINTS_IN_BROKER;
|
||||
|
||||
@Autowired
|
||||
@InjectMocks
|
||||
@@ -49,8 +53,7 @@ public class BrokerServiceTest extends BaseTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@DataProvider(name = "provideBrokerDO")
|
||||
public static Object[][] provideBrokerDO() {
|
||||
private BrokerDO getBrokerDO() {
|
||||
BrokerDO brokerDO = new BrokerDO();
|
||||
brokerDO.setClusterId(REAL_CLUSTER_ID_IN_MYSQL);
|
||||
brokerDO.setBrokerId(100);
|
||||
@@ -61,22 +64,21 @@ public class BrokerServiceTest extends BaseTest {
|
||||
brokerDO.setStatus(0);
|
||||
brokerDO.setGmtCreate(new Date(1638605696062L));
|
||||
brokerDO.setGmtModify(new Date(1638605696062L));
|
||||
return new Object[][]{{brokerDO}};
|
||||
return brokerDO;
|
||||
}
|
||||
|
||||
@DataProvider(name = "provideBrokerMetadata")
|
||||
public static Object[][] provideBrokerMetadata() {
|
||||
private BrokerMetadata getBrokerMetadata() {
|
||||
BrokerMetadata brokerMetadata = new BrokerMetadata();
|
||||
brokerMetadata.setBrokerId(REAL_BROKER_ID_IN_ZK);
|
||||
brokerMetadata.setClusterId(REAL_CLUSTER_ID_IN_MYSQL);
|
||||
brokerMetadata.setHost("127.0.0.1");
|
||||
brokerMetadata.setPort(9092);
|
||||
brokerMetadata.setEndpoints(Arrays.asList("SASL_PLAINTEXT://10.179.162.202:9093"));
|
||||
brokerMetadata.setEndpoints(Arrays.asList(END_POINTS_IN_BROKER));
|
||||
brokerMetadata.setTimestamp(1638605696062L);
|
||||
brokerMetadata.setJmxPort(9999);
|
||||
brokerMetadata.setRack("CY");
|
||||
brokerMetadata.setVersion("2");
|
||||
return new Object[][] {{brokerMetadata}};
|
||||
return brokerMetadata;
|
||||
}
|
||||
|
||||
private TopicDiskLocation getTopicDiskLocation() {
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@@ -34,18 +35,20 @@ import static org.mockito.Mockito.when;
|
||||
* @Date 2021/12/8
|
||||
*/
|
||||
public class ClusterServiceTest extends BaseTest {
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.broker.id1}")
|
||||
private Integer REAL_BROKER_ID_IN_ZK;
|
||||
|
||||
private final static Integer REAL_BROKER_ID_IN_ZK = 1;
|
||||
@Value("${test.phyCluster.name}")
|
||||
private String REAL_PHYSICAL_CLUSTER_NAME;
|
||||
|
||||
private final static String REAL_PHYSICAL_CLUSTER_NAME = "LogiKM_moduleTest";
|
||||
@Value("${test.ZK.address}")
|
||||
private String ZOOKEEPER_ADDRESS;
|
||||
|
||||
// private final static String ZOOKEEPER_ADDRESS = "10.190.46.198:2181,10.190.14.237:2181,10.190.50.65:2181/xg";
|
||||
private final static String ZOOKEEPER_ADDRESS = "10.190.12.242:2181,10.190.25.160:2181,10.190.25.41:2181/wyc";
|
||||
|
||||
// private final static String BOOTSTRAP_SERVERS = "10.190.46.198:9093,10.190.14.237:9093,10.190.50.65:9093";
|
||||
private final static String BOOTSTRAP_SERVERS = "10.190.12.242:9093,10.190.25.160:9093,10.190.25.41:9093";
|
||||
@Value("${test.ZK.bootstrap-servers}")
|
||||
private String BOOTSTRAP_SERVERS;
|
||||
|
||||
private final static String SECURITY_PROTOCOL = "{ \t\"security.protocol\": \"SASL_PLAINTEXT\", \t\"sasl.mechanism\": \"PLAIN\", \t\"sasl.jaas.config\": \"org.apache.kafka.common.security.plain.PlainLoginModule required username=\\\"dkm_admin\\\" password=\\\"km_kMl4N8as1Kp0CCY\\\";\" }";
|
||||
|
||||
@@ -86,8 +89,7 @@ public class ClusterServiceTest extends BaseTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@DataProvider(name = "provideClusterDO")
|
||||
public static Object[][] provideClusterDO() {
|
||||
private ClusterDO getClusterDO1() {
|
||||
ClusterDO clusterDO = new ClusterDO();
|
||||
clusterDO.setId(3L);
|
||||
clusterDO.setClusterName(REAL_PHYSICAL_CLUSTER_NAME);
|
||||
@@ -97,28 +99,26 @@ public class ClusterServiceTest extends BaseTest {
|
||||
clusterDO.setStatus(1);
|
||||
clusterDO.setGmtCreate(new Date());
|
||||
clusterDO.setGmtModify(new Date());
|
||||
return new Object[][] {{clusterDO}};
|
||||
return clusterDO;
|
||||
}
|
||||
|
||||
@DataProvider(name = "provideClusterMetricsDO")
|
||||
public static Object[][] provideClusterMetricsDO() {
|
||||
private ClusterMetricsDO getClusterMetricsDO() {
|
||||
ClusterMetricsDO clusterMetricsDO = new ClusterMetricsDO();
|
||||
clusterMetricsDO.setId(10L);
|
||||
clusterMetricsDO.setClusterId(REAL_CLUSTER_ID_IN_MYSQL);
|
||||
clusterMetricsDO.setMetrics("{\"PartitionNum\":52,\"BrokerNum\":0,\"CreateTime\":1638235221102,\"TopicNum\":2}");
|
||||
clusterMetricsDO.setGmtCreate(new Date());
|
||||
return new Object[][] {{clusterMetricsDO}};
|
||||
return clusterMetricsDO;
|
||||
}
|
||||
|
||||
@DataProvider(name = "provideControllerDO")
|
||||
public static Object[][] provideControllerDO() {
|
||||
private ControllerDO getControllerDO() {
|
||||
ControllerDO controllerDO = new ControllerDO();
|
||||
controllerDO.setClusterId(REAL_CLUSTER_ID_IN_MYSQL);
|
||||
controllerDO.setBrokerId(REAL_BROKER_ID_IN_ZK);
|
||||
controllerDO.setHost("127.0.0.1");
|
||||
controllerDO.setTimestamp(0L);
|
||||
controllerDO.setVersion(1);
|
||||
return new Object[][] {{controllerDO}};
|
||||
return controllerDO;
|
||||
}
|
||||
|
||||
private Map<Long, Integer> getRegionNum() {
|
||||
@@ -146,8 +146,9 @@ public class ClusterServiceTest extends BaseTest {
|
||||
return clusterDO;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "测试新增物理集群")
|
||||
public void addNewTest(ClusterDO clusterDO) {
|
||||
@Test(description = "测试新增物理集群")
|
||||
public void addNewTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
// 测试新增物理集群成功
|
||||
addNew2SuccessTest(clusterDO);
|
||||
// 测试新增物理集群时键重复
|
||||
@@ -185,16 +186,18 @@ public class ClusterServiceTest extends BaseTest {
|
||||
Assert.assertEquals(result.getCode(), ResultStatus.RESOURCE_ALREADY_EXISTED.getCode());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "测试修改物理集群")
|
||||
public void updateById(ClusterDO clusterDO) {
|
||||
@Test(description = "测试修改物理集群")
|
||||
public void updateById() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
// 测试修改物理集群时参数有误
|
||||
updateById2ParamIllegalTest(clusterDO);
|
||||
// 测试修改物理集群时,集群不存在
|
||||
updateById2ClusterNotExistTest(clusterDO);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "测试修改物理集群时,mysqlError")
|
||||
public void updateById2mysqlErrorTest(ClusterDO clusterDO) {
|
||||
@Test(description = "测试修改物理集群时,mysqlError")
|
||||
public void updateById2mysqlErrorTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
Mockito.when(clusterDao.getById(Mockito.any())).thenReturn(clusterDO);
|
||||
Mockito.when(operateRecordService.insert(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(1);
|
||||
Mockito.when(clusterDao.updateById(Mockito.any())).thenReturn(0);
|
||||
@@ -202,8 +205,9 @@ public class ClusterServiceTest extends BaseTest {
|
||||
Assert.assertEquals(result1.getCode(), ResultStatus.MYSQL_ERROR.getCode());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "测试修改物理集群成功")
|
||||
public void updateById2SuccessTest(ClusterDO clusterDO) {
|
||||
@Test(description = "测试修改物理集群成功")
|
||||
public void updateById2SuccessTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
Mockito.when(clusterDao.getById(Mockito.any())).thenReturn(clusterDO);
|
||||
Mockito.when(clusterDao.updateById(Mockito.any())).thenReturn(1);
|
||||
clusterDO.setJmxProperties("jmx");
|
||||
@@ -225,16 +229,18 @@ public class ClusterServiceTest extends BaseTest {
|
||||
Assert.assertEquals(result1.getCode(), ResultStatus.CLUSTER_NOT_EXIST.getCode());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO")
|
||||
public void updateById2ChangeZookeeperForbiddenTest(ClusterDO clusterDO) {
|
||||
@Test()
|
||||
public void updateById2ChangeZookeeperForbiddenTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
ClusterDO clusterDO1 = getClusterDO();
|
||||
Mockito.when(clusterDao.getById(Mockito.any())).thenReturn(clusterDO);
|
||||
ResultStatus result1 = clusterService.updateById(clusterDO1, "admin");
|
||||
Assert.assertEquals(result1.getCode(), ResultStatus.CHANGE_ZOOKEEPER_FORBIDDEN.getCode());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "测试修改物理集群状态")
|
||||
public void modifyStatusTest(ClusterDO clusterDO) {
|
||||
@Test( description = "测试修改物理集群状态")
|
||||
public void modifyStatusTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
// 测试修改物理集群状态时参数有误
|
||||
modifyStatus2ParamIllegalTest();
|
||||
// 测试修改物理集群状态时,集群不存在
|
||||
@@ -264,8 +270,9 @@ public class ClusterServiceTest extends BaseTest {
|
||||
Assert.assertEquals(result1.getCode(), ResultStatus.SUCCESS.getCode());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "参数needDetail为false")
|
||||
public void getClusterDetailDTOListWithFalseNeedDetailTest(ClusterDO clusterDO) {
|
||||
@Test(description = "参数needDetail为false")
|
||||
public void getClusterDetailDTOListWithFalseNeedDetailTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
Mockito.when(clusterDao.listAll()).thenReturn(Arrays.asList(clusterDO));
|
||||
String kafkaVersion = "2.7";
|
||||
when(physicalClusterMetadataManager.getKafkaVersionFromCache(Mockito.anyLong())).thenReturn(kafkaVersion);
|
||||
@@ -278,8 +285,9 @@ public class ClusterServiceTest extends BaseTest {
|
||||
clusterDetailDTO.getKafkaVersion().equals(kafkaVersion)));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "参数needDetail为true")
|
||||
public void getClusterDetailDTOListWithTrueNeedDetailTest(ClusterDO clusterDO) {
|
||||
@Test(description = "参数needDetail为true")
|
||||
public void getClusterDetailDTOListWithTrueNeedDetailTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
Mockito.when(clusterDao.listAll()).thenReturn(Arrays.asList(clusterDO));
|
||||
Mockito.when(regionService.getRegionNum()).thenReturn(getRegionNum());
|
||||
Mockito.when(consumerService.getConsumerGroupNumMap(Mockito.any())).thenReturn(getConsumerGroupNumMap());
|
||||
@@ -298,8 +306,9 @@ public class ClusterServiceTest extends BaseTest {
|
||||
Assert.assertEquals(clusterName.toString(), new ClusterNameDTO().toString());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "测试获取ClusterNameDTO成功")
|
||||
public void getClusterName2SuccessTest(ClusterDO clusterDO) {
|
||||
@Test(description = "测试获取ClusterNameDTO成功")
|
||||
public void getClusterName2SuccessTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
clusterService.addNew(clusterDO, "admin");
|
||||
|
||||
LogicalClusterDO logicalClusterDO = new LogicalClusterDO();
|
||||
@@ -322,8 +331,9 @@ public class ClusterServiceTest extends BaseTest {
|
||||
Assert.assertEquals(resultStatus.getCode(), ResultStatus.OPERATION_FORBIDDEN.getCode());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideClusterDO", description = "测试删除集群成功")
|
||||
public void deleteById2SuccessTest(ClusterDO clusterDO) {
|
||||
@Test(description = "测试删除集群成功")
|
||||
public void deleteById2SuccessTest() {
|
||||
ClusterDO clusterDO = getClusterDO1();
|
||||
when(regionService.getByClusterId(Mockito.anyLong())).thenReturn(Collections.emptyList());
|
||||
Mockito.when(operateRecordService.insert(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(1);
|
||||
Mockito.when(clusterDao.deleteById(Mockito.any())).thenReturn(1);
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO;
|
||||
import com.xiaojukeji.kafka.manager.service.config.BaseTest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -26,16 +27,13 @@ import java.util.Map;
|
||||
*/
|
||||
public class ConsumerServiceTest extends BaseTest {
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
|
||||
private final static Integer REAL_BROKER_ID_IN_ZK = 1;
|
||||
|
||||
private final static Long INVALID_CLUSTER_ID = -1L;
|
||||
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
/**
|
||||
* 集群共包括三个broker:1,2,3, 该topic 1分区 1副本因子,在broker1上
|
||||
*/
|
||||
private final static String REAL_TOPIC1_IN_ZK = "moduleTest";
|
||||
@Value("${test.topic.name1}")
|
||||
private String REAL_TOPIC1_IN_ZK;
|
||||
|
||||
/**
|
||||
* 集群共包括三个broker:1,2,3, 该topic 2分区 3副本因子,在broker1,2,3上
|
||||
@@ -44,17 +42,21 @@ public class ConsumerServiceTest extends BaseTest {
|
||||
|
||||
private final static String INVALID_TOPIC = "xxxxxx";
|
||||
|
||||
private final static String REAL_CONSUMER_GROUP_NAME = "moduleTestGroup";
|
||||
@Value("${test.consumer-group}")
|
||||
private String REAL_CONSUMER_GROUP_NAME;
|
||||
|
||||
private final static String INVALID_CONSUMER_GROUP_NAME = "xxxxxxxx";
|
||||
|
||||
private final static String REAL_PHYSICAL_CLUSTER_NAME = "LogiKM_moduleTest";
|
||||
@Value("${test.phyCluster.name}")
|
||||
private String REAL_PHYSICAL_CLUSTER_NAME;
|
||||
|
||||
private final static String ZOOKEEPER_ADDRESS = "10.190.12.242:2181,10.190.25.160:2181,10.190.25.41:2181/wyc";
|
||||
@Value("${test.ZK.address}")
|
||||
private String ZOOKEEPER_ADDRESS;
|
||||
|
||||
private final static String BOOTSTRAP_SERVERS = "10.190.12.242:9093,10.190.25.160:9093,10.190.25.41:9093";
|
||||
@Value("${test.ZK.bootstrap-servers}")
|
||||
private String BOOTSTRAP_SERVERS;
|
||||
|
||||
private final static String SECURITY_PROTOCOL = "{ \t\"security.protocol\": \"SASL_PLAINTEXT\", \t\"sasl.mechanism\": \"PLAIN\", \t\"sasl.jaas.config\": \"org.apache.kafka.common.security.plain.PlainLoginModule required username=\\\"dkm_admin\\\" password=\\\"km_kMl4N8as1Kp0CCY\\\";\" }";
|
||||
private String SECURITY_PROTOCOL = "{ \t\"security.protocol\": \"SASL_PLAINTEXT\", \t\"sasl.mechanism\": \"PLAIN\", \t\"sasl.jaas.config\": \"org.apache.kafka.common.security.plain.PlainLoginModule required username=\\\"dkm_admin\\\" password=\\\"km_kMl4N8as1Kp0CCY\\\";\" }";
|
||||
|
||||
@Autowired
|
||||
private ConsumerService consumerService;
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -27,9 +28,11 @@ import java.util.*;
|
||||
* @date 2021/12/27
|
||||
*/
|
||||
public class ExpertServiceTest extends BaseTest {
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static String REAL_TOPIC_IN_ZK = "topic_a";
|
||||
@Value("${test.topic.name4}")
|
||||
private String REAL_TOPIC_IN_ZK;
|
||||
|
||||
private final static Set<Integer> REAL_BROKER_ID_SET = new HashSet<>();
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.xiaojukeji.kafka.manager.common.zookeeper.znode.brokers.PartitionStat
|
||||
import com.xiaojukeji.kafka.manager.service.config.BaseTest;
|
||||
import org.apache.kafka.common.TopicPartition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -22,12 +23,14 @@ public class JmxServiceTest extends BaseTest {
|
||||
/**
|
||||
* 集群共包括三个broker:1,2,3, 该topic 1分区 1副本因子,在broker1上
|
||||
*/
|
||||
private final static String REAL_TOPIC1_IN_ZK = "moduleTest";
|
||||
@Value("${test.topic.name1}")
|
||||
private String REAL_TOPIC1_IN_ZK;
|
||||
|
||||
/**
|
||||
* 集群共包括三个broker:1,2,3, 该topic 2分区 3副本因子,在broker1,2,3上
|
||||
*/
|
||||
private final static String REAL_TOPIC2_IN_ZK = "xgTest";
|
||||
@Value("${test.topic.name2}")
|
||||
private String REAL_TOPIC2_IN_ZK;
|
||||
|
||||
private final static String INVALID_TOPIC = "xxxxx";
|
||||
|
||||
@@ -35,9 +38,11 @@ public class JmxServiceTest extends BaseTest {
|
||||
|
||||
private final static String NO_OFFSET_CHANGE_TOPIC_IN_ZK = "NoOffsetChangeTopic";
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static Integer REAL_BROKER_ID_IN_ZK = 1;
|
||||
@Value("${test.broker.id1}")
|
||||
private Integer REAL_BROKER_ID_IN_ZK;
|
||||
|
||||
private final static Integer INVALID_BROKER_ID = -1;
|
||||
|
||||
@@ -45,7 +50,8 @@ public class JmxServiceTest extends BaseTest {
|
||||
|
||||
private final static Integer INVALID_PARTITION_ID = -1;
|
||||
|
||||
private final static String CLIENT_ID = "dkm_admin.moduleTest";
|
||||
@Value("${test.client-id}")
|
||||
private String CLIENT_ID;
|
||||
|
||||
private final static Integer INVALID_METRICS_CODE = -1;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@@ -37,17 +38,22 @@ public class KafkaBillServiceTest extends BaseTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@DataProvider(name = "provideKafkaBillDO")
|
||||
public static Object[][] provideKafkaBillDO() {
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private KafkaBillDO getKafkaBillDO() {
|
||||
KafkaBillDO kafkaBillDO = new KafkaBillDO();
|
||||
kafkaBillDO.setClusterId(1L);
|
||||
kafkaBillDO.setClusterId(REAL_CLUSTER_ID_IN_MYSQL);
|
||||
kafkaBillDO.setCost(100.0d);
|
||||
kafkaBillDO.setGmtCreate(new Date(1638605696062L));
|
||||
kafkaBillDO.setGmtDay("10");
|
||||
kafkaBillDO.setPrincipal("admin");
|
||||
kafkaBillDO.setPrincipal(ADMIN);
|
||||
kafkaBillDO.setQuota(1000.0d);
|
||||
kafkaBillDO.setTopicName("moduleTest");
|
||||
return new Object[][] {{kafkaBillDO}};
|
||||
return kafkaBillDO;
|
||||
}
|
||||
|
||||
private BrokerMetricsDO getBrokerMetricsDO() {
|
||||
@@ -56,8 +62,9 @@ public class KafkaBillServiceTest extends BaseTest {
|
||||
return metricsDO;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideKafkaBillDO")
|
||||
public void replaceTest(KafkaBillDO kafkaBillDO) {
|
||||
@Test()
|
||||
public void replaceTest() {
|
||||
KafkaBillDO kafkaBillDO = getKafkaBillDO();
|
||||
// 插入成功
|
||||
replace2SuccessTest(kafkaBillDO);
|
||||
// 插入失败
|
||||
@@ -76,8 +83,9 @@ public class KafkaBillServiceTest extends BaseTest {
|
||||
Assert.assertEquals(result, 0);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideKafkaBillDO")
|
||||
public void getByTopicNameTest(KafkaBillDO kafkaBillDO) {
|
||||
@Test()
|
||||
public void getByTopicNameTest() {
|
||||
KafkaBillDO kafkaBillDO = getKafkaBillDO();
|
||||
// 查询成功
|
||||
getByTopicName2SuccessTest(kafkaBillDO);
|
||||
// 查询异常
|
||||
@@ -102,8 +110,9 @@ public class KafkaBillServiceTest extends BaseTest {
|
||||
Assert.assertTrue(result.isEmpty());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideKafkaBillDO")
|
||||
public void getByPrincipalTest(KafkaBillDO kafkaBillDO) {
|
||||
@Test()
|
||||
public void getByPrincipalTest() {
|
||||
KafkaBillDO kafkaBillDO = getKafkaBillDO();
|
||||
// 查询成功
|
||||
getByPrincipal2SuccessTest(kafkaBillDO);
|
||||
// 查询失败
|
||||
@@ -127,8 +136,9 @@ public class KafkaBillServiceTest extends BaseTest {
|
||||
Assert.assertTrue(result.isEmpty());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideKafkaBillDO")
|
||||
public void getByTimeBetweenTest(KafkaBillDO kafkaBillDO) {
|
||||
@Test()
|
||||
public void getByTimeBetweenTest() {
|
||||
KafkaBillDO kafkaBillDO = getKafkaBillDO();
|
||||
// 查询成功
|
||||
getByTimeBetween2SuccessTest(kafkaBillDO);
|
||||
// 查询失败
|
||||
@@ -152,8 +162,9 @@ public class KafkaBillServiceTest extends BaseTest {
|
||||
Assert.assertTrue(result.isEmpty());
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideKafkaBillDO")
|
||||
public void getByGmtDayTest(KafkaBillDO kafkaBillDO) {
|
||||
@Test()
|
||||
public void getByGmtDayTest() {
|
||||
KafkaBillDO kafkaBillDO = getKafkaBillDO();
|
||||
// 查询成功
|
||||
getByGmtDay2SuccessTest(kafkaBillDO);
|
||||
// 查询失败
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@@ -33,7 +34,8 @@ public class LogicalClusterServiceTest extends BaseTest {
|
||||
|
||||
private final static Long INVALID_CLUSTER_ID = -1L;
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
@Autowired
|
||||
@InjectMocks
|
||||
|
||||
@@ -54,12 +54,6 @@ public class OperateRecordServiceTest extends BaseTest {
|
||||
Assert.assertEquals(result, 1);
|
||||
}
|
||||
|
||||
// @Test(dataProvider = "operateRecordDO", description = "插入操作记录失败测试")
|
||||
// public void insert2FailureTest(OperateRecordDO operateRecordDO) {
|
||||
// operateRecordDO.setResource(null);
|
||||
// int result = operateRecordService.insert(operateRecordDO);
|
||||
// Assert.assertEquals(result, 0);
|
||||
// }
|
||||
|
||||
|
||||
@Test(description = "插入的重载方法操作成功测试")
|
||||
@@ -70,13 +64,6 @@ public class OperateRecordServiceTest extends BaseTest {
|
||||
Assert.assertEquals(result, 1);
|
||||
}
|
||||
|
||||
// @Test(description = "插入的重载方法操作失败测试")
|
||||
// public void insert2FailureTest1() {
|
||||
// Map<String, String> content = new HashMap<>();
|
||||
// content.put("key", "value");
|
||||
// int result = operateRecordService.insert(null, ModuleEnum.CLUSTER, "testOpRecord", OperateEnum.ADD, content);
|
||||
// Assert.assertEquals(result, 0);
|
||||
// }
|
||||
|
||||
@Test(dataProvider = "operateRecordDO")
|
||||
public void queryByConditionTest(OperateRecordDO operateRecordDO) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -33,9 +34,11 @@ public class ReassignServiceTest extends BaseTest {
|
||||
/**
|
||||
* 集群共包括三个broker:1,2,3, 该topic 2分区 3副本因子,在broker1,2,3上
|
||||
*/
|
||||
private final static String REAL_TOPIC2_IN_ZK = "xgTest";
|
||||
@Value("${test.topic.name2}")
|
||||
private String REAL_TOPIC2_IN_ZK;
|
||||
|
||||
private final static String ADMIN_OPERATOR = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN_OPERATOR;
|
||||
|
||||
@Autowired
|
||||
@InjectMocks
|
||||
@@ -55,19 +58,22 @@ public class ReassignServiceTest extends BaseTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
// private final static String ZOOKEEPER_ADDRESS = "10.190.46.198:2181,10.190.14.237:2181,10.190.50.65:2181/xg";
|
||||
private final static String ZOOKEEPER_ADDRESS = "10.190.12.242:2181,10.190.25.160:2181,10.190.25.41:2181/wyc";
|
||||
@Value("${test.ZK.address}")
|
||||
private String ZOOKEEPER_ADDRESS;
|
||||
|
||||
private final static String BOOTSTRAP_SERVERS = "10.190.12.242:9093,10.190.25.160:9093,10.190.25.41:9093";
|
||||
@Value("${test.ZK.bootstrap-servers}")
|
||||
private String BOOTSTRAP_SERVERS;
|
||||
|
||||
private final static String SECURITY_PROTOCOL = "{ \t\"security.protocol\": \"SASL_PLAINTEXT\", \t\"sasl.mechanism\": \"PLAIN\", \t\"sasl.jaas.config\": \"org.apache.kafka.common.security.plain.PlainLoginModule required username=\\\"dkm_admin\\\" password=\\\"km_kMl4N8as1Kp0CCY\\\";\" }";
|
||||
|
||||
private final static String REASSIGNMENTJSON =
|
||||
"{ \"version\": 1, \"partitions\": [ { \"topic\": \"reassignTest\", \"partition\": 1, \"replicas\": [ 1,2,3 ], \"log_dirs\": [ \"any\",\"any\",\"any\" ] }, { \"topic\": \"reassignTest\", \"partition\": 0, \"replicas\": [ 1,2,3 ], \"log_dirs\": [ \"any\",\"any\",\"any\" ] } ] }";
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static String REAL_PHYSICAL_CLUSTER_NAME = "LogiKM_moduleTest";
|
||||
@Value("${test.phyCluster.name}")
|
||||
private String REAL_PHYSICAL_CLUSTER_NAME;
|
||||
|
||||
|
||||
private ReassignTopicDTO getReassignTopicDTO() {
|
||||
@@ -76,7 +82,7 @@ public class ReassignServiceTest extends BaseTest {
|
||||
reassignTopicDTO.setClusterId(REAL_CLUSTER_ID_IN_MYSQL);
|
||||
reassignTopicDTO.setTopicName(REAL_TOPIC2_IN_ZK);
|
||||
reassignTopicDTO.setBrokerIdList(Arrays.asList(2,3));
|
||||
reassignTopicDTO.setRegionId(2L);
|
||||
reassignTopicDTO.setRegionId(1000000L);
|
||||
// 原本Topic只有两个分区
|
||||
reassignTopicDTO.setPartitionIdList(Arrays.asList(0, 1));
|
||||
reassignTopicDTO.setThrottle(100000L);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ListUtils;
|
||||
import com.xiaojukeji.kafka.manager.service.config.BaseTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -19,11 +20,14 @@ import java.util.stream.Collectors;
|
||||
* @date 2021/12/8
|
||||
*/
|
||||
public class RegionServiceTest extends BaseTest{
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static String REAL_REGION_NAME_IN_CLUSTER = "region_1";
|
||||
@Value("${test.region-name}")
|
||||
private String REAL_REGION_NAME_IN_CLUSTER;
|
||||
|
||||
private final static String REAL_TOPIC1_IN_ZK = "moduleTest";
|
||||
@Value("${test.topic.name1}")
|
||||
private String REAL_TOPIC1_IN_ZK;
|
||||
@Autowired
|
||||
private RegionService regionService;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -22,21 +23,18 @@ import java.util.*;
|
||||
*/
|
||||
public class ThrottleServiceTest extends BaseTest {
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static String REAL_TOPIC_IN_ZK = "moduleTest";
|
||||
@Value("${test.topic.name1}")
|
||||
private String REAL_TOPIC_IN_ZK;
|
||||
|
||||
private final static String ADMIN_NAME_IN_MYSQL = "admin";
|
||||
@Value("${test.app.id}")
|
||||
private String KAFKA_MANAGER_APP_ID;
|
||||
|
||||
private final static String KAFKA_MANAGER_APP_NAME = "KM管理员";
|
||||
|
||||
private final static String KAFKA_MANAGER_APP_ID = "dkm_admin";
|
||||
|
||||
private final static Set<Integer> REAL_BROKER_ID_SET = new HashSet<>();
|
||||
|
||||
// 共享集群
|
||||
private final static Integer REAL_LOGICAL_CLUSTER_MODE = 0;
|
||||
|
||||
static {
|
||||
REAL_BROKER_ID_SET.add(1);
|
||||
REAL_BROKER_ID_SET.add(2);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicExpiredDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicExpiredDao;
|
||||
import com.xiaojukeji.kafka.manager.service.config.BaseTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -19,9 +20,11 @@ public class TopicExpiredServiceTest extends BaseTest {
|
||||
/*
|
||||
该topic在region_1上,region_1使用了1,2broker,该topic3个分区,2个副本
|
||||
*/
|
||||
private final static String REAL_TOPIC1_IN_ZK = "topic_a";
|
||||
@Value("${test.topic.name4}")
|
||||
private String REAL_TOPIC1_IN_ZK;
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -37,21 +38,27 @@ import java.util.*;
|
||||
* @date 2021/12/21
|
||||
*/
|
||||
public class TopicManagerServiceTest extends BaseTest {
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static String REAL_TOPIC_IN_ZK = "topic_a";
|
||||
@Value("${test.topic.name4}")
|
||||
private String REAL_TOPIC_IN_ZK;
|
||||
|
||||
private final static String ADMIN_NAME_IN_MYSQL = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN_NAME_IN_MYSQL;
|
||||
|
||||
private final static String KAFKA_MANAGER_APP_NAME = "KM管理员";
|
||||
|
||||
private final static String KAFKA_MANAGER_APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String KAFKA_MANAGER_APP_ID;
|
||||
|
||||
private final static Set<Integer> REAL_BROKER_ID_SET = new HashSet<>();
|
||||
|
||||
private final static String REAL_REGION_IN_CLUSTER = "region1";
|
||||
@Value("${test.region-name}")
|
||||
private String REAL_REGION_IN_CLUSTER;
|
||||
|
||||
private final static String REAL_LOGICAL_CLUSTER_NAME = "logical_cluster_1";
|
||||
@Value("${test.logicalCluster.name}")
|
||||
private String REAL_LOGICAL_CLUSTER_NAME;
|
||||
|
||||
// 共享集群
|
||||
private final static Integer REAL_LOGICAL_CLUSTER_MODE = 0;
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -46,35 +47,44 @@ public class TopicServiceTest extends BaseTest {
|
||||
* 集群共包括三个broker:1,2,3, 该topic 1分区 1副本因子,在broker1上
|
||||
* 要求测试之前,moduleTest这个topic需要有过生产者生产和消费者消费moduleTest
|
||||
*/
|
||||
private final static String REAL_TOPIC1_IN_ZK = "moduleTest";
|
||||
@Value("${test.topic.name1}")
|
||||
private String REAL_TOPIC1_IN_ZK;
|
||||
|
||||
/**
|
||||
* 集群共包括三个broker:1,2,3, 该topic 2分区 3副本因子,在broker1,2,3上
|
||||
*/
|
||||
private final static String REAL_TOPIC2_IN_ZK = "xgTest";
|
||||
@Value("${test.topic.name2}")
|
||||
private String REAL_TOPIC2_IN_ZK;
|
||||
|
||||
private final static String INVALID_TOPIC = "xxxxx";
|
||||
|
||||
private final static String ZK_DEFAULT_TOPIC = "_consumer_offsets";
|
||||
@Value("${test.topic.name6}")
|
||||
private String ZK_DEFAULT_TOPIC;
|
||||
|
||||
/**
|
||||
* 该topic同样需要被创建,但是不能有流量
|
||||
*/
|
||||
private final static String NO_OFFSET_CHANGE_TOPIC_IN_ZK = "NoOffsetChangeTopic";
|
||||
@Value("${test.topic.name5}")
|
||||
private String NO_OFFSET_CHANGE_TOPIC_IN_ZK;
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private final static Integer REAL_BROKER_ID_IN_ZK = 3;
|
||||
@Value("${test.broker.id3}")
|
||||
private Integer REAL_BROKER_ID_IN_ZK;
|
||||
|
||||
private final static Long INVALID_CLUSTER_ID = -1L;
|
||||
|
||||
private final static Integer INVALID_PARTITION_ID = -1;
|
||||
|
||||
private final static String REAL_PHYSICAL_CLUSTER_NAME = "LogiKM_moduleTest";
|
||||
@Value("${test.phyCluster.name}")
|
||||
private String REAL_PHYSICAL_CLUSTER_NAME;
|
||||
|
||||
private final static String ZOOKEEPER_ADDRESS = "10.190.12.242:2181,10.190.25.160:2181,10.190.25.41:2181/wyc";
|
||||
@Value("${test.ZK.address}")
|
||||
private String ZOOKEEPER_ADDRESS;
|
||||
|
||||
private final static String BOOTSTRAP_SERVERS = "10.190.12.242:9093,10.190.25.160:9093,10.190.25.41:9093";
|
||||
@Value("${test.ZK.bootstrap-servers}")
|
||||
private String BOOTSTRAP_SERVERS;
|
||||
|
||||
private final static String SECURITY_PROTOCOL = "{ \t\"security.protocol\": \"SASL_PLAINTEXT\", \t\"sasl.mechanism\": \"PLAIN\", \t\"sasl.jaas.config\": \"org.apache.kafka.common.security.plain.PlainLoginModule required username=\\\"dkm_admin\\\" password=\\\"km_kMl4N8as1Kp0CCY\\\";\" }";
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.xiaojukeji.kafka.manager.common.zookeeper.znode.didi.TopicJmxSwitch;
|
||||
import com.xiaojukeji.kafka.manager.service.config.BaseTest;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@@ -25,8 +26,8 @@ public class ZookeeperServiceTest extends BaseTest {
|
||||
@Autowired
|
||||
private ZookeeperService zookeeperService;
|
||||
|
||||
// private final static String ZOOKEEPER_ADDRESS = "10.190.46.198:2181,10.190.14.237:2181,10.190.50.65:2181/xg";
|
||||
private final static String ZOOKEEPER_ADDRESS = "10.190.12.242:2181,10.190.25.160:2181,10.190.25.41:2181/wyc";
|
||||
@Value("${test.ZK.address}")
|
||||
private String ZOOKEEPER_ADDRESS;
|
||||
|
||||
|
||||
@DataProvider(name = "extendsAndCandidatesZnodeExist")
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO;
|
||||
import com.xiaojukeji.kafka.manager.service.config.BaseTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -21,14 +22,19 @@ public class TopicConnectionServiceTest extends BaseTest {
|
||||
@Autowired
|
||||
private TopicConnectionService topicConnectionService;
|
||||
|
||||
private static final String TOPIC_NAME = "moduleTest";
|
||||
@Value("${test.topic.name1}")
|
||||
private String TOPIC_NAME;
|
||||
|
||||
private static final Long CLUSTER_ID = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long CLUSTER_ID;
|
||||
|
||||
private static final String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
@DataProvider(name = "provideTopicConnection")
|
||||
public static Object[][] provideTopicConnection() {
|
||||
@Value("${test.gateway}")
|
||||
private String GATEWAY;
|
||||
|
||||
public TopicConnectionDO getTopicConnectionDO() {
|
||||
TopicConnectionDO topicConnectionDO = new TopicConnectionDO();
|
||||
topicConnectionDO.setId(13L);
|
||||
topicConnectionDO.setAppId(APP_ID);
|
||||
@@ -36,10 +42,10 @@ public class TopicConnectionServiceTest extends BaseTest {
|
||||
topicConnectionDO.setTopicName(TOPIC_NAME);
|
||||
topicConnectionDO.setType("fetch");
|
||||
// topicConnectionDO.setIp("172.23.142.253");
|
||||
topicConnectionDO.setIp("172.23.161.128");
|
||||
topicConnectionDO.setIp(GATEWAY);
|
||||
topicConnectionDO.setClientVersion("2.4");
|
||||
topicConnectionDO.setCreateTime(new Date(1638786493173L));
|
||||
return new Object[][] {{topicConnectionDO}};
|
||||
return topicConnectionDO;
|
||||
}
|
||||
|
||||
// 测试批量插入为空的情况
|
||||
@@ -49,8 +55,9 @@ public class TopicConnectionServiceTest extends BaseTest {
|
||||
}
|
||||
|
||||
// 测试批量插入成功的情况,通过调整list的数量和TopicConnectionServiceImpl中splitInterval的数量,使每个流程都测试一遍
|
||||
@Test(dataProvider = "provideTopicConnection")
|
||||
private void batchAdd2SuccessTest(TopicConnectionDO topicConnectionDO) {
|
||||
@Test()
|
||||
private void batchAdd2SuccessTest() {
|
||||
TopicConnectionDO topicConnectionDO = getTopicConnectionDO();
|
||||
List<TopicConnectionDO> list = new ArrayList<>();
|
||||
list.add(topicConnectionDO);
|
||||
list.add(topicConnectionDO);
|
||||
@@ -58,8 +65,9 @@ public class TopicConnectionServiceTest extends BaseTest {
|
||||
topicConnectionService.batchAdd(list);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideTopicConnection")
|
||||
public void getByTopicName2Test(TopicConnectionDO topicConnectionDO) {
|
||||
@Test()
|
||||
public void getByTopicName2Test() {
|
||||
TopicConnectionDO topicConnectionDO = getTopicConnectionDO();
|
||||
List<TopicConnection> result = topicConnectionService.getByTopicName(CLUSTER_ID, TOPIC_NAME, new Date(0L), new Date());
|
||||
Assert.assertFalse(result.isEmpty());
|
||||
}
|
||||
@@ -72,8 +80,9 @@ public class TopicConnectionServiceTest extends BaseTest {
|
||||
}
|
||||
|
||||
// 测试获取数据,clusterId不为null,TODO
|
||||
@Test(dataProvider = "provideTopicConnection")
|
||||
public void getByTopicName2SuccessTest(TopicConnectionDO topicConnectionDO) {
|
||||
@Test()
|
||||
public void getByTopicName2SuccessTest() {
|
||||
TopicConnectionDO topicConnectionDO = getTopicConnectionDO();
|
||||
List<TopicConnectionDO> list = new ArrayList<>();
|
||||
list.add(topicConnectionDO);
|
||||
topicConnectionService.batchAdd(list);
|
||||
|
||||
@@ -96,3 +96,32 @@ notify:
|
||||
topic-name: didi-kafka-notify
|
||||
order:
|
||||
detail-url: http://127.0.0.1
|
||||
|
||||
test:
|
||||
topic:
|
||||
name1: moduleTest
|
||||
name2: xgTest
|
||||
name3: expandPartitionTopic
|
||||
name4: topic_a
|
||||
name5: NoOffsetChangeTopic
|
||||
name6: _consumer_offsets
|
||||
phyCluster:
|
||||
id: 1
|
||||
name: LogiKM_moduleTest
|
||||
logicalCluster:
|
||||
name: logical_cluster_1
|
||||
broker:
|
||||
id1: 1
|
||||
id2: 2
|
||||
id3: 3
|
||||
app:
|
||||
id: dkm_admin
|
||||
ZK:
|
||||
address: 10.190.12.242:2181,10.190.25.160:2181,10.190.25.41:2181/wyc
|
||||
bootstrap-servers: 10.190.12.242:9093,10.190.25.160:9093,10.190.25.41:9093
|
||||
gateway: 172.23.161.128
|
||||
sasl-plaintext: SASL_PLAINTEXT://10.179.162.202:9093
|
||||
admin: admin
|
||||
consumer-group: moduleTestGroup
|
||||
client-id: dkm_admin.moduleTest
|
||||
region-name: region_1
|
||||
|
||||
Reference in New Issue
Block a user