fix(接口测试): 并发报告存储处理,执行前优先提交入库

This commit is contained in:
fit2-zhao 2021-12-01 15:32:06 +08:00 committed by BugKing
parent 614433e399
commit 34b90d2484
1 changed files with 17 additions and 10 deletions

View File

@ -1440,6 +1440,9 @@ public class ApiAutomationService {
* @param request * @param request
*/ */
private void parallel(Map<String, RunModeDataDTO> executeQueue, RunScenarioRequest request) { private void parallel(Map<String, RunModeDataDTO> executeQueue, RunScenarioRequest request) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class); ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
// 开始并发执行 // 开始并发执行
@ -1449,7 +1452,11 @@ public class ApiAutomationService {
batchMapper.insert(report); batchMapper.insert(report);
MessageCache.scenarioExecResourceLock.put(reportId, report); MessageCache.scenarioExecResourceLock.put(reportId, report);
} }
sqlSession.flushStatements(); sqlSession.commit();
sqlSession.clearCache();
}
});
thread.start();
for (String reportId : executeQueue.keySet()) { for (String reportId : executeQueue.keySet()) {
// 增加一个本地锁防止并发找不到资源 // 增加一个本地锁防止并发找不到资源