fix(测试跟踪): 修复测试计划异常执行时会清空用户session的问题

修复测试计划异常执行时会清空用户session的问题
This commit is contained in:
song-tianyang 2023-04-23 18:01:59 +08:00 committed by 刘瑞斌
parent a2ff72234d
commit 888b236bee
2 changed files with 11 additions and 11 deletions

View File

@ -47,6 +47,7 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils; import org.mybatis.spring.SqlSessionUtils;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -570,6 +571,12 @@ public class TestPlanReportService {
return false; return false;
} }
@Async
void syncFinishTestPlanExecute(String planReportId) {
this.testPlanExecuteOver(planReportId, TestPlanReportStatus.COMPLETED.name());
}
public void testPlanExecuteOver(String testPlanReportId, String finishStatus) { public void testPlanExecuteOver(String testPlanReportId, String finishStatus) {
TestPlanReport testPlanReport = this.getTestPlanReport(testPlanReportId); TestPlanReport testPlanReport = this.getTestPlanReport(testPlanReportId);
if (this.isTestPlanCountOver(testPlanReport)) { if (this.isTestPlanCountOver(testPlanReport)) {

View File

@ -70,7 +70,6 @@ import org.mybatis.spring.SqlSessionUtils;
import org.quartz.*; import org.quartz.*;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -1059,20 +1058,14 @@ public class TestPlanService {
LoggerUtil.info("开始生成测试计划报告内容 " + planReportId); LoggerUtil.info("开始生成测试计划报告内容 " + planReportId);
testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiTestCases, scenarioCases, uiScenarios, loadCaseReportMap); testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiTestCases, scenarioCases, uiScenarios, loadCaseReportMap);
if (!haveApiCaseExec && !haveScenarioCaseExec && !haveLoadCaseExec && !haveUICaseExec) { if (!haveApiCaseExec && !haveScenarioCaseExec && !haveLoadCaseExec && !haveUICaseExec) {
/** // 如果没有执行自动化用例结束测试计划的执行
*如果没有执行自动化用例结束测试计划的执行 // 使用异步操作的方式是为了更早的将执行信息回馈给前台
* 使用异步操作的方式是为了更早的将执行信息回馈给前台 // 不为前台直接返回无法执行的报错是考虑到测试计划内会有功能用例issue等信息可以进行统计
* 不为前台直接返回无法执行的报错是考虑到测试计划内会有功能用例issue等信息可以进行统计 testPlanReportService.syncFinishTestPlanExecute(planReportId);
*/
this.syncFinishTestPlanExecute(planReportId);
} }
return planReportId; return planReportId;
} }
@Async
void syncFinishTestPlanExecute(String planReportId) {
testPlanReportService.testPlanExecuteOver(planReportId, TestPlanReportStatus.COMPLETED.name());
}
public void verifyPool(String projectId, RunModeConfigDTO runConfig) { public void verifyPool(String projectId, RunModeConfigDTO runConfig) {
// 检查是否禁用了本地执行 // 检查是否禁用了本地执行