fix(接口测试): 并发报告存储处理,执行前优先提交入库
This commit is contained in:
parent
9eadbc68c1
commit
f1a08fcdc2
|
@ -1560,16 +1560,23 @@ public class ApiAutomationService {
|
|||
* @param request
|
||||
*/
|
||||
private void parallel(Map<String, RunModeDataDTO> executeQueue, RunScenarioRequest request) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
|
||||
// 开始并发执行
|
||||
for (String reportId : executeQueue.keySet()) {
|
||||
//存储报告
|
||||
APIScenarioReportResult report = executeQueue.get(reportId).getReport();
|
||||
batchMapper.insert(report);
|
||||
MessageCache.scenarioExecResourceLock.put(reportId, report);
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
|
||||
// 开始并发执行
|
||||
for (String reportId : executeQueue.keySet()) {
|
||||
//存储报告
|
||||
APIScenarioReportResult report = executeQueue.get(reportId).getReport();
|
||||
batchMapper.insert(report);
|
||||
MessageCache.scenarioExecResourceLock.put(reportId, report);
|
||||
}
|
||||
sqlSession.commit();
|
||||
sqlSession.clearCache();
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
for (String reportId : executeQueue.keySet()) {
|
||||
// 增加一个本地锁,防止并发找不到资源
|
||||
|
|
Loading…
Reference in New Issue