mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-04 21:19:52 +08:00
fix(测试计划): 修复日志中对测试计划组或测试计划对应所属类型判断错误的问题
This commit is contained in:
parent
446f42062f
commit
4b218f2baf
@ -51,7 +51,9 @@ public class TestPlanExecuteController {
|
||||
@Log(type = OperationLogType.EXECUTE, expression = "#msClass.batchExecuteLog(#request)", msClass = TestPlanLogService.class)
|
||||
public void startExecute(@Validated @RequestBody TestPlanBatchExecuteRequest request) {
|
||||
testPlanManagementService.checkModuleIsOpen(request.getProjectId(), TestPlanResourceConfig.CHECK_TYPE_PROJECT, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
|
||||
testPlanExecuteService.batchExecuteTestPlan(request, SessionUtils.getUserId());
|
||||
Thread.startVirtualThread(() ->
|
||||
testPlanExecuteService.batchExecuteTestPlan(request, SessionUtils.getUserId())
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||
import io.metersphere.sdk.constants.ApiExecuteRunMode;
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.system.schedule.BaseScheduleJob;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobKey;
|
||||
@ -21,13 +22,14 @@ public class TestPlanScheduleJob extends BaseScheduleJob {
|
||||
assert testPlanExecuteService != null;
|
||||
Map<String, String> runConfig = JSON.parseObject(context.getJobDetail().getJobDataMap().get("config").toString(), Map.class);
|
||||
String runMode = runConfig.containsKey("runMode") ? runConfig.get("runMode") : ApiBatchRunMode.SERIAL.name();
|
||||
Thread.startVirtualThread(() -> {
|
||||
LogUtils.info("开始执行测试计划的定时任务. ID:" + resourceId);
|
||||
Thread.startVirtualThread(() ->
|
||||
testPlanExecuteService.singleExecuteTestPlan(new TestPlanExecuteRequest() {{
|
||||
this.setExecuteId(resourceId);
|
||||
this.setRunMode(runMode);
|
||||
this.setExecutionSource(ApiExecuteRunMode.SCHEDULE.name());
|
||||
}}, userId);
|
||||
});
|
||||
}}, userId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,10 +86,13 @@ public class TestPlanBatchOperationService extends TestPlanBaseUtilsService {
|
||||
|
||||
List<String> movePlanIds = new ArrayList<>();
|
||||
for (TestPlan testPlan : testPlanList) {
|
||||
// 已归档的测试计划无法操作
|
||||
if (StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
|
||||
throw new MSException(Translator.get("test_plan.is.archived"));
|
||||
}
|
||||
// 已归档的测试计划无法操作 测试计划组无法操作
|
||||
if (StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)
|
||||
|| StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP)) {
|
||||
continue;
|
||||
if (StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP)) {
|
||||
throw new MSException(Translator.get("test_plan.group.error"));
|
||||
}
|
||||
movePlanIds.add(testPlan.getId());
|
||||
}
|
||||
@ -195,6 +198,8 @@ public class TestPlanBatchOperationService extends TestPlanBaseUtilsService {
|
||||
testPlan.setModuleId(moduleId);
|
||||
testPlan.setGroupId(groupId);
|
||||
testPlan.setPos(pos);
|
||||
testPlan.setActualEndTime(null);
|
||||
testPlan.setActualStartTime(null);
|
||||
testPlan.setStatus(TestPlanConstants.TEST_PLAN_STATUS_PREPARED);
|
||||
testPlanMapper.insert(testPlan);
|
||||
|
||||
@ -282,6 +287,8 @@ public class TestPlanBatchOperationService extends TestPlanBaseUtilsService {
|
||||
testPlanGroup.setUpdateUser(operator);
|
||||
testPlanGroup.setUpdateTime(operatorTime);
|
||||
testPlanGroup.setModuleId(moduleId);
|
||||
testPlanGroup.setActualEndTime(null);
|
||||
testPlanGroup.setActualStartTime(null);
|
||||
testPlanGroup.setStatus(TestPlanConstants.TEST_PLAN_STATUS_PREPARED);
|
||||
testPlanMapper.insert(testPlanGroup);
|
||||
|
||||
|
@ -257,7 +257,7 @@ public class TestPlanLogService {
|
||||
}
|
||||
|
||||
private String getLogModule(TestPlan testPlan) {
|
||||
if (StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_TYPE_PLAN)) {
|
||||
if (StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN)) {
|
||||
return OperationLogModule.TEST_PLAN_TEST_PLAN;
|
||||
} else {
|
||||
return OperationLogModule.TEST_PLAN_TEST_PLAN_GROUP;
|
||||
|
@ -45,7 +45,6 @@ public class TestPlanExecuteTests extends BaseTest {
|
||||
private static TestPlan noGroupPlan;
|
||||
|
||||
private static final String URL_POST_TEST_PLAN_SINGLE_EXECUTE = "/test-plan-execute/single";
|
||||
private static final String URL_POST_TEST_PLAN_BATCH_EXECUTE = "/test-plan-execute/batch";
|
||||
|
||||
@Resource
|
||||
private CommonProjectService commonProjectService;
|
||||
@ -242,8 +241,7 @@ public class TestPlanExecuteTests extends BaseTest {
|
||||
batchExecuteRequest.setExecuteIds(execIds);
|
||||
batchExecuteRequest.setProjectId(project.getId());
|
||||
batchExecuteRequest.setRunMode(runMode);
|
||||
|
||||
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_EXECUTE, batchExecuteRequest);
|
||||
testPlanExecuteService.batchExecuteTestPlan(batchExecuteRequest, "admin");
|
||||
|
||||
//检查队列
|
||||
List<String> allQueueIds = new ArrayList<>();
|
||||
|
Loading…
Reference in New Issue
Block a user