fix (接口自动化):多节点执行优化

This commit is contained in:
fit2-zhao 2021-10-08 10:31:29 +08:00 committed by fit2-zhao
parent 1540e573ab
commit de641948ef
2 changed files with 15 additions and 8 deletions

View File

@ -1238,12 +1238,19 @@ public class ApiAutomationService {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class); ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
// 开始并发执行 // 开始并发执行
for (String reportId : executeQueue.keySet()) { Thread thread = new Thread(new Runnable() {
//存储报告 @Override
APIScenarioReportResult report = executeQueue.get(reportId).getReport(); public void run() {
batchMapper.insert(report); for (String reportId : executeQueue.keySet()) {
} //存储报告
sqlSession.flushStatements(); APIScenarioReportResult report = executeQueue.get(reportId).getReport();
batchMapper.insert(report);
}
sqlSession.flushStatements();
}
});
thread.start();
for (String reportId : executeQueue.keySet()) { for (String reportId : executeQueue.keySet()) {
if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) { if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) {
jMeterService.runTest(executeQueue.get(reportId).getTestId(), reportId, request.getRunMode(), request.getPlanScenarioId(), request.getConfig()); jMeterService.runTest(executeQueue.get(reportId).getTestId(), reportId, request.getRunMode(), request.getPlanScenarioId(), request.getConfig());

View File

@ -56,8 +56,8 @@ public class NodeKafkaService {
config.getTestResources().remove(jvmInfoDTO); config.getTestResources().remove(jvmInfoDTO);
} }
String cUri = String.format(BASE_URL + "/consumer/create", nodeIp, port); //String cUri = String.format(BASE_URL + "/consumer/create", nodeIp, port);
restTemplate.postForEntity(cUri, consumerProps, void.class); //restTemplate.postForEntity(cUri, consumerProps, void.class);
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage()); LogUtil.error(e.getMessage());