fix(接口测试): 接口用例串行批量执行失败

This commit is contained in:
AgAngle 2024-03-20 14:37:46 +08:00 committed by jianxing
parent cf3c49de16
commit df980ac47c
3 changed files with 6 additions and 7 deletions

View File

@ -1,7 +1,6 @@
package io.metersphere.api.service;
import io.metersphere.api.service.queue.ApiExecutionQueueService;
import io.metersphere.sdk.constants.ApiExecuteResourceType;
import io.metersphere.sdk.dto.api.task.ApiRunModeConfigDTO;
import io.metersphere.sdk.dto.queue.ExecutionQueue;
import io.metersphere.sdk.dto.queue.ExecutionQueueDetail;
@ -26,8 +25,8 @@ public class ApiBatchRunBaseService {
* @param runModeConfig
* @return
*/
public ExecutionQueue initExecutionqueue(List<String> resourceIds, ApiRunModeConfigDTO runModeConfig, String userId) {
ExecutionQueue queue = getExecutionQueue(runModeConfig, userId);
public ExecutionQueue initExecutionqueue(List<String> resourceIds, ApiRunModeConfigDTO runModeConfig, String resourceType, String userId) {
ExecutionQueue queue = getExecutionQueue(runModeConfig, resourceType, userId);
List<ExecutionQueueDetail> queueDetails = new ArrayList<>();
AtomicInteger sort = new AtomicInteger(1);
for (String resourceId : resourceIds) {
@ -40,11 +39,11 @@ public class ApiBatchRunBaseService {
return queue;
}
private ExecutionQueue getExecutionQueue(ApiRunModeConfigDTO runModeConfig, String userId) {
private ExecutionQueue getExecutionQueue(ApiRunModeConfigDTO runModeConfig, String resourceType, String userId) {
ExecutionQueue queue = new ExecutionQueue();
queue.setQueueId(UUID.randomUUID().toString());
queue.setRunModeConfig(runModeConfig);
queue.setResourceType(ApiExecuteResourceType.API_SCENARIO.name());
queue.setResourceType(resourceType);
queue.setCreateTime(System.currentTimeMillis());
queue.setUserId(userId);
return queue;

View File

@ -104,7 +104,7 @@ public class ApiTestCaseBatchRunService {
initIntegratedReport(runModeConfig, ids, userId, request.getProjectId());
}
// 先初始化集成报告设置好报告ID再初始化执行队列
ExecutionQueue queue = apiBatchRunBaseService.initExecutionqueue(ids, runModeConfig, userId);
ExecutionQueue queue = apiBatchRunBaseService.initExecutionqueue(ids, runModeConfig, ApiExecuteResourceType.API_CASE.name(), userId);
// 执行第一个任务
ExecutionQueueDetail nextDetail = apiExecutionQueueService.getNextDetail(queue.getQueueId());
executeNextTask(queue, nextDetail);

View File

@ -98,7 +98,7 @@ public class ApiScenarioBatchRunService {
initIntegratedReport(runModeConfig, ids, userId, request.getProjectId());
}
// 先初始化集成报告设置好报告ID再初始化执行队列
ExecutionQueue queue = apiBatchRunBaseService.initExecutionqueue(ids, runModeConfig, userId);
ExecutionQueue queue = apiBatchRunBaseService.initExecutionqueue(ids, runModeConfig, ApiExecuteResourceType.API_SCENARIO.name(), userId);
// 执行第一个任务
ExecutionQueueDetail nextDetail = apiExecutionQueueService.getNextDetail(queue.getQueueId());
executeNextTask(queue, nextDetail);