diff --git a/backend/src/main/java/io/metersphere/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/service/PerformanceTestService.java index 850b1eafcf..ef3ce7006f 100644 --- a/backend/src/main/java/io/metersphere/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/service/PerformanceTestService.java @@ -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 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 updatedFiles = request.getUpdatedFileList(); List 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(); } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 634a2c073f..22315563d4 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -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 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 6a6daf57a4..bc77486217 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -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 \ No newline at end of file +max_thread_insufficient=\u5E76\u53D1\u7528\u6237\u6570\u8D85\u989D +cannot_edit_load_test_running=不能修改正在运行的测试 \ No newline at end of file