From 7331d2c85f03ea1f8022cd88949e8df617d0dd8e Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 29 Oct 2024 17:06:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=B1=A0=E4=B8=8B=E6=8B=89=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1048305 --user=王旭 【任务中心】详情列表-资源池下拉k8s无节点选项 https://www.tapd.cn/55049933/s/1600825 --- .../dto/taskhub/ResourcePoolOptionsDTO.java | 2 + .../plan/service/TestPlanExecuteService.java | 50 +++++++++---------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/ResourcePoolOptionsDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/ResourcePoolOptionsDTO.java index 2b35ec1da9..65c63a63b1 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/ResourcePoolOptionsDTO.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/ResourcePoolOptionsDTO.java @@ -1,5 +1,6 @@ package io.metersphere.system.dto.taskhub; +import com.fasterxml.jackson.annotation.JsonInclude; import io.metersphere.system.dto.sdk.OptionDTO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -13,6 +14,7 @@ import java.util.List; */ @Data @EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_EMPTY) public class ResourcePoolOptionsDTO extends OptionDTO { @Schema(description = "资源池节点") diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java index 26ce6715a8..07aa9145df 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java @@ -155,27 +155,27 @@ public class TestPlanExecuteService { */ @Transactional(rollbackFor = Exception.class, propagation = Propagation.NOT_SUPPORTED) public String singleExecuteTestPlan(TestPlanExecuteRequest request, String reportId, String userId) { - String queueId = IDGenerator.nextStr(); - TestPlanExecutionQueue singleExecuteRootQueue = new TestPlanExecutionQueue( - 0, - userId, - System.currentTimeMillis(), - queueId, - QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE, - null, - null, - request.getExecuteId(), - request.getRunMode(), - request.getExecutionSource(), - reportId, - IDGenerator.nextStr() - ); + String queueId = IDGenerator.nextStr(); + TestPlanExecutionQueue singleExecuteRootQueue = new TestPlanExecutionQueue( + 0, + userId, + System.currentTimeMillis(), + queueId, + QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE, + null, + null, + request.getExecuteId(), + request.getRunMode(), + request.getExecutionSource(), + reportId, + IDGenerator.nextStr() + ); - testPlanExecuteSupportService.setRedisForList( - testPlanExecuteSupportService.genQueueKey(queueId, QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE), List.of(JSON.toJSONString(singleExecuteRootQueue))); - TestPlanExecutionQueue nextQueue = testPlanExecuteSupportService.getNextQueue(queueId, QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE); - LogUtils.info("测试计划(组)的单独执行start!计划报告[{}] , 资源ID[{}]", singleExecuteRootQueue.getPrepareReportId(), singleExecuteRootQueue.getSourceID()); - executeTestPlanOrGroup(nextQueue); + testPlanExecuteSupportService.setRedisForList( + testPlanExecuteSupportService.genQueueKey(queueId, QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE), List.of(JSON.toJSONString(singleExecuteRootQueue))); + TestPlanExecutionQueue nextQueue = testPlanExecuteSupportService.getNextQueue(queueId, QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE); + LogUtils.info("测试计划(组)的单独执行start!计划报告[{}] , 资源ID[{}]", singleExecuteRootQueue.getPrepareReportId(), singleExecuteRootQueue.getSourceID()); + executeTestPlanOrGroup(nextQueue); return reportId; } @@ -253,7 +253,7 @@ public class TestPlanExecuteService { extTestPlanApiScenarioMapper.countByPlanIds(childPlanIds); } // 初始化任务 - ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan.getName(), project, executionQueue.getCreateUser(), executionQueue.getExecutionSource(), executionQueue.getPrepareReportId()); + ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan, project, executionQueue.getCreateUser(), executionQueue.getExecutionSource(), executionQueue.getPrepareReportId()); // 预生成计划组报告 Map reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), execTask.getId(), genReportRequest, executionQueue.getCreateUser()); @@ -309,7 +309,7 @@ public class TestPlanExecuteService { Integer caseTotal = extTestPlanApiCaseMapper.countByPlanIds(List.of(testPlan.getId())) + extTestPlanApiScenarioMapper.countByPlanIds(List.of(testPlan.getId())); // 初始化任务 - ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan.getName(), project, executionQueue.getCreateUser(), executionQueue.getExecutionSource(), executionQueue.getPrepareReportId()); + ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan, project, executionQueue.getCreateUser(), executionQueue.getExecutionSource(), executionQueue.getPrepareReportId()); Map reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), execTask.getId(), genReportRequest, executionQueue.getCreateUser()); executionQueue.setPrepareReportId(reportMap.get(executionQueue.getSourceID())); @@ -319,14 +319,14 @@ public class TestPlanExecuteService { } } - private ExecTask initExecTask(String taskId, int caseSize, String name, Project project, String userId, String triggerMode, String reportId) { + private ExecTask initExecTask(String taskId, int caseSize, TestPlan testPlan, Project project, String userId, String triggerMode, String reportId) { ExecTask execTask = apiCommonService.newExecTask(project.getId(), userId); execTask.setId(taskId); execTask.setCaseCount(Long.valueOf(caseSize)); - execTask.setTaskName(name); + execTask.setTaskName(testPlan.getName()); execTask.setOrganizationId(project.getOrganizationId()); execTask.setTriggerMode(triggerMode); - execTask.setTaskType(ExecTaskType.TEST_PLAN.name()); + execTask.setTaskType(StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN) ? ExecTaskType.TEST_PLAN.name() : ExecTaskType.TEST_PLAN_GROUP.name()); baseTaskHubService.insertExecTask(execTask); // 创建报告和任务的关联关系