mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +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
|
||||
|
||||
@@ -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;
|
||||
@@ -32,7 +33,8 @@ import java.util.List;
|
||||
*/
|
||||
public class OrderServiceTest extends BaseTest {
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final Integer INVALID_ORDER_TYPE = -1;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -32,7 +33,8 @@ public class ApplyAppOrderTest extends BaseTest {
|
||||
|
||||
private static final Long ORDER_ID = 1L;
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final Integer APPLY_TOPIC_TYPE = 0;
|
||||
|
||||
@@ -41,7 +43,8 @@ public class ApplyAppOrderTest extends BaseTest {
|
||||
*/
|
||||
private static final Integer ORDER_PASSED_STATUS = 1;
|
||||
|
||||
private static final String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("applyAppOrder")
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -38,15 +39,18 @@ public class ApplyAuthorityOrderTest extends BaseTest {
|
||||
|
||||
private final static String TOPIC_NOT_EXIST_EXTENSIONS = "{\"clusterId\":7,\"topicName\":\"xxxx\",\"appId\":\"dkm_admin\",\"access\":\"3\"}";
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private static final Long ORDER_ID = 1L;
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final Integer APPLY_TOPIC_TYPE = 0;
|
||||
|
||||
private static final String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
private static final String INVALIDE_USER = "xxxx";
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -25,7 +26,8 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class ApplyClusterOrderTest extends BaseTest {
|
||||
|
||||
private final static String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
private final static String IDC = "国内";
|
||||
|
||||
@@ -33,7 +35,8 @@ public class ApplyClusterOrderTest extends BaseTest {
|
||||
|
||||
private final static String INVALID_IDC = "xxx";
|
||||
|
||||
private final static String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("applyClusterOrder")
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -38,14 +39,16 @@ public class ApplyPartitionOrderTest extends BaseTest {
|
||||
|
||||
private static final String INVALIDE_APPROVE_ORDER_APPLY_DETAIL = "{\"brokerIdList\":[3],\"partitionNum\":0,\"regionId\":1}";
|
||||
|
||||
private static final Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
/**
|
||||
* 工单状态, 0:待审批, 1:通过, 2:拒绝, 3:取消
|
||||
*/
|
||||
private static final Integer ORDER_PASSED_STATUS = 1;
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final String INVALID_USER_NAME = "xxxxx";
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -37,7 +38,8 @@ import java.util.Date;
|
||||
*/
|
||||
public class ApplyQuotaOrderTest extends BaseTest {
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final String INVALID_USER_NAME = "xxxxx";
|
||||
|
||||
@@ -55,7 +57,8 @@ public class ApplyQuotaOrderTest extends BaseTest {
|
||||
|
||||
private static final String APPROVE_ORDER_APPLY_DETAIL = "{\"brokerIdList\":[3],\"partitionNum\":1,\"regionId\":1}";
|
||||
|
||||
private static final Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
/**
|
||||
* 工单状态, 0:待审批, 1:通过, 2:拒绝, 3:取消
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -34,7 +35,8 @@ import java.util.Date;
|
||||
* @Date 2021/12/27
|
||||
*/
|
||||
public class ApplyTopicOrderTest extends BaseTest {
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final String INVALID_USER_NAME = "xxxxx";
|
||||
|
||||
@@ -52,7 +54,8 @@ public class ApplyTopicOrderTest extends BaseTest {
|
||||
|
||||
private static final String APPROVE_ORDER_APPLY_DETAIL = "{\"brokerIdList\":[3],\"partitionNum\":1,\"replicaNum\":1,\"retentionTime\":12}";
|
||||
|
||||
private static final Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
/**
|
||||
* 工单状态, 0:待审批, 1:通过, 2:拒绝, 3:取消
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -35,7 +36,8 @@ public class DeleteAppOrderTest extends BaseTest {
|
||||
|
||||
private static final Long ORDER_ID = 1L;
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final Integer APPLY_TOPIC_TYPE = 0;
|
||||
|
||||
@@ -43,9 +45,6 @@ public class DeleteAppOrderTest extends BaseTest {
|
||||
* 工单状态, 0:待审批, 1:通过, 2:拒绝, 3:取消
|
||||
*/
|
||||
private static final Integer ORDER_PASSED_STATUS = 1;
|
||||
|
||||
private static final String APP_ID = "dkm_admin";
|
||||
|
||||
@Autowired
|
||||
@Qualifier("deleteAppOrder")
|
||||
@InjectMocks
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -32,15 +33,18 @@ public class DeleteAuthorityOrderTest extends BaseTest {
|
||||
|
||||
private final static String EXTENSIONS = "{\"clusterId\":7,\"topicName\":\"moduleTest\",\"appId\":\"dkm_admin\",\"access\":\"3\"}";
|
||||
|
||||
@Value("${test.phyCluster.id}")
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
|
||||
private static final Long ORDER_ID = 1L;
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final Integer APPLY_TOPIC_TYPE = 0;
|
||||
|
||||
private static final String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
private static final String INVALIDE_USER = "xxxx";
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -30,7 +31,8 @@ import java.util.Set;
|
||||
*/
|
||||
public class DeleteClusterOrderTest extends BaseTest {
|
||||
|
||||
private final static String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
private final static String IDC = "国内";
|
||||
|
||||
@@ -38,7 +40,8 @@ public class DeleteClusterOrderTest extends BaseTest {
|
||||
|
||||
private final static String INVALID_IDC = "xxx";
|
||||
|
||||
private final static String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private final static Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -35,7 +36,8 @@ import java.util.Date;
|
||||
*/
|
||||
public class DeleteTopicOrderTest extends BaseTest {
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final String INVALID_USER_NAME = "xxxxx";
|
||||
|
||||
@@ -53,11 +55,13 @@ public class DeleteTopicOrderTest extends BaseTest {
|
||||
|
||||
private static final String APPROVE_ORDER_APPLY_DETAIL = "{\"brokerIdList\":[3],\"partitionNum\":1,\"replicaNum\":1,\"retentionTime\":12}";
|
||||
|
||||
private static final Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private static final Long INVALID_CLUSTER_ID = -1L;
|
||||
|
||||
private static final String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
/**
|
||||
* 工单状态, 0:待审批, 1:通过, 2:拒绝, 3:取消
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -25,7 +26,8 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class ModifyClusterOrderTest extends BaseTest {
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final String INVALID_USER_NAME = "xxxxx";
|
||||
|
||||
@@ -39,7 +41,8 @@ public class ModifyClusterOrderTest extends BaseTest {
|
||||
|
||||
private static final String EXTENSIONS = "{\"clusterId\":7}";
|
||||
|
||||
private static final Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("modifyClusterOrder")
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -23,8 +24,8 @@ import org.testng.annotations.Test;
|
||||
* @Date 2021/12/31
|
||||
*/
|
||||
public class ModifyGatewayConfigOrderTest extends BaseTest {
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final String INVALID_USER_NAME = "xxxxx";
|
||||
|
||||
@@ -48,7 +49,8 @@ public class ModifyGatewayConfigOrderTest extends BaseTest {
|
||||
|
||||
private static final Long INVALID_CLUSTER_ID = -1L;
|
||||
|
||||
private static final String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
/**
|
||||
* 工单状态, 0:待审批, 1:通过, 2:拒绝, 3:取消
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -34,8 +35,8 @@ import java.util.Date;
|
||||
* @Date 2021/12/31
|
||||
*/
|
||||
public class ThirdPartDeleteTopicOrderTest extends BaseTest {
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final String INVALID_USER_NAME = "xxxxx";
|
||||
|
||||
@@ -53,11 +54,13 @@ public class ThirdPartDeleteTopicOrderTest extends BaseTest {
|
||||
|
||||
private static final String APPROVE_ORDER_APPLY_DETAIL = "{\"brokerIdList\":[3],\"partitionNum\":1,\"replicaNum\":1,\"retentionTime\":12}";
|
||||
|
||||
private static final Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private static final Long INVALID_CLUSTER_ID = -1L;
|
||||
|
||||
private static final String APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String APP_ID;
|
||||
|
||||
/**
|
||||
* 工单状态, 0:待审批, 1:通过, 2:拒绝, 3:取消
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -30,9 +31,11 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class ClusterTaskServiceTest extends BaseTest {
|
||||
|
||||
private static final Long REAL_CLUSTER_ID_IN_MYSQL = 1L;
|
||||
@Value("${test.phyCluster.id}")
|
||||
private Long REAL_CLUSTER_ID_IN_MYSQL;
|
||||
|
||||
private static final String ADMIN = "admin";
|
||||
@Value("${test.admin}")
|
||||
private String ADMIN;
|
||||
|
||||
private static final String BASEURL = "127.0.0.1";
|
||||
|
||||
|
||||
@@ -13,6 +13,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.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -28,6 +29,7 @@ public class KafkaFileServiceTest extends BaseTest {
|
||||
|
||||
private static final Long KAFKA_FILE_ID = 1L;
|
||||
|
||||
@Value("${test.admin}")
|
||||
private static final String ADMIN = "admin";
|
||||
|
||||
private KafkaFileDTO getKafkaFileDTO() {
|
||||
|
||||
@@ -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
|
||||
@@ -13,6 +13,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;
|
||||
@@ -28,25 +29,32 @@ import java.util.List;
|
||||
*/
|
||||
public class ThirdPartServiceTest 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 REAL_PHYSICAL_CLUSTER_NAME = "LogiKM_moduleTest";
|
||||
@Value("${test.phyCluster.name}")
|
||||
private String REAL_PHYSICAL_CLUSTER_NAME;
|
||||
|
||||
private final static String ZOOKEEPER = "10.190.12.242:2181,10.190.25.160:2181,10.190.25.41:2181/wyc";
|
||||
@Value("${test.ZK.address}")
|
||||
private String ZOOKEEPER;
|
||||
|
||||
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_PROPERTIES = "{ \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 JMX_PROPERTIES = "{\n" + "\t\"maxConn\": 100000\n" + "}";
|
||||
private final static Integer STATUS = 1;
|
||||
|
||||
private final static String REAL_APP_ID = "dkm_admin";
|
||||
@Value("${test.app.id}")
|
||||
private String REAL_APP_ID;
|
||||
|
||||
// 要求消费moduleTest这个topic的消费者所属的消费者组是moduleTestGroup
|
||||
private final static String REAL_CONSUMER_GROUP_ID = "moduleTestGroup";
|
||||
@Value("${test.consumer-group}")
|
||||
private String REAL_CONSUMER_GROUP_ID;
|
||||
|
||||
@Autowired
|
||||
@InjectMocks
|
||||
|
||||
@@ -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
|
||||
@@ -106,6 +106,11 @@
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${spring-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.xiaojukeji.kafka.manager.web.api.versionone.op;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.op.topic.TopicCreationDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.op.topic.TopicDeletionDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.op.topic.TopicModificationDTO;
|
||||
import com.xiaojukeji.kafka.manager.web.config.BaseTest;
|
||||
import com.xiaojukeji.kafka.manager.web.config.Constant;
|
||||
import com.xiaojukeji.kafka.manager.web.config.HttpUtils;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.*;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wyc
|
||||
* @date 2022/1/20
|
||||
*/
|
||||
public class opTopicControllerTest extends BaseTest {
|
||||
private final TestRestTemplate testRestTemplate = new TestRestTemplate();
|
||||
|
||||
|
||||
private TopicCreationDTO getTopicCreationDTO() {
|
||||
// 在broker1上创建1分区,1副本的createTopicTest
|
||||
TopicCreationDTO creationDTO = new TopicCreationDTO();
|
||||
creationDTO.setAppId(Constant.APPID_IN_MYSQL);
|
||||
// 在broker1上创建
|
||||
creationDTO.setBrokerIdList(Arrays.asList(1));
|
||||
creationDTO.setPartitionNum(1);
|
||||
creationDTO.setReplicaNum(1);
|
||||
creationDTO.setRetentionTime(1000L * 60 * 60 * 168);
|
||||
creationDTO.setPeakBytesIn(10L * 1024 * 1024);
|
||||
// 物理集群id
|
||||
creationDTO.setClusterId(Constant.PHYSICAL_CLUSTER_ID_IN_MYSQL);
|
||||
creationDTO.setTopicName("createTopicTest");
|
||||
return creationDTO;
|
||||
}
|
||||
|
||||
private TopicDeletionDTO getTopicDeletionDTO() {
|
||||
TopicDeletionDTO deletionDTO = new TopicDeletionDTO();
|
||||
deletionDTO.setClusterId(1L);
|
||||
deletionDTO.setTopicName("createTopicTest");
|
||||
deletionDTO.setUnForce(true);
|
||||
return deletionDTO;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createCommonTopicTest() {
|
||||
String url = Constant.BASE_URL + "/api/v1/op/topics";
|
||||
|
||||
// PARAM_ILLEGAL
|
||||
createCommonTopic1Test(url);
|
||||
// CLUSTER_NOT_EXIST
|
||||
createCommonTopic2Test(url);
|
||||
// SUCCESS
|
||||
createCommonTopic3Test(url);
|
||||
}
|
||||
|
||||
private void createCommonTopic1Test(String url) {
|
||||
HttpHeaders httpHeaders = HttpUtils.getHttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
TopicCreationDTO creationDTO = getTopicCreationDTO();
|
||||
creationDTO.setClusterId(null);
|
||||
|
||||
HttpEntity<TopicCreationDTO> httpEntity = new HttpEntity<>(creationDTO, httpHeaders);
|
||||
ResponseEntity<Result> result = testRestTemplate.exchange(url, HttpMethod.POST, httpEntity, Result.class);
|
||||
Assert.assertEquals(result.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result.getBody());
|
||||
Assert.assertEquals(result.getBody().getCode(), ResultStatus.PARAM_ILLEGAL.getCode());
|
||||
}
|
||||
|
||||
private void createCommonTopic2Test(String url) {
|
||||
HttpHeaders httpHeaders = HttpUtils.getHttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
TopicCreationDTO creationDTO = getTopicCreationDTO();
|
||||
creationDTO.setClusterId(-1L);
|
||||
|
||||
HttpEntity<TopicCreationDTO> httpEntity = new HttpEntity<>(creationDTO, httpHeaders);
|
||||
ResponseEntity<Result> result = testRestTemplate.exchange(url, HttpMethod.POST, httpEntity, Result.class);
|
||||
Assert.assertEquals(result.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result.getBody());
|
||||
Assert.assertEquals(result.getBody().getCode(), ResultStatus.CLUSTER_NOT_EXIST.getCode());
|
||||
}
|
||||
|
||||
private void createCommonTopic3Test(String url) {
|
||||
// 创建Topic
|
||||
HttpHeaders httpHeaders = HttpUtils.getHttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
TopicCreationDTO creationDTO = getTopicCreationDTO();
|
||||
HttpEntity<TopicCreationDTO> httpEntity = new HttpEntity<>(creationDTO, httpHeaders);
|
||||
ResponseEntity<Result> result = testRestTemplate.exchange(url, HttpMethod.POST, httpEntity, Result.class);
|
||||
Assert.assertEquals(result.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result.getBody());
|
||||
Assert.assertEquals(result.getBody().getCode(), ResultStatus.SUCCESS.getCode());
|
||||
|
||||
// 删除创建的topic
|
||||
TopicDeletionDTO topicDeletionDTO = getTopicDeletionDTO();
|
||||
HttpEntity<List<TopicDeletionDTO>> httpEntity2 = new HttpEntity<>(Arrays.asList(topicDeletionDTO), httpHeaders);
|
||||
ResponseEntity<Result> result2 = testRestTemplate.exchange(url, HttpMethod.DELETE, httpEntity2, Result.class);
|
||||
Assert.assertEquals(result2.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result2.getBody());
|
||||
Assert.assertEquals(result2.getBody().getCode(), ResultStatus.SUCCESS.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteTopicsTest() {
|
||||
String url = Constant.BASE_URL + "/api/v1/op/topics";
|
||||
// PARAM_ILLEGAL
|
||||
deleteTopics1Test(url);
|
||||
// OPERATION_FAILED
|
||||
deleteTopics2Test(url);
|
||||
// SUCCESS
|
||||
deleteTopics3Test(url);
|
||||
}
|
||||
|
||||
private void deleteTopics1Test(String url) {
|
||||
ArrayList<TopicDeletionDTO> deletionDTOArrayList = new ArrayList<>();
|
||||
for (int i = 0; i < 11; i++) {
|
||||
deletionDTOArrayList.add(getTopicDeletionDTO());
|
||||
}
|
||||
|
||||
HttpHeaders httpHeaders = HttpUtils.getHttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<List<TopicDeletionDTO>> httpEntity = new HttpEntity<>(deletionDTOArrayList, httpHeaders);
|
||||
ResponseEntity<Result> result = testRestTemplate.exchange(url, HttpMethod.DELETE, httpEntity, Result.class);
|
||||
Assert.assertEquals(result.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result.getBody());
|
||||
Assert.assertEquals(result.getBody().getCode(), ResultStatus.PARAM_ILLEGAL.getCode());
|
||||
}
|
||||
|
||||
private void deleteTopics2Test(String url) {
|
||||
HttpHeaders httpHeaders = HttpUtils.getHttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
TopicDeletionDTO topicDeletionDTO = getTopicDeletionDTO();
|
||||
topicDeletionDTO.setClusterId(-1L);
|
||||
HttpEntity<List<TopicDeletionDTO>> httpEntity = new HttpEntity<>(Arrays.asList(topicDeletionDTO), httpHeaders);
|
||||
ResponseEntity<Result> result = testRestTemplate.exchange(url, HttpMethod.DELETE, httpEntity, Result.class);
|
||||
Assert.assertEquals(result.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result.getBody());
|
||||
Assert.assertEquals(result.getBody().getCode(), ResultStatus.OPERATION_FAILED.getCode());
|
||||
}
|
||||
|
||||
private void deleteTopics3Test(String url) {
|
||||
// 创建Topic
|
||||
HttpHeaders httpHeaders = HttpUtils.getHttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
TopicCreationDTO creationDTO = getTopicCreationDTO();
|
||||
HttpEntity<TopicCreationDTO> httpEntity = new HttpEntity<>(creationDTO, httpHeaders);
|
||||
ResponseEntity<Result> result = testRestTemplate.exchange(url, HttpMethod.POST, httpEntity, Result.class);
|
||||
Assert.assertEquals(result.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result.getBody());
|
||||
Assert.assertEquals(result.getBody().getCode(), ResultStatus.SUCCESS.getCode());
|
||||
|
||||
// 删除创建的topic
|
||||
TopicDeletionDTO topicDeletionDTO = getTopicDeletionDTO();
|
||||
HttpEntity<List<TopicDeletionDTO>> httpEntity2 = new HttpEntity<>(Arrays.asList(topicDeletionDTO), httpHeaders);
|
||||
ResponseEntity<Result> result2 = testRestTemplate.exchange(url, HttpMethod.DELETE, httpEntity2, Result.class);
|
||||
Assert.assertEquals(result2.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result2.getBody());
|
||||
Assert.assertEquals(result2.getBody().getCode(), ResultStatus.SUCCESS.getCode());
|
||||
}
|
||||
|
||||
|
||||
private TopicModificationDTO getTopicModificationDTO() {
|
||||
TopicModificationDTO modificationDTO = new TopicModificationDTO();
|
||||
modificationDTO.setAppId(Constant.APPID_IN_MYSQL);
|
||||
modificationDTO.setClusterId(Constant.PHYSICAL_CLUSTER_ID_IN_MYSQL);
|
||||
modificationDTO.setTopicName("createTopicName");
|
||||
return modificationDTO;
|
||||
}
|
||||
|
||||
public void modifyTopicTest() {
|
||||
String url = Constant.BASE_URL + "/api/v1/op/topics";
|
||||
|
||||
}
|
||||
|
||||
public void modifyTopic1Test(String url) {
|
||||
// 创建Topic
|
||||
HttpHeaders httpHeaders = HttpUtils.getHttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
TopicCreationDTO creationDTO = getTopicCreationDTO();
|
||||
HttpEntity<TopicCreationDTO> httpEntity = new HttpEntity<>(creationDTO, httpHeaders);
|
||||
ResponseEntity<Result> result = testRestTemplate.exchange(url, HttpMethod.POST, httpEntity, Result.class);
|
||||
Assert.assertEquals(result.getStatusCodeValue(), HttpStatus.OK.value());
|
||||
Assert.assertNotNull(result.getBody());
|
||||
Assert.assertEquals(result.getBody().getCode(), ResultStatus.SUCCESS.getCode());
|
||||
|
||||
// 修改topic
|
||||
TopicModificationDTO topicModificationDTO = getTopicModificationDTO();
|
||||
HttpEntity<TopicModificationDTO> httpEntity2 = new HttpEntity<>(topicModificationDTO, httpHeaders);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user