fix(数据库连接池): 修复数据库连接池在大压力下容易出现获取不到的问题
修复数据库连接池在大压力下容易出现获取不到的问题
This commit is contained in:
parent
74f3fb00ea
commit
c56955e475
|
@ -68,6 +68,7 @@ import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
import org.apache.jorphan.collections.ListedHashTree;
|
import org.apache.jorphan.collections.ListedHashTree;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -1468,8 +1469,12 @@ public class ApiAutomationService {
|
||||||
report.setStatus(APITestStatus.Waiting.name());
|
report.setStatus(APITestStatus.Waiting.name());
|
||||||
batchMapper.insert(report);
|
batchMapper.insert(report);
|
||||||
}
|
}
|
||||||
sqlSession.commit();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开始串行执行
|
// 开始串行执行
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1572,8 +1577,10 @@ public class ApiAutomationService {
|
||||||
batchMapper.insert(report);
|
batchMapper.insert(report);
|
||||||
MessageCache.scenarioExecResourceLock.put(reportId, report);
|
MessageCache.scenarioExecResourceLock.put(reportId, report);
|
||||||
}
|
}
|
||||||
sqlSession.commit();
|
sqlSession.flushStatements();
|
||||||
sqlSession.clearCache();
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
@ -1595,7 +1602,6 @@ public class ApiAutomationService {
|
||||||
TriggerMode.BATCH.name().equals(request.getTriggerMode()) ? TriggerMode.BATCH.name() : request.getReportId(), request.getRunMode());
|
TriggerMode.BATCH.name().equals(request.getTriggerMode()) ? TriggerMode.BATCH.name() : request.getReportId(), request.getRunMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
executeQueue.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1705,6 +1711,9 @@ public class ApiAutomationService {
|
||||||
}
|
}
|
||||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
MSException.throwException(ex.getMessage());
|
MSException.throwException(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -1979,6 +1988,9 @@ public class ApiAutomationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2318,6 +2330,9 @@ public class ApiAutomationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long getImportNextOrder(String projectId) {
|
private Long getImportNextOrder(String projectId) {
|
||||||
|
|
|
@ -59,6 +59,7 @@ import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -1145,6 +1146,9 @@ public class ApiDefinitionService {
|
||||||
if (!CollectionUtils.isEmpty(apiImport.getCases())) {
|
if (!CollectionUtils.isEmpty(apiImport.getCases())) {
|
||||||
importMsCase(apiImport, sqlSession, request);
|
importMsCase(apiImport, sqlSession, request);
|
||||||
}
|
}
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -102,11 +103,19 @@ public class ApiEnvironmentRunningParamService {
|
||||||
sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE);
|
sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE);
|
||||||
ApiTestEnvironmentMapper batchMapper = sqlSession.getMapper(ApiTestEnvironmentMapper.class);
|
ApiTestEnvironmentMapper batchMapper = sqlSession.getMapper(ApiTestEnvironmentMapper.class);
|
||||||
batchMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironmentWithBLOBs);
|
batchMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironmentWithBLOBs);
|
||||||
sqlSession.commit();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
sqlSession.rollback();
|
sqlSession.rollback();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}finally {
|
}finally {
|
||||||
sqlSession.close();
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -353,6 +354,9 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
apiDefinitionMapper.updateByPrimaryKeySelective(value);
|
apiDefinitionMapper.updateByPrimaryKeySelective(value);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -432,6 +436,9 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
apiModuleMapper.updateByPrimaryKeySelective(value);
|
apiModuleMapper.updateByPrimaryKeySelective(value);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiModule getModuleByName(String projectId, String protocol) {
|
public ApiModule getModuleByName(String projectId, String protocol) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -289,6 +290,9 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
ApiScenarioMapper apiScenarioMapper = sqlSession.getMapper(ApiScenarioMapper.class);
|
ApiScenarioMapper apiScenarioMapper = sqlSession.getMapper(ApiScenarioMapper.class);
|
||||||
apiScenarios.forEach(apiScenarioMapper::updateByPrimaryKeySelective);
|
apiScenarios.forEach(apiScenarioMapper::updateByPrimaryKeySelective);
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -395,6 +399,9 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
ApiScenarioModuleMapper apiScenarioModuleMapper = sqlSession.getMapper(ApiScenarioModuleMapper.class);
|
ApiScenarioModuleMapper apiScenarioModuleMapper = sqlSession.getMapper(ApiScenarioModuleMapper.class);
|
||||||
updateNodes.forEach(apiScenarioModuleMapper::updateByPrimaryKeySelective);
|
updateNodes.forEach(apiScenarioModuleMapper::updateByPrimaryKeySelective);
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLogDetails(List<String> ids) {
|
public String getLogDetails(List<String> ids) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -159,6 +160,7 @@ public class ApiScenarioReportService {
|
||||||
if (report == null) {
|
if (report == null) {
|
||||||
LogUtil.info("从缓存中获取场景报告:【" + test.getName() + "】");
|
LogUtil.info("从缓存中获取场景报告:【" + test.getName() + "】");
|
||||||
report = MessageCache.scenarioExecResourceLock.get(test.getName());
|
report = MessageCache.scenarioExecResourceLock.get(test.getName());
|
||||||
|
LogUtil.info("从缓存中获取场景报告:【" + test.getName() + "】是否为空:" + (report == null));
|
||||||
}
|
}
|
||||||
if (report != null) {
|
if (report != null) {
|
||||||
report.setName(report.getScenarioName() + "-" + DateUtils.getTimeStr(System.currentTimeMillis()));
|
report.setName(report.getScenarioName() + "-" + DateUtils.getTimeStr(System.currentTimeMillis()));
|
||||||
|
@ -322,88 +324,86 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
ApiScenarioReport report = editReport(scenarioResult, startTime);
|
ApiScenarioReport report = editReport(scenarioResult, startTime);
|
||||||
|
|
||||||
TestResult newResult = createTestResult(result.getTestId(), scenarioResult);
|
if(report != null){
|
||||||
newResult.setConsole(result.getConsole());
|
TestResult newResult = createTestResult(result.getTestId(), scenarioResult);
|
||||||
scenarioResult.setName(report.getScenarioName());
|
newResult.setConsole(result.getConsole());
|
||||||
newResult.addScenario(scenarioResult);
|
scenarioResult.setName(report.getScenarioName());
|
||||||
/**
|
|
||||||
* 测试计划的定时任务场景执行时,主键是提前生成的【测试报告ID】。也就是TestResult.id是【测试报告ID】。
|
|
||||||
* report.getScenarioId中存放的是 TestPlanApiScenario.id:TestPlanReport.id 由于参数限制,只得将两个ID拼接起来
|
|
||||||
* 拆分report.getScenarioId, 查出ScenarioId,将真正的场景ID赋值回去
|
|
||||||
* 同时将testPlanReportID存入集合,逻辑走完后更新TestPlanReport
|
|
||||||
*/
|
|
||||||
String[] idArr = report.getScenarioId().split(":");
|
|
||||||
String planScenarioId = null;
|
|
||||||
if (idArr.length > 1) {
|
|
||||||
planScenarioId = idArr[0];
|
|
||||||
String planReportID = idArr[1];
|
|
||||||
if (!testPlanReportIdList.contains(planReportID)) {
|
|
||||||
testPlanReportIdList.add(planReportID);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
planScenarioId = report.getScenarioId();
|
|
||||||
}
|
|
||||||
TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(planScenarioId);
|
|
||||||
report.setScenarioId(testPlanApiScenario.getApiScenarioId());
|
|
||||||
report.setTestPlanScenarioId(planScenarioId);
|
|
||||||
report.setEndTime(System.currentTimeMillis());
|
|
||||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
|
||||||
planScenarioReportMap.put(planScenarioId, report.getId());
|
|
||||||
|
|
||||||
|
newResult.addScenario(scenarioResult);
|
||||||
if (scenarioResult.getError() > 0) {
|
/**
|
||||||
scenarioAndErrorMap.put(testPlanApiScenario.getId(), TestPlanApiExecuteStatus.FAILD.name());
|
* 测试计划的定时任务场景执行时,主键是提前生成的【测试报告ID】。也就是TestResult.id是【测试报告ID】。
|
||||||
testPlanApiScenario.setLastResult(ScenarioStatus.Fail.name());
|
* report.getScenarioId中存放的是 TestPlanApiScenario.id:TestPlanReport.id 由于参数限制,只得将两个ID拼接起来
|
||||||
} else {
|
* 拆分report.getScenarioId, 查出ScenarioId,将真正的场景ID赋值回去
|
||||||
scenarioAndErrorMap.put(testPlanApiScenario.getId(), TestPlanApiExecuteStatus.SUCCESS.name());
|
* 同时将testPlanReportID存入集合,逻辑走完后更新TestPlanReport
|
||||||
testPlanApiScenario.setLastResult(ScenarioStatus.Success.name());
|
*/
|
||||||
}
|
String[] idArr = report.getScenarioId().split(":");
|
||||||
|
String planScenarioId = null;
|
||||||
String passRate = new DecimalFormat("0%").format((float) scenarioResult.getSuccess() / (scenarioResult.getSuccess() + scenarioResult.getError()));
|
if (idArr.length > 1) {
|
||||||
testPlanApiScenario.setPassRate(passRate);
|
planScenarioId = idArr[0];
|
||||||
// 报告详情内容
|
String planReportID = idArr[1];
|
||||||
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
|
if (!testPlanReportIdList.contains(planReportID)) {
|
||||||
|
testPlanReportIdList.add(planReportID);
|
||||||
detail.setContent(JSON.toJSONString(newResult).getBytes(StandardCharsets.UTF_8));
|
}
|
||||||
detail.setReportId(report.getId());
|
|
||||||
detail.setProjectId(report.getProjectId());
|
|
||||||
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) {
|
|
||||||
report.setTriggerMode(TriggerMode.MANUAL.name());
|
|
||||||
}
|
|
||||||
apiScenarioReportDetailMapper.insert(detail);
|
|
||||||
|
|
||||||
testPlanApiScenario.setReportId(report.getId());
|
|
||||||
report.setEndTime(System.currentTimeMillis());
|
|
||||||
testPlanApiScenario.setUpdateTime(System.currentTimeMillis());
|
|
||||||
testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario);
|
|
||||||
scenarioIdList.add(testPlanApiScenario.getApiScenarioId());
|
|
||||||
scenarioNames.append(report.getName()).append(",");
|
|
||||||
|
|
||||||
// 更新场景状态
|
|
||||||
ApiScenario scenario = apiScenarioMapper.selectByPrimaryKey(testPlanApiScenario.getApiScenarioId());
|
|
||||||
if (scenario != null) {
|
|
||||||
if (scenarioResult.getError() > 0) {
|
|
||||||
scenario.setLastResult("Fail");
|
|
||||||
} else {
|
} else {
|
||||||
scenario.setLastResult("Success");
|
planScenarioId = report.getScenarioId();
|
||||||
}
|
}
|
||||||
scenario.setPassRate(passRate);
|
TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(planScenarioId);
|
||||||
scenario.setReportId(report.getId());
|
report.setScenarioId(testPlanApiScenario.getApiScenarioId());
|
||||||
int executeTimes = 0;
|
report.setTestPlanScenarioId(planScenarioId);
|
||||||
if (scenario.getExecuteTimes() != null) {
|
report.setEndTime(System.currentTimeMillis());
|
||||||
executeTimes = scenario.getExecuteTimes().intValue();
|
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||||
}
|
planScenarioReportMap.put(planScenarioId, report.getId());
|
||||||
scenario.setExecuteTimes(executeTimes + 1);
|
|
||||||
|
|
||||||
apiScenarioMapper.updateByPrimaryKey(scenario);
|
if (scenarioResult.getError() > 0) {
|
||||||
// 发送通知
|
scenarioAndErrorMap.put(testPlanApiScenario.getId(), TestPlanApiExecuteStatus.FAILD.name());
|
||||||
// sendNotice(scenario);
|
testPlanApiScenario.setLastResult(ScenarioStatus.Fail.name());
|
||||||
|
} else {
|
||||||
|
scenarioAndErrorMap.put(testPlanApiScenario.getId(), TestPlanApiExecuteStatus.SUCCESS.name());
|
||||||
|
testPlanApiScenario.setLastResult(ScenarioStatus.Success.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
String passRate = new DecimalFormat("0%").format((float) scenarioResult.getSuccess() / (scenarioResult.getSuccess() + scenarioResult.getError()));
|
||||||
|
testPlanApiScenario.setPassRate(passRate);
|
||||||
|
// 报告详情内容
|
||||||
|
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
|
||||||
|
|
||||||
|
detail.setContent(JSON.toJSONString(newResult).getBytes(StandardCharsets.UTF_8));
|
||||||
|
detail.setReportId(report.getId());
|
||||||
|
detail.setProjectId(report.getProjectId());
|
||||||
|
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) {
|
||||||
|
report.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
|
}
|
||||||
|
apiScenarioReportDetailMapper.insert(detail);
|
||||||
|
|
||||||
|
testPlanApiScenario.setReportId(report.getId());
|
||||||
|
report.setEndTime(System.currentTimeMillis());
|
||||||
|
testPlanApiScenario.setUpdateTime(System.currentTimeMillis());
|
||||||
|
testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario);
|
||||||
|
scenarioIdList.add(testPlanApiScenario.getApiScenarioId());
|
||||||
|
scenarioNames.append(report.getName()).append(",");
|
||||||
|
|
||||||
|
// 更新场景状态
|
||||||
|
ApiScenario scenario = apiScenarioMapper.selectByPrimaryKey(testPlanApiScenario.getApiScenarioId());
|
||||||
|
if (scenario != null) {
|
||||||
|
if (scenarioResult.getError() > 0) {
|
||||||
|
scenario.setLastResult("Fail");
|
||||||
|
} else {
|
||||||
|
scenario.setLastResult("Success");
|
||||||
|
}
|
||||||
|
scenario.setPassRate(passRate);
|
||||||
|
scenario.setReportId(report.getId());
|
||||||
|
int executeTimes = 0;
|
||||||
|
if (scenario.getExecuteTimes() != null) {
|
||||||
|
executeTimes = scenario.getExecuteTimes().intValue();
|
||||||
|
}
|
||||||
|
scenario.setExecuteTimes(executeTimes + 1);
|
||||||
|
|
||||||
|
apiScenarioMapper.updateByPrimaryKey(scenario);
|
||||||
|
}
|
||||||
|
lastReport = report;
|
||||||
|
MessageCache.executionQueue.remove(report.getId());
|
||||||
|
reportIds.add(report.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
lastReport = report;
|
|
||||||
|
|
||||||
MessageCache.executionQueue.remove(report.getId());
|
|
||||||
reportIds.add(report.getId());
|
|
||||||
}
|
}
|
||||||
testPlanLog.info("TestPlanReportId" + JSONArray.toJSONString(testPlanReportIdList) + " EXECUTE OVER. SCENARIO STATUS : " + JSONObject.toJSONString(scenarioAndErrorMap));
|
testPlanLog.info("TestPlanReportId" + JSONArray.toJSONString(testPlanReportIdList) + " EXECUTE OVER. SCENARIO STATUS : " + JSONObject.toJSONString(scenarioAndErrorMap));
|
||||||
for (String reportId : testPlanReportIdList) {
|
for (String reportId : testPlanReportIdList) {
|
||||||
|
@ -505,6 +505,9 @@ public class ApiScenarioReportService {
|
||||||
scenarioReportMapper.updateByPrimaryKeySelective(scenario);
|
scenarioReportMapper.updateByPrimaryKeySelective(scenario);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
passRateMap.clear();
|
passRateMap.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
import org.apache.jorphan.collections.ListedHashTree;
|
import org.apache.jorphan.collections.ListedHashTree;
|
||||||
import org.aspectj.util.FileUtil;
|
import org.aspectj.util.FileUtil;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -593,6 +594,9 @@ public class ApiTestCaseService {
|
||||||
testCaseReviewMapper.updateByPrimaryKey(testCaseReview);
|
testCaseReviewMapper.updateByPrimaryKey(testCaseReview);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> selectIdsNotExistsInPlan(String projectId, String planId) {
|
public List<String> selectIdsNotExistsInPlan(String projectId, String planId) {
|
||||||
|
@ -676,6 +680,9 @@ public class ApiTestCaseService {
|
||||||
batchMapper.updateByPrimaryKeySelective(apiTestCase);
|
batchMapper.updateByPrimaryKeySelective(apiTestCase);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,6 +721,9 @@ public class ApiTestCaseService {
|
||||||
batchMapper.updateByPrimaryKeySelective(apiTestCase);
|
batchMapper.updateByPrimaryKeySelective(apiTestCase);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,8 +798,10 @@ public class ApiTestCaseService {
|
||||||
batchMapper.insert(report);
|
batchMapper.insert(report);
|
||||||
executeQueue.add(runCaseRequest);
|
executeQueue.add(runCaseRequest);
|
||||||
}
|
}
|
||||||
sqlSession.commit();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
for (RunCaseRequest runCaseRequest : executeQueue) {
|
for (RunCaseRequest runCaseRequest : executeQueue) {
|
||||||
MessageCache.caseExecResourceLock.put(runCaseRequest.getReportId(), runCaseRequest.getReport());
|
MessageCache.caseExecResourceLock.put(runCaseRequest.getReportId(), runCaseRequest.getReport());
|
||||||
run(runCaseRequest);
|
run(runCaseRequest);
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -448,6 +449,9 @@ public class HistoricalDataUpgradeService {
|
||||||
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenarioTest.getId(), scenarioTest.getName(), listSteps.size(), scenarioDefinition, mapper, num);
|
createApiScenarioWithBLOBs(saveHistoricalDataUpgrade, scenarioTest.getId(), scenarioTest.getName(), listSteps.size(), scenarioDefinition, mapper, num);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -159,6 +160,9 @@ public class ServiceUtils {
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
}
|
}
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
MSException.throwException("初始化 order 字段失败");
|
MSException.throwException("初始化 order 字段失败");
|
||||||
|
|
|
@ -59,8 +59,6 @@ public class TestPlanUtils {
|
||||||
if (StringUtils.equals(successStatus, status)) {
|
if (StringUtils.equals(successStatus, status)) {
|
||||||
report.setPassCount(report.getPassCount() + 1);
|
report.setPassCount(report.getPassCount() + 1);
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
System.out.println(status);
|
|
||||||
}
|
}
|
||||||
TestPlanUtils.getStatusResultMap(statusResultMap, status);
|
TestPlanUtils.getStatusResultMap(statusResultMap, status);
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.aspectj.util.FileUtil;
|
import org.aspectj.util.FileUtil;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -852,6 +853,10 @@ public class PerformanceTestService {
|
||||||
scenarioLoadTest.setId(UUID.randomUUID().toString());
|
scenarioLoadTest.setId(UUID.randomUUID().toString());
|
||||||
mapper.insert(scenarioLoadTest);
|
mapper.insert(scenarioLoadTest);
|
||||||
});
|
});
|
||||||
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getGranularity(String reportId) {
|
public Integer getGranularity(String reportId) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -111,7 +112,9 @@ public class CustomFieldTemplateService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
sqlSession.close();
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -199,6 +200,9 @@ public class GroupService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Group> getGroupByType(EditGroupRequest request) {
|
public List<Group> getGroupByType(EditGroupRequest request) {
|
||||||
|
@ -438,6 +442,9 @@ public class GroupService {
|
||||||
mapper.insertSelective(userGroup);
|
mapper.insertSelective(userGroup);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,6 +474,9 @@ public class GroupService {
|
||||||
mapper.insertSelective(userGroup);
|
mapper.insertSelective(userGroup);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -249,6 +250,9 @@ public class RelationshipEdgeService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RelationshipEdge getNewRelationshipEdge(String graphId, String sourceId, String targetId, String type) {
|
private RelationshipEdge getNewRelationshipEdge(String graphId, String sourceId, String targetId, String type) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.authc.*;
|
import org.apache.shiro.authc.*;
|
||||||
import org.apache.shiro.authz.UnauthorizedException;
|
import org.apache.shiro.authz.UnauthorizedException;
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -154,6 +155,9 @@ public class UserService {
|
||||||
mapper.insertSelective(userGroup);
|
mapper.insertSelective(userGroup);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -856,6 +860,9 @@ public class UserService {
|
||||||
mapper.insertSelective(userGroup);
|
mapper.insertSelective(userGroup);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -903,6 +910,9 @@ public class UserService {
|
||||||
mapper.insertSelective(userGroup);
|
mapper.insertSelective(userGroup);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1226,6 +1236,9 @@ public class UserService {
|
||||||
mapper.insertSelective(userGroup);
|
mapper.insertSelective(userGroup);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -568,6 +569,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
testCaseNodeMapper.updateByPrimaryKeySelective(value);
|
testCaseNodeMapper.updateByPrimaryKeySelective(value);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void batchUpdateTestCase(List<TestCaseDTO> testCases) {
|
private void batchUpdateTestCase(List<TestCaseDTO> testCases) {
|
||||||
|
@ -577,6 +581,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
testCaseMapper.updateByPrimaryKeySelective(value);
|
testCaseMapper.updateByPrimaryKeySelective(value);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TestCaseDTO> QueryTestCaseByNodeIds(List<String> nodeIds) {
|
private List<TestCaseDTO> QueryTestCaseByNodeIds(List<String> nodeIds) {
|
||||||
|
@ -678,6 +685,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
testCaseNodeMapper.updateByPrimaryKey(node);
|
testCaseNodeMapper.updateByPrimaryKey(node);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import io.metersphere.track.request.testreview.TestReviewRequest;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -88,6 +89,9 @@ public class TestCaseReviewLoadService {
|
||||||
testCaseReviewMapper.updateByPrimaryKey(testCaseReview);
|
testCaseReviewMapper.updateByPrimaryKey(testCaseReview);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
|
@ -104,7 +108,7 @@ public class TestCaseReviewLoadService {
|
||||||
testCaseReviewLoadMapper.updateByPrimaryKeySelective(testCaseReviewLoad);
|
testCaseReviewLoadMapper.updateByPrimaryKeySelective(testCaseReviewLoad);
|
||||||
return reportId;
|
return reportId;
|
||||||
}
|
}
|
||||||
//???
|
|
||||||
public Boolean isExistReport(LoadCaseReportRequest request) {
|
public Boolean isExistReport(LoadCaseReportRequest request) {
|
||||||
String reportId = request.getReportId();
|
String reportId = request.getReportId();
|
||||||
String testPlanLoadCaseId = request.getTestPlanLoadCaseId();
|
String testPlanLoadCaseId = request.getTestPlanLoadCaseId();
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -389,65 +390,10 @@ public class TestCaseReviewService {
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
//同步添加关联的接口和测试用例
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
/* if(request.getChecked()){
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
if (!testCaseIds.isEmpty()) {
|
}
|
||||||
testCaseIds.forEach(caseId -> {
|
|
||||||
TestCaseWithBLOBs testDtail=testCaseMapper.selectByPrimaryKey(caseId);
|
|
||||||
if(StringUtils.equals(testDtail.getType(), TestCaseStatus.performance.name())){
|
|
||||||
TestCaseReviewLoad t=new TestCaseReviewLoad();
|
|
||||||
t.setId(UUID.randomUUID().toString());
|
|
||||||
t.setTestCaseReviewId(request.getReviewId());
|
|
||||||
t.setLoadCaseId(testDtail.getTestId());
|
|
||||||
t.setCreateTime(System.currentTimeMillis());
|
|
||||||
t.setUpdateTime(System.currentTimeMillis());
|
|
||||||
TestCaseReviewLoadExample example=new TestCaseReviewLoadExample();
|
|
||||||
example.createCriteria().andTestCaseReviewIdEqualTo(request.getReviewId()).andLoadCaseIdEqualTo(t.getLoadCaseId());
|
|
||||||
if (testCaseReviewLoadMapper.countByExample(example) <=0) {
|
|
||||||
testCaseReviewLoadMapper.insert(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.testcase.name())){
|
|
||||||
TestCaseReviewApiCase t=new TestCaseReviewApiCase();
|
|
||||||
ApiTestCaseWithBLOBs apitest=apiTestCaseMapper.selectByPrimaryKey(testDtail.getTestId());
|
|
||||||
ApiDefinitionWithBLOBs apidefinition=apiDefinitionMapper.selectByPrimaryKey(apitest.getApiDefinitionId());
|
|
||||||
t.setId(UUID.randomUUID().toString());
|
|
||||||
t.setTestCaseReviewId(request.getReviewId());
|
|
||||||
t.setApiCaseId(testDtail.getTestId());
|
|
||||||
t.setEnvironmentId(apidefinition.getEnvironmentId());
|
|
||||||
t.setCreateTime(System.currentTimeMillis());
|
|
||||||
t.setUpdateTime(System.currentTimeMillis());
|
|
||||||
TestCaseReviewApiCaseExample example=new TestCaseReviewApiCaseExample();
|
|
||||||
example.createCriteria().andTestCaseReviewIdEqualTo(request.getReviewId()).andApiCaseIdEqualTo(t.getApiCaseId());
|
|
||||||
if(testCaseReviewApiCaseMapper.countByExample(example)<=0){
|
|
||||||
testCaseReviewApiCaseMapper.insert(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.automation.name())){
|
|
||||||
TestCaseReviewScenario t=new TestCaseReviewScenario();
|
|
||||||
ApiScenarioWithBLOBs testPlanApiScenario=apiScenarioMapper.selectByPrimaryKey(testDtail.getTestId());
|
|
||||||
t.setId(UUID.randomUUID().toString());
|
|
||||||
t.setTestCaseReviewId(request.getReviewId());
|
|
||||||
t.setApiScenarioId(testDtail.getTestId());
|
|
||||||
t.setLastResult(testPlanApiScenario.getLastResult());
|
|
||||||
t.setPassRate(testPlanApiScenario.getPassRate());
|
|
||||||
t.setReportId(testPlanApiScenario.getReportId());
|
|
||||||
t.setStatus(testPlanApiScenario.getStatus());
|
|
||||||
t.setCreateTime(System.currentTimeMillis());
|
|
||||||
t.setUpdateTime(System.currentTimeMillis());
|
|
||||||
TestCaseReviewScenarioExample example=new TestCaseReviewScenarioExample();
|
|
||||||
example.createCriteria().andTestCaseReviewIdEqualTo(request.getReviewId()).andApiScenarioIdEqualTo(t.getApiScenarioId());
|
|
||||||
if(testCaseReviewScenarioMapper.countByExample(example)<=0){
|
|
||||||
testCaseReviewScenarioMapper.insert(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId());
|
TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId());
|
||||||
if (StringUtils.equals(testCaseReview.getStatus(), TestCaseReviewStatus.Prepare.name())
|
if (StringUtils.equals(testCaseReview.getStatus(), TestCaseReviewStatus.Prepare.name())
|
||||||
|| StringUtils.equals(testCaseReview.getStatus(), TestCaseReviewStatus.Completed.name())) {
|
|| StringUtils.equals(testCaseReview.getStatus(), TestCaseReviewStatus.Completed.name())) {
|
||||||
|
|
|
@ -58,6 +58,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -668,6 +669,9 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateImportData(List<TestCaseWithBLOBs> testCases, String projectId) {
|
public void updateImportData(List<TestCaseWithBLOBs> testCases, String projectId) {
|
||||||
|
@ -693,6 +697,9 @@ public class TestCaseService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String updateCustomField(String customFields, String priority) {
|
private String updateCustomField(String customFields, String priority) {
|
||||||
|
@ -750,6 +757,9 @@ public class TestCaseService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -789,6 +799,9 @@ public class TestCaseService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCaseTemplateExport(String projectId, String importType, HttpServletResponse response) {
|
public void testCaseTemplateExport(String projectId, String importType, HttpServletResponse response) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -459,8 +460,11 @@ public class TestPlanApiCaseService {
|
||||||
TestPlanReportExecuteCatch.updateTestPlanThreadInfo(request.getPlanReportId(), executeThreadIdMap, null, null);
|
TestPlanReportExecuteCatch.updateTestPlanThreadInfo(request.getPlanReportId(), executeThreadIdMap, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
|
|
||||||
sqlSession.commit();
|
|
||||||
List<String> reportIds = new LinkedList<>();
|
List<String> reportIds = new LinkedList<>();
|
||||||
// 开始串行执行
|
// 开始串行执行
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
|
@ -562,7 +566,10 @@ public class TestPlanApiCaseService {
|
||||||
executeThreadIdMap.put(testPlanApiCase.getId(), report.getId());
|
executeThreadIdMap.put(testPlanApiCase.getId(), report.getId());
|
||||||
MessageCache.caseExecResourceLock.put(report.getId(), report);
|
MessageCache.caseExecResourceLock.put(report.getId(), report);
|
||||||
});
|
});
|
||||||
sqlSession.commit();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
//如果是测试计划生成报告的执行,则更新执行信息、执行线程信息。
|
//如果是测试计划生成报告的执行,则更新执行信息、执行线程信息。
|
||||||
if (TestPlanReportExecuteCatch.containsReport(request.getPlanReportId())) {
|
if (TestPlanReportExecuteCatch.containsReport(request.getPlanReportId())) {
|
||||||
if (!executeThreadIdMap.isEmpty()) {
|
if (!executeThreadIdMap.isEmpty()) {
|
||||||
|
@ -677,6 +684,9 @@ public class TestPlanApiCaseService {
|
||||||
});
|
});
|
||||||
|
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean hasFailCase(String planId, List<String> apiCaseIds) {
|
public Boolean hasFailCase(String planId, List<String> apiCaseIds) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -128,6 +129,9 @@ public class TestPlanLoadCaseService {
|
||||||
testPlanMapper.updateByPrimaryKey(testPlan);
|
testPlanMapper.updateByPrimaryKey(testPlan);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
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.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -247,6 +248,9 @@ public class TestPlanScenarioCaseService {
|
||||||
mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario);
|
mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario);
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
import org.apache.jorphan.collections.ListedHashTree;
|
import org.apache.jorphan.collections.ListedHashTree;
|
||||||
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
@ -668,6 +669,10 @@ public class TestPlanService {
|
||||||
testPlan.setActualEndTime(null);
|
testPlan.setActualEndTime(null);
|
||||||
testPlanMapper.updateByPrimaryKey(testPlan);
|
testPlanMapper.updateByPrimaryKey(testPlan);
|
||||||
}
|
}
|
||||||
|
sqlSession.flushStatements();
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestPlan> recentTestPlans(String projectId) {
|
public List<TestPlan> recentTestPlans(String projectId) {
|
||||||
|
@ -1438,6 +1443,10 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
|
||||||
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue