fix(测试计划定时任务): 修复测试计划定时任务取消关联资源池时不生效的问题

修复测试计划定时任务取消关联资源池时不生效的问题,并在回调函数处增加log记录
This commit is contained in:
song-tianyang 2021-11-30 19:57:38 +08:00 committed by song-tianyang
parent aa79031605
commit 614433e399
3 changed files with 36 additions and 19 deletions

View File

@ -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();
@ -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;
} }

View File

@ -1077,6 +1077,15 @@ public class TestPlanService {
runModeConfig.setEnvMap(new HashMap<>()); runModeConfig.setEnvMap(new HashMap<>());
runModeConfig.setOnSampleError(false); runModeConfig.setOnSampleError(false);
} else { } else {
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) { if (runModeConfig.getEnvMap() == null) {
runModeConfig.setEnvMap(new HashMap<>()); runModeConfig.setEnvMap(new HashMap<>());
} }

View File

@ -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() {