refactor: update resource pool
This commit is contained in:
parent
a574f5f369
commit
5db28cfb25
|
@ -54,6 +54,9 @@ public class NodeResourcePoolService {
|
|||
}
|
||||
}
|
||||
isValid = validateNode(testResourceNodeDTO);
|
||||
if (!isValid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//校验节点
|
||||
List<ImmutablePair<String, String>> ipPort = nodesList.stream()
|
||||
|
|
|
@ -58,6 +58,9 @@ public class TestResourcePoolService {
|
|||
checkApiConfig(testResourceDTO, testResourcePool, testResourcePool.getType());
|
||||
checkLoadConfig(testResourceDTO, testResourcePool, testResourcePool.getType());
|
||||
checkUiConfig(testResourceDTO, testResourcePool);
|
||||
if (CollectionUtils.isEmpty(testResourceDTO.getNodesList())) {
|
||||
testResourceDTO.setNodesList(new ArrayList<>());
|
||||
}
|
||||
String configuration = JSON.toJSONString(testResourceDTO);
|
||||
testResourcePoolBlob.setConfiguration(configuration.getBytes());
|
||||
buildTestPoolBaseInfo(testResourcePool, id);
|
||||
|
@ -98,7 +101,9 @@ public class TestResourcePoolService {
|
|||
private static void buildTestPoolBaseInfo(TestResourcePool testResourcePool, String id) {
|
||||
testResourcePool.setId(id);
|
||||
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
||||
if (testResourcePool.getEnable() == null) {
|
||||
testResourcePool.setEnable(true);
|
||||
}
|
||||
testResourcePool.setDeleted(false);
|
||||
}
|
||||
|
||||
|
@ -179,6 +184,9 @@ public class TestResourcePoolService {
|
|||
checkApiConfig(testResourceDTO, testResourcePool, testResourcePool.getType());
|
||||
checkLoadConfig(testResourceDTO, testResourcePool, testResourcePool.getType());
|
||||
checkUiConfig(testResourceDTO, testResourcePool);
|
||||
if (CollectionUtils.isEmpty(testResourceDTO.getNodesList())) {
|
||||
testResourceDTO.setNodesList(new ArrayList<>());
|
||||
}
|
||||
String configuration = JSON.toJSONString(testResourceDTO);
|
||||
TestResourcePoolBlob testResourcePoolBlob = new TestResourcePoolBlob();
|
||||
testResourcePoolBlob.setId(testResourcePool.getId());
|
||||
|
@ -254,6 +262,9 @@ public class TestResourcePoolService {
|
|||
byte[] configuration = testResourcePoolBlob.getConfiguration();
|
||||
String testResourceDTOStr = new String(configuration);
|
||||
TestResourceDTO testResourceDTO = JSON.parseObject(testResourceDTOStr, TestResourceDTO.class);
|
||||
if (CollectionUtils.isEmpty(testResourceDTO.getNodesList())) {
|
||||
testResourceDTO.setNodesList(new ArrayList<>());
|
||||
}
|
||||
TestResourceReturnDTO testResourceReturnDTO = new TestResourceReturnDTO();
|
||||
BeanUtils.copyBean(testResourceReturnDTO, testResourceDTO);
|
||||
List<String> orgIds = testResourceDTO.getOrgIds();
|
||||
|
@ -341,17 +352,26 @@ public class TestResourcePoolService {
|
|||
throw new MSException(Translator.get("test_resource_pool_not_exists"));
|
||||
}
|
||||
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
||||
if (testResourcePool.getEnable()) {
|
||||
testResourcePool.setEnable(false);
|
||||
} else {
|
||||
testResourcePool.setEnable(true);
|
||||
}
|
||||
Boolean enable = testResourcePool.getEnable();
|
||||
if (!enable) {
|
||||
TestResourcePoolBlob testResourcePoolBlob = testResourcePoolBlobMapper.selectByPrimaryKey(testResourcePoolId);
|
||||
byte[] configuration = testResourcePoolBlob.getConfiguration();
|
||||
String testResourceDTOStr = new String(configuration);
|
||||
TestResourceDTO testResourceDTO = JSON.parseObject(testResourceDTOStr, TestResourceDTO.class);
|
||||
checkApiConfig(testResourceDTO, testResourcePool, testResourcePool.getType());
|
||||
checkLoadConfig(testResourceDTO, testResourcePool, testResourcePool.getType());
|
||||
boolean apiValidate = checkApiConfig(testResourceDTO, testResourcePool, testResourcePool.getType());
|
||||
if (! apiValidate) {
|
||||
throw new MSException(Translator.get("test_resource_pool_is_valid_fail"));
|
||||
}
|
||||
boolean loadValidate = checkLoadConfig(testResourceDTO, testResourcePool, testResourcePool.getType());
|
||||
if (! loadValidate) {
|
||||
throw new MSException(Translator.get("test_resource_pool_is_valid_fail"));
|
||||
}
|
||||
}
|
||||
if (enable) {
|
||||
testResourcePool.setEnable(false);
|
||||
} else {
|
||||
testResourcePool.setEnable(true);
|
||||
}
|
||||
testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ test_resource_pool_used_content_is_null = Resource pool use-related configuratio
|
|||
|
||||
load_test=Load Test
|
||||
test_resource_pool_is_use=This resource pool is in use and cannot be deleted
|
||||
test_resource_pool_is_valid_fail =The verification fails, please check whether the resource pool configuration is normal
|
||||
only_one_k8s=Only one K8S can be added
|
||||
test_resource_pool_not_exists=Test resource pool not exists
|
||||
test_resource_pool_invalid=Test resource pool invalid
|
||||
|
|
|
@ -72,6 +72,7 @@ test_resource_pool_type_is_null=资源池类型不能为空
|
|||
test_resource_pool_used_content_is_null = 资源池用途相关配置为空
|
||||
load_test=性能测试
|
||||
test_resource_pool_is_use=正在使用此资源池,无法删除
|
||||
test_resource_pool_is_valid_fail = 校验不通过,请管理员检查资源池是否配置正常
|
||||
only_one_k8s=只能添加一个 K8S
|
||||
test_resource_pool_not_exists=测试资源池不存在
|
||||
test_resource_pool_invalid=当前测试使用的资源池处于禁用状态
|
||||
|
|
|
@ -74,6 +74,8 @@ test_resource_pool_used_content_is_null = 資源池用途相關配置為空
|
|||
|
||||
load_test=性能測試
|
||||
test_resource_pool_is_use=正在使用此資源池,無法刪除
|
||||
test_resource_pool_is_valid_fail =校驗不通過,請管理員檢查資源池是否配置正常
|
||||
|
||||
only_one_k8s=只能添加一個 K8S
|
||||
test_resource_pool_not_exists=測試資源池不存在
|
||||
test_resource_pool_invalid=當前測試使用的資源池處於禁用狀態
|
||||
|
|
|
@ -54,10 +54,10 @@ class TestResourcePoolControllerTests extends BaseTest {
|
|||
" \"loadTestImage\": \"123\",\n" +
|
||||
" \"loadTestHeap\": \"123\",\n" +
|
||||
" \"nodesList\":[{\n" +
|
||||
" \"ip\":\"172.2.130.1\",\n" +
|
||||
" \"port\": \"3306\",\n" +
|
||||
" \"monitor\": \"11\",\n" +
|
||||
" \"concurrentNumber\": 1\n" +
|
||||
" \"ip\":\"192.168.20.17\",\n" +
|
||||
" \"port\": \"1194\",\n" +
|
||||
" \"monitor\": \"9100\",\n" +
|
||||
" \"concurrentNumber\": 100\n" +
|
||||
" }],\n" +
|
||||
"\"ip\":\"172.2.130.1\",\n" +
|
||||
"\"token\":\"dsdfssdsvgsd\",\n" +
|
||||
|
@ -76,10 +76,10 @@ class TestResourcePoolControllerTests extends BaseTest {
|
|||
" \"loadTestHeap\": \"123\",\n" +
|
||||
" \"nodesList\": [\n" +
|
||||
" {\n" +
|
||||
" \"ip\": \"172.2.130.1\",\n" +
|
||||
" \"port\": \"3306\",\n" +
|
||||
" \"monitor\": \"11\",\n" +
|
||||
" \"concurrentNumber\": 1\n" +
|
||||
" \"ip\": \"172.16.200.8\",\n" +
|
||||
" \"port\": \"8082\",\n" +
|
||||
" \"monitor\": \"9100\",\n" +
|
||||
" \"concurrentNumber\": 100\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"orgIds\": [\"sys_default_organization_2\",\"sys_default_organization_3\"],\n" +
|
||||
|
@ -533,7 +533,7 @@ class TestResourcePoolControllerTests extends BaseTest {
|
|||
mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/set/enable/"+id)
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(status().is5xxServerError())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue