feat(测试计划): 测试计划批量执行方法开发
This commit is contained in:
parent
791432f490
commit
fde8326fd2
|
@ -17,7 +17,6 @@ public class TestPlanExecutionQueue {
|
|||
private String runMode;
|
||||
//执行来源
|
||||
private String executionSource;
|
||||
//预生成的报告ID (不一定会用到)
|
||||
private String prepareReportId;
|
||||
private String createUser;
|
||||
private long createTime;
|
||||
|
|
|
@ -533,7 +533,7 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
|||
|
||||
//开启用例重复的测试计划,再次调用
|
||||
testPlanConfig.setRepeatCase(true);
|
||||
testPlanConfigMapper.updateByPrimaryKey(testPlanConfig);
|
||||
testPlanConfigMapper.updateByPrimaryKeySelective(testPlanConfig);
|
||||
|
||||
mvcResult = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_MODULE_COUNT, request);
|
||||
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
|
|
|
@ -39,9 +39,9 @@ public class TestPlanExecuteController {
|
|||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE)
|
||||
@CheckOwner(resourceId = "#request.getExecuteId()", resourceType = "test_plan")
|
||||
@Log(type = OperationLogType.EXECUTE, expression = "#msClass.executeLog(#request)", msClass = TestPlanLogService.class)
|
||||
public void startExecute(@Validated @RequestBody TestPlanExecuteRequest request) {
|
||||
public String startExecute(@Validated @RequestBody TestPlanExecuteRequest request) {
|
||||
testPlanManagementService.checkModuleIsOpen(request.getExecuteId(), TestPlanResourceConfig.CONFIG_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
|
||||
testPlanExecuteService.singleExecuteTestPlan(request, SessionUtils.getUserId());
|
||||
return testPlanExecuteService.singleExecuteTestPlan(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/batch")
|
||||
|
|
|
@ -56,5 +56,5 @@ public interface ExtTestPlanApiCaseMapper {
|
|||
|
||||
List<ModuleCountDTO> collectionCountByRequest(@Param("testPlanId") String testPlanId);
|
||||
|
||||
Long getMaxPosByCollectionId(@Param("collectionId") String collectionId);
|
||||
Long getMaxPosByCollectionId(String collectionId);
|
||||
}
|
||||
|
|
|
@ -662,6 +662,6 @@
|
|||
<select id="getMaxPosByCollectionId" resultType="java.lang.Long">
|
||||
SELECT max(pos)
|
||||
FROM test_plan_api_case
|
||||
WHERE test_plan_collection_id = #{collectionId}
|
||||
WHERE test_plan_collection_id = #{0}
|
||||
</select>
|
||||
</mapper>
|
|
@ -15,7 +15,7 @@ public interface ExtTestPlanApiScenarioMapper {
|
|||
|
||||
List<String> selectIdByTestPlanIdOrderByPos(String testPlanId);
|
||||
|
||||
Long getMaxPosByRangeId(String testPlanId);
|
||||
Long getMaxPosByRangeId(String rangeId);
|
||||
|
||||
List<String> getIdByParam(ResourceSelectParam resourceSelectParam);
|
||||
|
||||
|
|
|
@ -59,5 +59,5 @@ public interface ExtTestPlanFunctionalCaseMapper {
|
|||
|
||||
List<TestPlanCaseRunResultCount> selectCaseExecResultCount(String testPlanId);
|
||||
|
||||
Long getMaxPosByCollectionId(@Param("collectionId") String collectionId);
|
||||
Long getMaxPosByCollectionId(String collectionId);
|
||||
}
|
||||
|
|
|
@ -541,7 +541,7 @@
|
|||
<select id="getMaxPosByCollectionId" resultType="java.lang.Long">
|
||||
SELECT max(pos)
|
||||
FROM test_plan_functional_case
|
||||
WHERE test_plan_collection_id = #{collectionId}
|
||||
WHERE test_plan_collection_id = #{0}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -13,11 +13,7 @@ import io.metersphere.functional.dto.ProjectOptionDTO;
|
|||
import io.metersphere.plan.constants.AssociateCaseType;
|
||||
import io.metersphere.plan.constants.TreeTypeEnums;
|
||||
import io.metersphere.plan.domain.*;
|
||||
import io.metersphere.plan.dto.ApiCaseModuleDTO;
|
||||
import io.metersphere.plan.dto.ResourceLogInsertModule;
|
||||
import io.metersphere.plan.dto.TestPlanCaseRunResultCount;
|
||||
import io.metersphere.plan.dto.TestPlanCollectionDTO;
|
||||
import io.metersphere.plan.dto.TestPlanResourceAssociationParam;
|
||||
import io.metersphere.plan.dto.*;
|
||||
import io.metersphere.plan.dto.request.*;
|
||||
import io.metersphere.plan.dto.response.TestPlanApiCasePageResponse;
|
||||
import io.metersphere.plan.dto.response.TestPlanAssociationResponse;
|
||||
|
@ -549,7 +545,6 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
|||
|
||||
public TestPlanOperationResponse sortNode(ResourceSortRequest request, LogInsertModule logInsertModule) {
|
||||
TestPlanApiCase dragNode = testPlanApiCaseMapper.selectByPrimaryKey(request.getMoveId());
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestCollectionId());
|
||||
if (dragNode == null) {
|
||||
throw new MSException(Translator.get("test_plan.drag.node.error"));
|
||||
}
|
||||
|
@ -562,6 +557,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
|||
);
|
||||
super.sort(sortDTO);
|
||||
response.setOperationCount(1);
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(dragNode.getTestPlanId());
|
||||
testPlanResourceLogService.saveSortLog(testPlan, request.getMoveId(), new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_API_CASE, logInsertModule));
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,6 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
|
|||
}
|
||||
public TestPlanOperationResponse sortNode(ResourceSortRequest request, LogInsertModule logInsertModule) {
|
||||
TestPlanApiScenario dragNode = testPlanApiScenarioMapper.selectByPrimaryKey(request.getMoveId());
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestCollectionId());
|
||||
if (dragNode == null) {
|
||||
throw new MSException(Translator.get("test_plan.drag.node.error"));
|
||||
}
|
||||
|
@ -164,6 +163,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
|
|||
);
|
||||
super.sort(sortDTO);
|
||||
response.setOperationCount(1);
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(dragNode.getTestPlanId());
|
||||
testPlanResourceLogService.saveSortLog(testPlan, request.getMoveId(), new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_API_CASE, logInsertModule));
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -38,14 +38,16 @@ public class TestPlanExecuteService {
|
|||
public static final String QUEUE_PREFIX_TEST_PLAN_GROUP = "test-plan-group-execute:";
|
||||
public static final String QUEUE_PREFIX_TEST_COLLECTION = "test-collection-execute:";
|
||||
|
||||
public void executeTestPlan(TestPlan testPlan, String executionSource, String userId) {
|
||||
public String executeTestPlan(TestPlan testPlan, String executionSource, String userId) {
|
||||
//todo 查询执行配置,配置下一步的队列
|
||||
|
||||
return "报告ID";
|
||||
}
|
||||
|
||||
/**
|
||||
* 预执行执行测试计划
|
||||
*/
|
||||
private void prepareExecuteTestPlan(TestPlan testPlan, String parentQueueId, String runMode, String executionSource, String userId) {
|
||||
private String prepareExecuteTestPlan(TestPlan testPlan, String parentQueueId, String runMode, String executionSource, String userId) {
|
||||
if (testPlan == null || StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
|
||||
throw new MSException("test_plan.error");
|
||||
}
|
||||
|
@ -72,16 +74,17 @@ public class TestPlanExecuteService {
|
|||
executeTestPlan(testPlanMapper.selectByPrimaryKey(childQueue.getTestPlanId()), childQueue.getExecutionSource(), childQueue.getCreateUser());
|
||||
});
|
||||
}
|
||||
return "";
|
||||
} else {
|
||||
this.executeTestPlan(testPlan, executionSource, userId);
|
||||
return this.executeTestPlan(testPlan, executionSource, userId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个执行测试计划
|
||||
*/
|
||||
public void singleExecuteTestPlan(TestPlanExecuteRequest request, String userId) {
|
||||
prepareExecuteTestPlan(testPlanMapper.selectByPrimaryKey(request.getExecuteId()), null, request.getRunMode(), request.getExecutionSource(), userId);
|
||||
public String singleExecuteTestPlan(TestPlanExecuteRequest request, String userId) {
|
||||
return prepareExecuteTestPlan(testPlanMapper.selectByPrimaryKey(request.getExecuteId()), null, request.getRunMode(), request.getExecutionSource(), userId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -200,7 +200,6 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
|
||||
public TestPlanOperationResponse sortNode(ResourceSortRequest request, LogInsertModule logInsertModule) {
|
||||
TestPlanFunctionalCase dragNode = testPlanFunctionalCaseMapper.selectByPrimaryKey(request.getMoveId());
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestCollectionId());
|
||||
if (dragNode == null) {
|
||||
throw new MSException(Translator.get("test_plan.drag.node.error"));
|
||||
}
|
||||
|
@ -213,6 +212,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
);
|
||||
super.sort(sortDTO);
|
||||
response.setOperationCount(1);
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(dragNode.getTestPlanId());
|
||||
testPlanResourceLogService.saveSortLog(testPlan, request.getMoveId(), new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_FUNCTIONAL_CASE, logInsertModule));
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ VALUES
|
|||
|
||||
|
||||
INSERT INTO `test_plan_config`(`test_plan_id`, `automatic_status_update`, `repeat_case`, `pass_threshold`,
|
||||
'case_run_mode')
|
||||
`case_run_mode`)
|
||||
VALUES ('wxx_1', b'0', b'0', 100, 'PARALLEL'),
|
||||
('wxx_2', b'0', b'0', 100, 'PARALLEL');
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ INSERT INTO `test_plan`(`id`, `num`, `project_id`, `group_id`, `module_id`, `nam
|
|||
('plan_id_for_gen_report', 100001, '100001100001', 'NONE', '1', 'gen-report-plan', 'PREPARED', 'TEST_PLAN', NULL, CURRENT_TIMESTAMP, 'admin', CURRENT_TIMESTAMP, 'admin', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '11'),
|
||||
('plan_id_for_gen_report_1', 100001, '100001100001', 'NONE', '1', 'gen-report-plan-1', 'PREPARED', 'TEST_PLAN', NULL, CURRENT_TIMESTAMP, 'admin', CURRENT_TIMESTAMP, 'admin', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '11');
|
||||
INSERT INTO `test_plan_config`(`test_plan_id`, `automatic_status_update`, `repeat_case`, `pass_threshold`,
|
||||
'case_run_mode')
|
||||
`case_run_mode`)
|
||||
VALUES ('plan_id_for_gen_report', b'0', b'0', 100.00, 'PARALLEL'),
|
||||
('plan_id_for_gen_report_1', b'0', b'0', 0.00, 'PARALLEL');
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ VALUES ('1', 'songtianyang-fix-wx', 'wx_测试模块名称', 'ROOT', 1, 17149801
|
|||
|
||||
|
||||
INSERT INTO `test_plan_config`(`test_plan_id`, `automatic_status_update`, `repeat_case`, `pass_threshold`,
|
||||
'case_run_mode')
|
||||
`case_run_mode`)
|
||||
VALUES ('wx_test_plan_id_1', b'0', b'0', 100, 'PARALLEL'),
|
||||
('wx_test_plan_id_4', b'0', b'0', 100, 'PARALLEL'),
|
||||
('wx_test_plan_id_7', b'0', b'0', 100, 'PARALLEL');
|
||||
|
|
Loading…
Reference in New Issue