不让修改正在运行的测试

This commit is contained in:
Captain.B 2020-04-20 11:33:44 +08:00
parent 22be52a59c
commit 825183edd2
3 changed files with 19 additions and 19 deletions

View File

@ -93,8 +93,6 @@ public class PerformanceTestService {
loadTest.setProjectId(request.getProjectId());
loadTest.setCreateTime(System.currentTimeMillis());
loadTest.setUpdateTime(System.currentTimeMillis());
loadTest.setScenarioDefinition("todo");
loadTest.setDescription("todo");
loadTest.setTestResourcePoolId(request.getTestResourcePoolId());
loadTest.setLoadConfiguration(request.getLoadConfiguration());
loadTest.setAdvancedConfiguration(request.getAdvancedConfiguration());
@ -133,6 +131,14 @@ public class PerformanceTestService {
}
public String edit(EditTestPlanRequest request, List<MultipartFile> files) {
//
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId());
if (loadTest == null) {
MSException.throwException(Translator.get("edit_load_test_not_found") + request.getId());
}
if (StringUtils.containsAny(loadTest.getStatus(), PerformanceTestStatus.Running.name(), PerformanceTestStatus.Starting.name())) {
MSException.throwException(Translator.get("cannot_edit_load_test_running"));
}
// 新选择了一个文件删除原来的文件
List<FileMetadata> updatedFiles = request.getUpdatedFileList();
List<FileMetadata> originFiles = fileService.getFileMetadataByTestId(request.getId());
@ -152,22 +158,14 @@ public class PerformanceTestService {
});
}
final LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId());
if (loadTest == null) {
MSException.throwException(Translator.get("edit_load_test_not_found") + request.getId());
} else {
loadTest.setName(request.getName());
loadTest.setProjectId(request.getProjectId());
loadTest.setUpdateTime(System.currentTimeMillis());
loadTest.setScenarioDefinition("todo");
loadTest.setDescription("todo");
loadTest.setLoadConfiguration(request.getLoadConfiguration());
loadTest.setAdvancedConfiguration(request.getAdvancedConfiguration());
loadTest.setTestResourcePoolId(request.getTestResourcePoolId());
// todo 修改 load_test 的时候排除状态这里存在修改了 Running 的测试状态的风险
// loadTest.setStatus(PerformanceTestStatus.Saved.name());
loadTestMapper.updateByPrimaryKeySelective(loadTest);
}
loadTest.setName(request.getName());
loadTest.setProjectId(request.getProjectId());
loadTest.setUpdateTime(System.currentTimeMillis());
loadTest.setLoadConfiguration(request.getLoadConfiguration());
loadTest.setAdvancedConfiguration(request.getAdvancedConfiguration());
loadTest.setTestResourcePoolId(request.getTestResourcePoolId());
loadTest.setStatus(PerformanceTestStatus.Saved.name());
loadTestMapper.updateByPrimaryKeySelective(loadTest);
return request.getId();
}

View File

@ -19,3 +19,4 @@ duplicate_node_ip=Duplicate IPs
only_one_k8s=Only one K8s can be added
organization_id_is_null=Organization ID cannot be null
max_thread_insufficient=The number of concurrent users exceeds
cannot_edit_load_test_running=Cannot modify the running test

View File

@ -18,4 +18,5 @@ no_nodes_message=\u6CA1\u6709\u8282\u70B9\u4FE1\u606F
duplicate_node_ip=\u8282\u70B9 IP \u91CD\u590D
only_one_k8s=\u53EA\u80FD\u6DFB\u52A0\u4E00\u4E2A K8s
organization_id_is_null=\u7EC4\u7EC7 ID \u4E0D\u80FD\u4E3A\u7A7A
max_thread_insufficient=\u5E76\u53D1\u7528\u6237\u6570\u8D85\u989D
max_thread_insufficient=\u5E76\u53D1\u7528\u6237\u6570\u8D85\u989D
cannot_edit_load_test_running=不能修改正在运行的测试