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

This commit is contained in:
fit2-zhao 2023-03-11 11:43:20 +08:00
parent 7426aa5d3d
commit fe5faf362c
1 changed files with 17 additions and 2 deletions

View File

@ -272,8 +272,23 @@ public class ApiExecutionQueueService {
} }
public void testPlanReportTestEnded(String testPlanReportId) { public void testPlanReportTestEnded(String testPlanReportId) {
// 检查测试计划中其他队列是否结束 ApiExecutionQueueExample executionQueueExample = new ApiExecutionQueueExample();
kafkaTemplate.send(KafkaTopicConstants.TEST_PLAN_REPORT_TOPIC, testPlanReportId); 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) { public void queueNext(ResultDTO dto) {