fix(接口测试): 修复集合报告无法停止问题

This commit is contained in:
fit2-zhao 2024-08-16 16:57:10 +08:00 committed by Craftsman
parent 6bffafb402
commit b26444f210
2 changed files with 12 additions and 7 deletions

View File

@ -166,7 +166,9 @@ public class ApiTestCaseBatchRunService {
} }
// 如果是集成报告则生成唯一的虚拟ID非集成报告使用单用例的报告ID // 如果是集成报告则生成唯一的虚拟ID非集成报告使用单用例的报告ID
String reportId = runModeConfig.isIntegratedReport() ? UUID.randomUUID().toString() : caseReportMap.get(id); String reportId = runModeConfig.isIntegratedReport()
? runModeConfig.getCollectionReport().getReportId() + IDGenerator.nextStr()
: caseReportMap.get(id);
TaskItem taskItem = apiExecuteService.getTaskItem(reportId, id); TaskItem taskItem = apiExecuteService.getTaskItem(reportId, id);
taskItem.setRequestCount(1L); taskItem.setRequestCount(1L);
@ -277,7 +279,7 @@ public class ApiTestCaseBatchRunService {
String reportId; String reportId;
if (runModeConfig.isIntegratedReport()) { if (runModeConfig.isIntegratedReport()) {
reportId = IDGenerator.nextStr(); reportId = runModeConfig.getCollectionReport().getReportId() + IDGenerator.nextStr();
} else { } else {
// 独立报告执行到当前任务时初始化报告 // 独立报告执行到当前任务时初始化报告
reportId = initApiReport(runModeConfig, List.of(apiTestCase), queue.getUserId()).getFirst().getApiReportId(); reportId = initApiReport(runModeConfig, List.of(apiTestCase), queue.getUserId()).getFirst().getApiReportId();

View File

@ -137,10 +137,13 @@ public class ApiScenarioBatchRunService {
setRunningIntegrateReport(runModeConfig); setRunningIntegrateReport(runModeConfig);
List<TaskItem> taskItems = ids.stream() List<TaskItem> taskItems = ids.stream()
.map(id -> { .map(id -> apiExecuteService.getTaskItem(
String reportId = runModeConfig.isIntegratedReport() ? IDGenerator.nextStr() : scenarioReportMap.get(id); runModeConfig.isIntegratedReport()
return apiExecuteService.getTaskItem(reportId, id); ? runModeConfig.getCollectionReport().getReportId() + IDGenerator.nextStr()
}).toList(); : scenarioReportMap.get(id), id
))
.toList();
TaskBatchRequestDTO taskRequest = getTaskBatchRequestDTO(request.getProjectId(), runModeConfig); TaskBatchRequestDTO taskRequest = getTaskBatchRequestDTO(request.getProjectId(), runModeConfig);
taskRequest.setTaskItems(taskItems); taskRequest.setTaskItems(taskItems);
taskRequest.getTaskInfo().setUserId(userId); taskRequest.getTaskInfo().setUserId(userId);
@ -259,7 +262,7 @@ public class ApiScenarioBatchRunService {
String reportId; String reportId;
if (runModeConfig.isIntegratedReport()) { if (runModeConfig.isIntegratedReport()) {
reportId = IDGenerator.nextStr(); reportId = runModeConfig.getCollectionReport().getReportId() + IDGenerator.nextStr();
} else { } else {
// 独立报告执行到当前任务时初始化报告 // 独立报告执行到当前任务时初始化报告
reportId = initScenarioReport(runModeConfig, apiScenario, queue.getUserId()).getApiScenarioReportId(); reportId = initScenarioReport(runModeConfig, apiScenario, queue.getUserId()).getApiScenarioReportId();