fix:jenkins选择资源池运行
This commit is contained in:
parent
3bc0459f42
commit
a9e7c67970
|
@ -278,11 +278,12 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
||||||
reportTask.setExecutor(userName);
|
reportTask.setExecutor(userName);
|
||||||
reportTask.setExecutionTime(executionTime);
|
reportTask.setExecutionTime(executionTime);
|
||||||
reportTask.setExecutionEnvironment(name);
|
reportTask.setExecutionEnvironment(name);
|
||||||
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name())) {
|
//用例,定时,jenkins
|
||||||
|
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||||
apiDefinitionService.addResult(testResult);
|
apiDefinitionService.addResult(testResult);
|
||||||
|
|
||||||
//测试计划定时任务-接口执行逻辑的话,需要同步测试计划的报告数据
|
//测试计划定时任务-接口执行逻辑的话,需要同步测试计划的报告数据
|
||||||
if (StringUtils.equalsAny(this.runMode, ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
if (StringUtils.equals(this.runMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
|
||||||
apiDefinitionExecResultService.saveApiResultByScheduleTask(testResult, ApiRunMode.SCHEDULE_API_PLAN.name());
|
apiDefinitionExecResultService.saveApiResultByScheduleTask(testResult, ApiRunMode.SCHEDULE_API_PLAN.name());
|
||||||
List<String> testPlanReportIdList = new ArrayList<>();
|
List<String> testPlanReportIdList = new ArrayList<>();
|
||||||
testPlanReportIdList.add(debugReportId);
|
testPlanReportIdList.add(debugReportId);
|
||||||
|
@ -290,17 +291,25 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
||||||
testPlanReportService.checkTestPlanStatus(testPlanReportId);
|
testPlanReportService.checkTestPlanStatus(testPlanReportId);
|
||||||
}
|
}
|
||||||
testPlanReportService.updateReport(testPlanReportIdList, ApiRunMode.SCHEDULE_API_PLAN.name(), ReportTriggerMode.SCHEDULE.name());
|
testPlanReportService.updateReport(testPlanReportIdList, ApiRunMode.SCHEDULE_API_PLAN.name(), ReportTriggerMode.SCHEDULE.name());
|
||||||
|
} else if (StringUtils.equals(this.runMode, ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||||
|
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.JENKINS_API_PLAN.name(), TriggerMode.API.name());
|
||||||
|
List<String> testPlanReportIdList = new ArrayList<>();
|
||||||
|
testPlanReportIdList.add(debugReportId);
|
||||||
|
for (String testPlanReportId : testPlanReportIdList) { // 更新每个测试计划的状态
|
||||||
|
testPlanReportService.checkTestPlanStatus(testPlanReportId);
|
||||||
|
}
|
||||||
|
testPlanReportService.updateReport(testPlanReportIdList, ApiRunMode.JENKINS_API_PLAN.name(), TriggerMode.API.name());
|
||||||
} else {
|
} else {
|
||||||
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.API_PLAN.name(), TriggerMode.MANUAL.name());
|
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.API_PLAN.name(), TriggerMode.MANUAL.name());
|
||||||
}
|
}
|
||||||
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO.name())) {
|
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
|
||||||
// 执行报告不需要存储,由用户确认后在存储
|
// 执行报告不需要存储,由用户确认后在存储
|
||||||
testResult.setTestId(testId);
|
testResult.setTestId(testId);
|
||||||
ApiScenarioReport scenarioReport = apiScenarioReportService.complete(testResult, this.runMode);
|
ApiScenarioReport scenarioReport = apiScenarioReportService.complete(testResult, this.runMode);
|
||||||
//环境
|
//环境
|
||||||
ApiScenarioWithBLOBs apiScenario = apiAutomationService.getDto(scenarioReport.getScenarioId());
|
ApiScenarioWithBLOBs apiScenario = apiAutomationService.getDto(scenarioReport.getScenarioId());
|
||||||
String name = "";
|
String name = "";
|
||||||
if(apiScenario!= null ) {
|
if (apiScenario != null) {
|
||||||
String executionEnvironment = apiScenario.getScenarioDefinition();
|
String executionEnvironment = apiScenario.getScenarioDefinition();
|
||||||
JSONObject json = JSONObject.parseObject(executionEnvironment);
|
JSONObject json = JSONObject.parseObject(executionEnvironment);
|
||||||
if (json != null && json.getString("environmentMap") != null && json.getString("environmentMap").length() > 2) {
|
if (json != null && json.getString("environmentMap") != null && json.getString("environmentMap").length() > 2) {
|
||||||
|
|
|
@ -916,7 +916,7 @@ public class ApiAutomationService {
|
||||||
APIScenarioReportResult report;
|
APIScenarioReportResult report;
|
||||||
Map<String, String> planEnvMap = new HashMap<>();
|
Map<String, String> planEnvMap = new HashMap<>();
|
||||||
//如果是测试计划页面触发的执行方式,生成报告时createScenarioReport第二个参数需要特殊处理
|
//如果是测试计划页面触发的执行方式,生成报告时createScenarioReport第二个参数需要特殊处理
|
||||||
if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
|
||||||
String testPlanScenarioId = item.getId();
|
String testPlanScenarioId = item.getId();
|
||||||
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(item.getId())) {
|
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(item.getId())) {
|
||||||
testPlanScenarioId = request.getScenarioTestPlanIdMap().get(item.getId());
|
testPlanScenarioId = request.getScenarioTestPlanIdMap().get(item.getId());
|
||||||
|
@ -1091,7 +1091,7 @@ public class ApiAutomationService {
|
||||||
if (reportIds != null) {
|
if (reportIds != null) {
|
||||||
//如果是测试计划页面触发的执行方式,生成报告时createScenarioReport第二个参数需要特殊处理
|
//如果是测试计划页面触发的执行方式,生成报告时createScenarioReport第二个参数需要特殊处理
|
||||||
APIScenarioReportResult report = null;
|
APIScenarioReportResult report = null;
|
||||||
if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
|
||||||
String testPlanScenarioId = item.getId();
|
String testPlanScenarioId = item.getId();
|
||||||
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(item.getId())) {
|
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(item.getId())) {
|
||||||
testPlanScenarioId = request.getScenarioTestPlanIdMap().get(item.getId());
|
testPlanScenarioId = request.getScenarioTestPlanIdMap().get(item.getId());
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class ApiScenarioReportService {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
if (StringUtils.equals(runMode, ApiRunMode.SCENARIO_PLAN.name())) {
|
if (StringUtils.equals(runMode, ApiRunMode.SCENARIO_PLAN.name())) {
|
||||||
return updatePlanCase(result, runMode);
|
return updatePlanCase(result, runMode);
|
||||||
} else if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
} else if (StringUtils.equalsAny(runMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
|
||||||
return updateSchedulePlanCase(result, runMode);
|
return updateSchedulePlanCase(result, runMode);
|
||||||
} else {
|
} else {
|
||||||
updateScenarioStatus(result.getTestId());
|
updateScenarioStatus(result.getTestId());
|
||||||
|
@ -319,7 +319,7 @@ public class ApiScenarioReportService {
|
||||||
// margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId, reportIds);
|
// margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId, reportIds);
|
||||||
|
|
||||||
TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
|
TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
|
||||||
testPlanReportService.updateReport(testPlanReportIdList, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ReportTriggerMode.SCHEDULE.name());
|
testPlanReportService.updateReport(testPlanReportIdList, runMode, lastReport.getTriggerMode());
|
||||||
|
|
||||||
return lastReport;
|
return lastReport;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.commons.constants;
|
package io.metersphere.commons.constants;
|
||||||
|
|
||||||
public enum ApiRunMode {
|
public enum ApiRunMode {
|
||||||
RUN, DEBUG, DEFINITION, SCENARIO, API_PLAN, JENKINS_API_PLAN, JENKINS, SCENARIO_PLAN, API, SCHEDULE_API_PLAN, SCHEDULE_SCENARIO,SCHEDULE_SCENARIO_PLAN, SCHEDULE_PERFORMANCE_TEST
|
RUN, DEBUG, DEFINITION, SCENARIO, API_PLAN, JENKINS_API_PLAN, JENKINS_SCENARIO_PLAN, JENKINS_PERFORMANCE_TEST, JENKINS,
|
||||||
|
SCENARIO_PLAN, API, SCHEDULE_API_PLAN, SCHEDULE_SCENARIO, SCHEDULE_SCENARIO_PLAN, SCHEDULE_PERFORMANCE_TEST
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@ public enum ReportTriggerMode {
|
||||||
* 性能测试用例执行触发报告
|
* 性能测试用例执行触发报告
|
||||||
*/
|
*/
|
||||||
CASE,
|
CASE,
|
||||||
TEST_PLAN_SCHEDULE
|
TEST_PLAN_SCHEDULE,
|
||||||
|
TEST_PLAN_API,
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,8 @@ public class TestPlanController {
|
||||||
ApiRunConfigDTO api = new ApiRunConfigDTO();
|
ApiRunConfigDTO api = new ApiRunConfigDTO();
|
||||||
api.setMode(testplanRunRequest.getMode());
|
api.setMode(testplanRunRequest.getMode());
|
||||||
api.setResourcePoolId(testplanRunRequest.getResourcePoolId());
|
api.setResourcePoolId(testplanRunRequest.getResourcePoolId());
|
||||||
|
api.setOnSampleError(true);
|
||||||
|
api.setReportType("iddReport");
|
||||||
String apiRunConfig = JSONObject.toJSONString(api);
|
String apiRunConfig = JSONObject.toJSONString(api);
|
||||||
testPlanService.run(testplanRunRequest.getTestPlanId(), testplanRunRequest.getProjectId(), testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), apiRunConfig);
|
testPlanService.run(testplanRunRequest.getTestPlanId(), testplanRunRequest.getProjectId(), testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), apiRunConfig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,14 @@ public class TestPlanReportController {
|
||||||
public String sendTask(@PathVariable String planId) {
|
public String sendTask(@PathVariable String planId) {
|
||||||
TestPlanReport report = testPlanReportService.getTestPlanReport(planId);
|
TestPlanReport report = testPlanReportService.getTestPlanReport(planId);
|
||||||
testPlanReportService.update(report);
|
testPlanReportService.update(report);
|
||||||
return "sucess";
|
return "sucess";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/status/{planId}")
|
||||||
|
public String getStatus(@PathVariable String planId) {
|
||||||
|
TestPlanReport report = testPlanReportService.getTestPlanReport(planId);
|
||||||
|
String status = report.getStatus();
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
||||||
public class ApiRunConfigDTO {
|
public class ApiRunConfigDTO {
|
||||||
private String mode;
|
private String mode;
|
||||||
private String reportType;
|
private String reportType;
|
||||||
private String onSampleError;
|
private boolean onSampleError;
|
||||||
private String runWithinResourcePool;
|
private String runWithinResourcePool;
|
||||||
private String resourcePoolId;
|
private String resourcePoolId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,6 @@ public class TestPlanReportService {
|
||||||
//更新TestPlan状态,改为进行中
|
//更新TestPlan状态,改为进行中
|
||||||
testPlan.setStatus(TestPlanStatus.Underway.name());
|
testPlan.setStatus(TestPlanStatus.Underway.name());
|
||||||
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||||
|
|
||||||
return testPlanReport;
|
return testPlanReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,8 +242,7 @@ public class TestPlanReportService {
|
||||||
String issuesInfo = null;
|
String issuesInfo = null;
|
||||||
|
|
||||||
//因为接口案例的定时任务是单个案例开线程运行, 所以要检查是否都执行完成。全部执行完成时才会进行统一整理
|
//因为接口案例的定时任务是单个案例开线程运行, 所以要检查是否都执行完成。全部执行完成时才会进行统一整理
|
||||||
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), triggerMode)
|
if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name()) && StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||||
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
|
|
||||||
List<String> statusList = extTestPlanApiCaseMapper.getStatusByTestPlanId(testPlan.getId());
|
List<String> statusList = extTestPlanApiCaseMapper.getStatusByTestPlanId(testPlan.getId());
|
||||||
for (String status : statusList) {
|
for (String status : statusList) {
|
||||||
if (status == null) {
|
if (status == null) {
|
||||||
|
@ -280,14 +278,14 @@ public class TestPlanReportService {
|
||||||
|
|
||||||
|
|
||||||
//只针对定时任务做处理
|
//只针对定时任务做处理
|
||||||
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), triggerMode)
|
if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name())
|
||||||
&& StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
|
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||||
testPlanReport.setIsApiCaseExecuting(false);
|
testPlanReport.setIsApiCaseExecuting(false);
|
||||||
} else if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), triggerMode)
|
} else if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name())
|
||||||
&& StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
||||||
testPlanReport.setIsScenarioExecuting(false);
|
testPlanReport.setIsScenarioExecuting(false);
|
||||||
} else if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), triggerMode)
|
} else if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name())
|
||||||
&& StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name())) {
|
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(), ApiRunMode.JENKINS_PERFORMANCE_TEST.name())) {
|
||||||
testPlanReport.setIsPerformanceExecuting(false);
|
testPlanReport.setIsPerformanceExecuting(false);
|
||||||
} else {
|
} else {
|
||||||
testPlanReport.setIsPerformanceExecuting(false);
|
testPlanReport.setIsPerformanceExecuting(false);
|
||||||
|
@ -299,8 +297,8 @@ public class TestPlanReportService {
|
||||||
component.afterBuild(testCaseReportMetricDTO);
|
component.afterBuild(testCaseReportMetricDTO);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), triggerMode)
|
if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name())
|
||||||
&& StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name())) {
|
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(), ApiRunMode.JENKINS_PERFORMANCE_TEST.name())) {
|
||||||
//如果是性能测试作为触发,由于延迟原因可能会出现报告已经结束但是状态还是进行中的状态
|
//如果是性能测试作为触发,由于延迟原因可能会出现报告已经结束但是状态还是进行中的状态
|
||||||
List<TestCaseReportStatusResultDTO> loadResult = testCaseReportMetricDTO.getExecuteResult().getLoadResult();
|
List<TestCaseReportStatusResultDTO> loadResult = testCaseReportMetricDTO.getExecuteResult().getLoadResult();
|
||||||
for (TestCaseReportStatusResultDTO dto : loadResult) {
|
for (TestCaseReportStatusResultDTO dto : loadResult) {
|
||||||
|
@ -381,17 +379,16 @@ public class TestPlanReportService {
|
||||||
testPlan.setStatus(TestPlanStatus.Completed.name());
|
testPlan.setStatus(TestPlanStatus.Completed.name());
|
||||||
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||||
}
|
}
|
||||||
|
if (StringUtils.equalsAny(report.getTriggerMode(), ReportTriggerMode.API.name(), ReportTriggerMode.SCHEDULE.name())) {
|
||||||
if (StringUtils.equals(report.getTriggerMode(), ReportTriggerMode.API.name()) || StringUtils.equals(report.getTriggerMode(), ReportTriggerMode.SCHEDULE.name())) {
|
|
||||||
//发送通知
|
//发送通知
|
||||||
sendMessage(report);
|
sendMessage(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
testPlanReportMapper.updateByPrimaryKey(report);
|
testPlanReportMapper.updateByPrimaryKey(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,10 +405,16 @@ public class TestPlanReportService {
|
||||||
String failedContext = "";
|
String failedContext = "";
|
||||||
String subject = "";
|
String subject = "";
|
||||||
String event = "";
|
String event = "";
|
||||||
|
if (StringUtils.equals(testPlanReport.getTriggerMode(), ReportTriggerMode.API.name())) {
|
||||||
|
successContext = "测试计划jenkins任务通知:'" + testPlan.getName() + "'执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||||
|
failedContext = "测试计划jenkins任务通知:'" + testPlan.getName() + "'执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||||
|
subject = Translator.get("task_notification_jenkins");
|
||||||
|
} else {
|
||||||
|
successContext = "测试计划定时任务通知:'" + testPlan.getName() + "'执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||||
|
failedContext = "测试计划定时任务通知:'" + testPlan.getName() + "'执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||||
|
subject = Translator.get("task_notification");
|
||||||
|
}
|
||||||
|
|
||||||
successContext = "测试计划定时任务通知:'" + testPlan.getName() + "'执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
|
||||||
failedContext = "测试计划定时任务通知:'" + testPlan.getName() + "'执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
|
||||||
subject = Translator.get("task_notification");
|
|
||||||
|
|
||||||
if (StringUtils.equals(TestPlanReportStatus.FAILED.name(), testPlanReport.getStatus())) {
|
if (StringUtils.equals(TestPlanReportStatus.FAILED.name(), testPlanReport.getStatus())) {
|
||||||
event = NoticeConstants.Event.EXECUTE_FAILED;
|
event = NoticeConstants.Event.EXECUTE_FAILED;
|
||||||
|
@ -428,7 +431,7 @@ public class TestPlanReportService {
|
||||||
String successfulMailTemplate = "";
|
String successfulMailTemplate = "";
|
||||||
String errfoMailTemplate = "";
|
String errfoMailTemplate = "";
|
||||||
|
|
||||||
if (StringUtils.equals(testPlanReport.getTriggerMode(), ReportTriggerMode.SCHEDULE.name())) {
|
if (StringUtils.equalsAny(testPlanReport.getTriggerMode(), ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name())) {
|
||||||
successfulMailTemplate = "TestPlanSuccessfulNotification";
|
successfulMailTemplate = "TestPlanSuccessfulNotification";
|
||||||
errfoMailTemplate = "TestPlanFailedNotification";
|
errfoMailTemplate = "TestPlanFailedNotification";
|
||||||
}
|
}
|
||||||
|
@ -498,7 +501,7 @@ public class TestPlanReportService {
|
||||||
for (String string : updatePerformaneReportIDList) {
|
for (String string : updatePerformaneReportIDList) {
|
||||||
TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO();
|
TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO();
|
||||||
eventDTO.setReportId(string);
|
eventDTO.setReportId(string);
|
||||||
eventDTO.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
|
eventDTO.setTriggerMode(triggerMode);
|
||||||
eventDTO.setStatus(PerformanceTestStatus.Completed.name());
|
eventDTO.setStatus(PerformanceTestStatus.Completed.name());
|
||||||
this.updatePerformanceTestStatus(eventDTO);
|
this.updatePerformanceTestStatus(eventDTO);
|
||||||
}
|
}
|
||||||
|
@ -516,7 +519,11 @@ public class TestPlanReportService {
|
||||||
|
|
||||||
public void updatePerformanceTestStatus(TestPlanLoadCaseEventDTO eventDTO) {
|
public void updatePerformanceTestStatus(TestPlanLoadCaseEventDTO eventDTO) {
|
||||||
List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(eventDTO.getReportId());
|
List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(eventDTO.getReportId());
|
||||||
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(), eventDTO.getTriggerMode());
|
if (StringUtils.equals(eventDTO.getTriggerMode(), ReportTriggerMode.SCHEDULE.name())) {
|
||||||
|
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(), eventDTO.getTriggerMode());
|
||||||
|
} else {
|
||||||
|
this.updateReport(testPlanReportId, ApiRunMode.JENKINS_PERFORMANCE_TEST.name(), eventDTO.getTriggerMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(List<String> testPlanReportIdList) {
|
public void delete(List<String> testPlanReportIdList) {
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ public class TestPlanService {
|
||||||
performanceRequest.setId(caseID);
|
performanceRequest.setId(caseID);
|
||||||
performanceRequest.setTestPlanLoadId(caseID);
|
performanceRequest.setTestPlanLoadId(caseID);
|
||||||
if (StringUtils.equals(ReportTriggerMode.API.name(), triggerMode)) {
|
if (StringUtils.equals(ReportTriggerMode.API.name(), triggerMode)) {
|
||||||
performanceRequest.setTriggerMode(ReportTriggerMode.API.name());
|
performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_API.name());
|
||||||
} else {
|
} else {
|
||||||
performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name());
|
performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name());
|
||||||
}
|
}
|
||||||
|
@ -1095,7 +1095,7 @@ public class TestPlanService {
|
||||||
|
|
||||||
if (!performaneReportIDList.isEmpty()) {
|
if (!performaneReportIDList.isEmpty()) {
|
||||||
//性能测试时保存性能测试报告ID,在结果返回时用于捕捉并进行
|
//性能测试时保存性能测试报告ID,在结果返回时用于捕捉并进行
|
||||||
testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDList, ReportTriggerMode.SCHEDULE.name());
|
testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDList, triggerMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1106,7 +1106,12 @@ public class TestPlanService {
|
||||||
String planCaseID = entry.getValue();
|
String planCaseID = entry.getValue();
|
||||||
ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID);
|
ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID);
|
||||||
//需要更新这里来保证PlanCase的状态能正常更改
|
//需要更新这里来保证PlanCase的状态能正常更改
|
||||||
apiTestCaseService.run(blobs, UUID.randomUUID().toString(), planReportId, testPlanID, ApiRunMode.SCHEDULE_API_PLAN.name());
|
if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) {
|
||||||
|
apiTestCaseService.run(blobs, UUID.randomUUID().toString(), planReportId, testPlanID, ApiRunMode.JENKINS_API_PLAN.name());
|
||||||
|
} else {
|
||||||
|
apiTestCaseService.run(blobs, UUID.randomUUID().toString(), planReportId, testPlanID, ApiRunMode.SCHEDULE_API_PLAN.name());
|
||||||
|
}
|
||||||
|
|
||||||
apiCaseIsExcuting = true;
|
apiCaseIsExcuting = true;
|
||||||
}
|
}
|
||||||
if (apiCaseIsExcuting) {
|
if (apiCaseIsExcuting) {
|
||||||
|
@ -1122,8 +1127,11 @@ public class TestPlanService {
|
||||||
scenarioRequest.setProjectId(projectID);
|
scenarioRequest.setProjectId(projectID);
|
||||||
if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) {
|
if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) {
|
||||||
scenarioRequest.setTriggerMode(ReportTriggerMode.API.name());
|
scenarioRequest.setTriggerMode(ReportTriggerMode.API.name());
|
||||||
|
scenarioRequest.setRunMode(ApiRunMode.JENKINS_SCENARIO_PLAN.name());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
|
scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
|
||||||
|
scenarioRequest.setRunMode(ApiRunMode.SCHEDULE_SCENARIO_PLAN.name());
|
||||||
}
|
}
|
||||||
scenarioRequest.setExecuteType(ExecuteType.Saved.name());
|
scenarioRequest.setExecuteType(ExecuteType.Saved.name());
|
||||||
Map<String, Map<String, String>> testPlanScenarioIdMap = new HashMap<>();
|
Map<String, Map<String, String>> testPlanScenarioIdMap = new HashMap<>();
|
||||||
|
@ -1131,7 +1139,7 @@ public class TestPlanService {
|
||||||
scenarioRequest.setTestPlanScenarioIDMap(testPlanScenarioIdMap);
|
scenarioRequest.setTestPlanScenarioIDMap(testPlanScenarioIdMap);
|
||||||
scenarioRequest.setReportUserID(userId);
|
scenarioRequest.setReportUserID(userId);
|
||||||
scenarioRequest.setTestPlanID(testPlanID);
|
scenarioRequest.setTestPlanID(testPlanID);
|
||||||
scenarioRequest.setRunMode(ApiRunMode.SCHEDULE_SCENARIO_PLAN.name());
|
|
||||||
scenarioRequest.setTestPlanReportId(planReportId);
|
scenarioRequest.setTestPlanReportId(planReportId);
|
||||||
RunModeConfig runModeConfig = JSONObject.parseObject(apiRunConfig, RunModeConfig.class);
|
RunModeConfig runModeConfig = JSONObject.parseObject(apiRunConfig, RunModeConfig.class);
|
||||||
scenarioRequest.setConfig(runModeConfig);
|
scenarioRequest.setConfig(runModeConfig);
|
||||||
|
|
Loading…
Reference in New Issue