refactor(接口测试): 调整验证方法

This commit is contained in:
fit2-zhao 2024-10-15 14:07:22 +08:00 committed by Craftsman
parent d4ff0d46b6
commit 61d58d8ce7
1 changed files with 7 additions and 1 deletions

View File

@ -241,6 +241,9 @@ public class ApiExecuteService {
EngineFactory.runApi(taskRequest, testResourceDTO); EngineFactory.runApi(taskRequest, testResourceDTO);
} }
} else { } else {
if (CollectionUtils.isEmpty(testResourcePoolDTO.getTestResourceReturnDTO().getNodesList())) {
throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG);
}
TestResourceNodeDTO testResourceNodeDTO = getNextExecuteNode(testResourcePoolDTO); TestResourceNodeDTO testResourceNodeDTO = getNextExecuteNode(testResourcePoolDTO);
if (!ApiExecuteRunMode.isDebug(taskInfo.getRunMode())) { if (!ApiExecuteRunMode.isDebug(taskInfo.getRunMode())) {
updateTaskItemNodeInfo(taskItem, testResourcePoolDTO, testResourceNodeDTO, execTaskItemMapper); updateTaskItemNodeInfo(taskItem, testResourcePoolDTO, testResourceNodeDTO, execTaskItemMapper);
@ -320,6 +323,9 @@ public class ApiExecuteService {
} else { } else {
// 将任务按资源池的数量拆分 // 将任务按资源池的数量拆分
List<TestResourceNodeDTO> nodesList = testResourcePool.getTestResourceReturnDTO().getNodesList(); List<TestResourceNodeDTO> nodesList = testResourcePool.getTestResourceReturnDTO().getNodesList();
if (CollectionUtils.isEmpty(nodesList)) {
throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG);
}
List<TaskBatchRequestDTO> distributeTasks = new ArrayList<>(nodesList.size()); List<TaskBatchRequestDTO> distributeTasks = new ArrayList<>(nodesList.size());
for (int i = 0; i < taskRequest.getTaskItems().size(); i++) { for (int i = 0; i < taskRequest.getTaskItems().size(); i++) {
TaskBatchRequestDTO distributeTask; TaskBatchRequestDTO distributeTask;
@ -412,7 +418,7 @@ public class ApiExecuteService {
} }
TestResourcePoolReturnDTO resourcePool = getAvailableResourcePoolDTO(projectId, poolId); TestResourcePoolReturnDTO resourcePool = getAvailableResourcePoolDTO(projectId, poolId);
if (resourcePool == null || CollectionUtils.isEmpty(resourcePool.getTestResourceReturnDTO().getNodesList())) { if (resourcePool == null) {
throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG); throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG);
} }
return resourcePool; return resourcePool;