refactor(测试计划): 优化测试计划单独执行的方法

This commit is contained in:
Jianguo-Genius 2024-07-09 18:16:29 +08:00 committed by 建国
parent 59ee108a09
commit 6ebb9148e5
2 changed files with 25 additions and 19 deletions

View File

@ -127,26 +127,30 @@ public class TestPlanExecuteService {
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NOT_SUPPORTED)
public String singleExecuteTestPlan(TestPlanExecuteRequest request, 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(),
IDGenerator.nextStr()
);
String reportId = IDGenerator.nextStr();
Thread.startVirtualThread(() -> {
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
);
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());
return 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;
}
/**

View File

@ -282,6 +282,8 @@ public class TestPlanExecuteTests extends BaseTest {
this.requestPostWithOk(URL_POST_TEST_PLAN_SINGLE_EXECUTE, executeRequest);
Thread.sleep(1000);
//检查队列
List<String> allQueueIds = new ArrayList<>();
List<String> collectionQueueIdList = new ArrayList<>();