refactor(接口测试): 优化测试计划消费阻塞问题

This commit is contained in:
fit2-zhao 2023-03-11 11:43:20 +08:00
parent 7426aa5d3d
commit fe5faf362c

View File

@ -272,9 +272,24 @@ public class ApiExecutionQueueService {
}
public void testPlanReportTestEnded(String testPlanReportId) {
ApiExecutionQueueExample executionQueueExample = new ApiExecutionQueueExample();
executionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
List<ApiExecutionQueue> queues = queueMapper.selectByExample(executionQueueExample);
if (org.springframework.util.CollectionUtils.isEmpty(queues)) {
LoggerUtil.info("测试计划执行结束开始发送通知:" + testPlanReportId);
kafkaTemplate.send(KafkaTopicConstants.TEST_PLAN_REPORT_TOPIC, testPlanReportId);
} else {
List<String> ids = queues.stream().map(ApiExecutionQueue::getId).collect(Collectors.toList());
ApiExecutionQueueDetailExample detailExample = new ApiExecutionQueueDetailExample();
detailExample.createCriteria().andQueueIdIn(ids);
long count = executionQueueDetailMapper.countByExample(detailExample);
if (count == 0) {
LoggerUtil.info("测试计划执行结束开始发送通知:" + testPlanReportId);
// 检查测试计划中其他队列是否结束
kafkaTemplate.send(KafkaTopicConstants.TEST_PLAN_REPORT_TOPIC, testPlanReportId);
}
}
}
public void queueNext(ResultDTO dto) {
LoggerUtil.info("开始处理队列:" + dto.getReportId() + "QID" + dto.getQueueId());