fix(测试计划定时任务): 修复测试计划定时任务取消关联资源池时不生效的问题
修复测试计划定时任务取消关联资源池时不生效的问题,并在回调函数处增加log记录
This commit is contained in:
parent
aa79031605
commit
614433e399
|
@ -156,6 +156,7 @@ public class ApiScenarioReportService {
|
||||||
public ApiScenarioReport editReport(ScenarioResult test, long startTime) {
|
public ApiScenarioReport editReport(ScenarioResult test, long startTime) {
|
||||||
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(test.getName());
|
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(test.getName());
|
||||||
if (report == null) {
|
if (report == null) {
|
||||||
|
LogUtil.info("从缓存中获取场景报告:【" + test.getName() + "】");
|
||||||
report = MessageCache.scenarioExecResourceLock.get(test.getName());
|
report = MessageCache.scenarioExecResourceLock.get(test.getName());
|
||||||
}
|
}
|
||||||
if (report != null) {
|
if (report != null) {
|
||||||
|
@ -169,6 +170,8 @@ public class ApiScenarioReportService {
|
||||||
}
|
}
|
||||||
MessageCache.scenarioExecResourceLock.remove(report.getId());
|
MessageCache.scenarioExecResourceLock.remove(report.getId());
|
||||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||||
|
} else {
|
||||||
|
LogUtil.error("未获取到场景报告!【" + test.getName() + "】");
|
||||||
}
|
}
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
@ -297,7 +300,7 @@ public class ApiScenarioReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiScenarioReport updateSchedulePlanCase(TestResult result, String runMode) {
|
public ApiScenarioReport updateSchedulePlanCase(TestResult result, String runMode) {
|
||||||
|
LogUtil.info("收到测试计划场景[" + result.getTestId() + "]的执行信息,开始保存");
|
||||||
ApiScenarioReport lastReport = null;
|
ApiScenarioReport lastReport = null;
|
||||||
List<ScenarioResult> scenarioResultList = result.getScenarios();
|
List<ScenarioResult> scenarioResultList = result.getScenarios();
|
||||||
|
|
||||||
|
@ -307,7 +310,7 @@ public class ApiScenarioReportService {
|
||||||
List<String> reportIds = new ArrayList<>();
|
List<String> reportIds = new ArrayList<>();
|
||||||
List<String> scenarioIdList = new ArrayList<>();
|
List<String> scenarioIdList = new ArrayList<>();
|
||||||
Map<String, String> scenarioAndErrorMap = new HashMap<>();
|
Map<String, String> scenarioAndErrorMap = new HashMap<>();
|
||||||
Map<String,String> planScenarioReportMap = new HashMap<>();
|
Map<String, String> planScenarioReportMap = new HashMap<>();
|
||||||
for (ScenarioResult scenarioResult : scenarioResultList) {
|
for (ScenarioResult scenarioResult : scenarioResultList) {
|
||||||
|
|
||||||
// 存储场景报告
|
// 存储场景报告
|
||||||
|
@ -344,7 +347,7 @@ public class ApiScenarioReportService {
|
||||||
report.setTestPlanScenarioId(planScenarioId);
|
report.setTestPlanScenarioId(planScenarioId);
|
||||||
report.setEndTime(System.currentTimeMillis());
|
report.setEndTime(System.currentTimeMillis());
|
||||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||||
planScenarioReportMap.put(planScenarioId,report.getId());
|
planScenarioReportMap.put(planScenarioId, report.getId());
|
||||||
|
|
||||||
|
|
||||||
if (scenarioResult.getError() > 0) {
|
if (scenarioResult.getError() > 0) {
|
||||||
|
@ -406,7 +409,7 @@ public class ApiScenarioReportService {
|
||||||
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(reportId, null, scenarioAndErrorMap, null);
|
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(reportId, null, scenarioAndErrorMap, null);
|
||||||
TestPlanReportExecuteCatch.updateTestPlanReport(reportId, null, planScenarioReportMap);
|
TestPlanReportExecuteCatch.updateTestPlanReport(reportId, null, planScenarioReportMap);
|
||||||
}
|
}
|
||||||
|
LogUtil.info("测试计划场景[" + result.getTestId() + "]保存结束");
|
||||||
return lastReport;
|
return lastReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,13 +867,13 @@ public class ApiScenarioReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getReportStatusByReportIds(Collection<String> values) {
|
public Map<String, String> getReportStatusByReportIds(Collection<String> values) {
|
||||||
if(CollectionUtils.isEmpty(values)){
|
if (CollectionUtils.isEmpty(values)) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
List<ApiScenarioReport> reportList = extApiScenarioReportMapper.selectStatusByIds(values);
|
List<ApiScenarioReport> reportList = extApiScenarioReportMapper.selectStatusByIds(values);
|
||||||
for (ApiScenarioReport report : reportList) {
|
for (ApiScenarioReport report : reportList) {
|
||||||
map.put(report.getId(),report.getStatus());
|
map.put(report.getId(), report.getStatus());
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class TestPlanService {
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanFollowMapper testPlanFollowMapper;
|
private TestPlanFollowMapper testPlanFollowMapper;
|
||||||
|
|
||||||
private final ExecutorService executorService = Executors.newFixedThreadPool(20,new NamedThreadFactory("TestPlanService"));
|
private final ExecutorService executorService = Executors.newFixedThreadPool(20, new NamedThreadFactory("TestPlanService"));
|
||||||
|
|
||||||
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
|
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
|
||||||
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
||||||
|
@ -992,7 +992,7 @@ public class TestPlanService {
|
||||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
||||||
String runMode = ApiRunMode.SCHEDULE_SCENARIO_PLAN.name();
|
String runMode = ApiRunMode.SCHEDULE_SCENARIO_PLAN.name();
|
||||||
// 调用执行方法
|
// 调用执行方法
|
||||||
jMeterService.runLocal(request.getId(),request.getConfig(), jmeterHashTree, request.getReportId(), runMode);
|
jMeterService.runLocal(request.getId(), request.getConfig(), jmeterHashTree, request.getReportId(), runMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnId;
|
return returnId;
|
||||||
|
@ -1076,8 +1076,17 @@ public class TestPlanService {
|
||||||
runModeConfig.setReportType("iddReport");
|
runModeConfig.setReportType("iddReport");
|
||||||
runModeConfig.setEnvMap(new HashMap<>());
|
runModeConfig.setEnvMap(new HashMap<>());
|
||||||
runModeConfig.setOnSampleError(false);
|
runModeConfig.setOnSampleError(false);
|
||||||
}else {
|
} else {
|
||||||
if(runModeConfig.getEnvMap() == null){
|
try {
|
||||||
|
JSONObject runModeObj = JSONObject.parseObject(apiRunConfig);
|
||||||
|
if (runModeObj.containsKey("runWithinResourcePool") && !runModeObj.getBoolean("runWithinResourcePool")) {
|
||||||
|
runModeConfig.setResourcePoolId(null);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runModeConfig.getEnvMap() == null) {
|
||||||
runModeConfig.setEnvMap(new HashMap<>());
|
runModeConfig.setEnvMap(new HashMap<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1097,11 +1106,11 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
if (planApiCaseMap.size() > count) {
|
if (planApiCaseMap.size() > count) {
|
||||||
testPlanReportService.finishReport(reportInfoDTO.getTestPlanReport());
|
testPlanReportService.finishReport(reportInfoDTO.getTestPlanReport());
|
||||||
MSException.throwException("并发超过"+count+",数量过大,请重新选择!");
|
MSException.throwException("并发超过" + count + ",数量过大,请重新选择!");
|
||||||
}
|
}
|
||||||
if (planScenarioIdsMap.size() > count) {
|
if (planScenarioIdsMap.size() > count) {
|
||||||
testPlanReportService.finishReport(reportInfoDTO.getTestPlanReport());
|
testPlanReportService.finishReport(reportInfoDTO.getTestPlanReport());
|
||||||
MSException.throwException("并发超过"+count+",数量过大,请重新选择!");
|
MSException.throwException("并发超过" + count + ",数量过大,请重新选择!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extTestPlanMapper.updateActualEndTimeIsNullById(testPlanID);
|
extTestPlanMapper.updateActualEndTimeIsNullById(testPlanID);
|
||||||
|
@ -1148,14 +1157,14 @@ public class TestPlanService {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
performaneThreadIDMap.put(performanceRequest.getTestPlanLoadId(),reportId);
|
performaneThreadIDMap.put(performanceRequest.getTestPlanLoadId(), reportId);
|
||||||
if (StringUtils.isNotEmpty(reportId)) {
|
if (StringUtils.isNotEmpty(reportId)) {
|
||||||
executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.RUNNING.name());
|
executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.RUNNING.name());
|
||||||
} else {
|
} else {
|
||||||
executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.PREPARE.name());
|
executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.PREPARE.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TestPlanReportExecuteCatch.updateTestPlanThreadInfo(planReportId,null,null,performaneThreadIDMap);
|
TestPlanReportExecuteCatch.updateTestPlanThreadInfo(planReportId, null, null, performaneThreadIDMap);
|
||||||
if (!performaneReportIDMap.isEmpty()) {
|
if (!performaneReportIDMap.isEmpty()) {
|
||||||
//性能测试时保存性能测试报告ID,在结果返回时用于捕捉并进行
|
//性能测试时保存性能测试报告ID,在结果返回时用于捕捉并进行
|
||||||
testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDMap, triggerMode);
|
testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDMap, triggerMode);
|
||||||
|
@ -1172,7 +1181,7 @@ public class TestPlanService {
|
||||||
testPlanLog.info("ReportId[" + planReportId + "] start run. TestPlanID:[" + testPlanID + "]. Execute api :" + JSONObject.toJSONString(executeApiCaseIdMap) + "; Execute scenario:" + JSONObject.toJSONString(executeScenarioCaseIdMap) + "; Execute performance:" + JSONObject.toJSONString(executePerformanceIdMap));
|
testPlanLog.info("ReportId[" + planReportId + "] start run. TestPlanID:[" + testPlanID + "]. Execute api :" + JSONObject.toJSONString(executeApiCaseIdMap) + "; Execute scenario:" + JSONObject.toJSONString(executeScenarioCaseIdMap) + "; Execute performance:" + JSONObject.toJSONString(executePerformanceIdMap));
|
||||||
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(planReportId, executeApiCaseIdMap, executeScenarioCaseIdMap, executePerformanceIdMap);
|
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(planReportId, executeApiCaseIdMap, executeScenarioCaseIdMap, executePerformanceIdMap);
|
||||||
//执行接口案例任务
|
//执行接口案例任务
|
||||||
this.executeApiTestCase(triggerMode, planReportId,new ArrayList<>(planApiCaseMap.keySet()), runModeConfig);
|
this.executeApiTestCase(triggerMode, planReportId, new ArrayList<>(planApiCaseMap.keySet()), runModeConfig);
|
||||||
//执行场景执行任务
|
//执行场景执行任务
|
||||||
this.executeScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, planScenarioIdsMap);
|
this.executeScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, planScenarioIdsMap);
|
||||||
this.listenTaskExecuteStatus(planReportId);
|
this.listenTaskExecuteStatus(planReportId);
|
||||||
|
@ -1702,7 +1711,7 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildApiReport(TestPlanSimpleReportDTO report, JSONObject config, TestPlanExecuteInfo executeInfo,boolean isFinish) {
|
public void buildApiReport(TestPlanSimpleReportDTO report, JSONObject config, TestPlanExecuteInfo executeInfo, boolean isFinish) {
|
||||||
if (MapUtils.isEmpty(executeInfo.getApiCaseExecInfo()) && MapUtils.isEmpty(executeInfo.getApiScenarioCaseExecInfo())) {
|
if (MapUtils.isEmpty(executeInfo.getApiCaseExecInfo()) && MapUtils.isEmpty(executeInfo.getApiScenarioCaseExecInfo())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1712,12 +1721,12 @@ public class TestPlanService {
|
||||||
if (checkReportConfig(config, "api", "all")) {
|
if (checkReportConfig(config, "api", "all")) {
|
||||||
if (MapUtils.isNotEmpty(executeInfo.getApiCaseExecInfo())) {
|
if (MapUtils.isNotEmpty(executeInfo.getApiCaseExecInfo())) {
|
||||||
// 接口
|
// 接口
|
||||||
apiAllCases = testPlanApiCaseService.getByApiExecReportIds(executeInfo.getApiCaseExecuteThreadMap(),isFinish);
|
apiAllCases = testPlanApiCaseService.getByApiExecReportIds(executeInfo.getApiCaseExecuteThreadMap(), isFinish);
|
||||||
report.setApiAllCases(apiAllCases);
|
report.setApiAllCases(apiAllCases);
|
||||||
}
|
}
|
||||||
if (MapUtils.isNotEmpty(executeInfo.getApiScenarioCaseExecInfo())) {
|
if (MapUtils.isNotEmpty(executeInfo.getApiScenarioCaseExecInfo())) {
|
||||||
//场景
|
//场景
|
||||||
scenarioAllCases = testPlanScenarioCaseService.getAllCases(executeInfo.getApiScenarioThreadMap(),isFinish);
|
scenarioAllCases = testPlanScenarioCaseService.getAllCases(executeInfo.getApiScenarioThreadMap(), isFinish);
|
||||||
report.setScenarioAllCases(scenarioAllCases);
|
report.setScenarioAllCases(scenarioAllCases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,6 +165,11 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
'schedule.value'() {
|
'schedule.value'() {
|
||||||
this.form.cronValue = this.schedule.value;
|
this.form.cronValue = this.schedule.value;
|
||||||
|
},
|
||||||
|
'runConfig.runWithinResourcePool'() {
|
||||||
|
if (!this.runConfig.runWithinResourcePool) {
|
||||||
|
this.runConfig.resourcePoolId = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
Loading…
Reference in New Issue