fix:jenkins调用测试报告不更新
This commit is contained in:
parent
6782432f5c
commit
fa5e5ae87c
|
@ -249,40 +249,6 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
reportTask.setExecutor(userName);
|
||||
reportTask.setExecutionTime(executionTime);
|
||||
reportTask.setExecutionEnvironment(name);
|
||||
} else if (StringUtils.equals(this.runMode, ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
apiDefinitionService.addResult(testResult);
|
||||
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.API_PLAN.name());
|
||||
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseService.getInfoJenkins(testResult.getTestId());
|
||||
ApiDefinitionExecResult apiResult = apiDefinitionExecResultService.getInfo(apiTestCaseWithBLOBs.getLastResultId());
|
||||
//环境
|
||||
TestPlanApiCase testPlanApiCase = testPlanApiCaseService.getInfo(testResult.getTestId(), debugReportId);
|
||||
String name = apiAutomationService.get(testPlanApiCase.getEnvironmentId()).getName();
|
||||
//时间
|
||||
Long time = apiTestCaseWithBLOBs.getCreateTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String executionTime = null;
|
||||
String time_ = String.valueOf(time);
|
||||
if (!time_.equals("null")) {
|
||||
executionTime = sdf.format(new Date(Long.parseLong(time_)));
|
||||
}
|
||||
|
||||
//执行人
|
||||
String userName = apiAutomationService.getUser(apiTestCaseWithBLOBs.getCreateUserId()).getName();
|
||||
|
||||
//报告内容
|
||||
reportTask = new ApiTestReportVariable();
|
||||
if (null != apiResult) {
|
||||
reportTask.setStatus(apiResult.getStatus());
|
||||
reportTask.setId(apiResult.getId());
|
||||
} else {
|
||||
reportTask.setStatus(testPlanApiCase.getStatus());
|
||||
reportTask.setId(testPlanApiCase.getId());
|
||||
}
|
||||
reportTask.setTriggerMode("API");
|
||||
reportTask.setName(apiTestCaseWithBLOBs.getName());
|
||||
reportTask.setExecutor(userName);
|
||||
reportTask.setExecutionTime(executionTime);
|
||||
reportTask.setExecutionEnvironment(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);
|
||||
|
@ -297,7 +263,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
}
|
||||
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());
|
||||
apiDefinitionExecResultService.saveApiResultByScheduleTask(testResult, ApiRunMode.JENKINS_API_PLAN.name());
|
||||
List<String> testPlanReportIdList = new ArrayList<>();
|
||||
testPlanReportIdList.add(debugReportId);
|
||||
for (String testPlanReportId : testPlanReportIdList) { // 更新每个测试计划的状态
|
||||
|
|
|
@ -110,7 +110,7 @@ public class ApiDefinitionExecResultService {
|
|||
*/
|
||||
public void saveApiResultByScheduleTask(TestResult result, String type) {
|
||||
String saveResultType = type;
|
||||
if (StringUtils.equalsAny(ApiRunMode.SCHEDULE_API_PLAN.name(), saveResultType)) {
|
||||
if (StringUtils.equalsAny(saveResultType, ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
saveResultType = ApiRunMode.API_PLAN.name();
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class ApiDefinitionExecResultService {
|
|||
saveResult.setStatus(status);
|
||||
|
||||
String userID = null;
|
||||
if (StringUtils.equals(type, ApiRunMode.SCHEDULE_API_PLAN.name())) {
|
||||
if (StringUtils.equalsAny(type, ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
TestPlanApiCase apiCase = testPlanApiCaseService.getById(item.getName());
|
||||
String scheduleCreateUser = testPlanService.findScheduleCreateUserById(apiCase.getTestPlanId());
|
||||
userID = scheduleCreateUser;
|
||||
|
|
|
@ -33,7 +33,8 @@ public class LoadReportStatusEvent implements LoadTestFinishEvent {
|
|||
@Override
|
||||
public void execute(LoadTestReport loadTestReport) {
|
||||
if (StringUtils.equals(ReportTriggerMode.CASE.name(), loadTestReport.getTriggerMode())
|
||||
|| StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(), loadTestReport.getTriggerMode())) {
|
||||
|| StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(), loadTestReport.getTriggerMode())
|
||||
|| StringUtils.equals(ReportTriggerMode.TEST_PLAN_API.name(), loadTestReport.getTriggerMode())) {
|
||||
if (StringUtils.equalsAny(loadTestReport.getStatus(),
|
||||
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
|
||||
updateLoadCaseStatus(loadTestReport);
|
||||
|
|
|
@ -248,7 +248,8 @@ public class TestPlanReportService {
|
|||
String issuesInfo = null;
|
||||
|
||||
//因为接口案例的定时任务是单个案例开线程运行, 所以要检查是否都执行完成。全部执行完成时才会进行统一整理
|
||||
if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name()) && StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name())
|
||||
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
List<String> statusList = extTestPlanApiCaseMapper.getStatusByTestPlanId(testPlan.getId());
|
||||
for (String status : statusList) {
|
||||
if (status == null) {
|
||||
|
@ -256,6 +257,7 @@ public class TestPlanReportService {
|
|||
}
|
||||
}
|
||||
} else if (StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(), triggerMode)) {
|
||||
|
||||
}
|
||||
|
||||
testPlanReport.setEndTime(System.currentTimeMillis());
|
||||
|
@ -288,7 +290,7 @@ public class TestPlanReportService {
|
|||
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
testPlanReport.setIsApiCaseExecuting(false);
|
||||
} else if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name())
|
||||
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
||||
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
|
||||
testPlanReport.setIsScenarioExecuting(false);
|
||||
} else if (StringUtils.equalsAny(triggerMode, ReportTriggerMode.SCHEDULE.name(), ReportTriggerMode.API.name())
|
||||
&& StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(), ApiRunMode.JENKINS_PERFORMANCE_TEST.name())) {
|
||||
|
@ -567,10 +569,10 @@ public class TestPlanReportService {
|
|||
|
||||
public void updatePerformanceTestStatus(TestPlanLoadCaseEventDTO eventDTO) {
|
||||
List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(eventDTO.getReportId());
|
||||
if (StringUtils.equals(eventDTO.getTriggerMode(), ReportTriggerMode.SCHEDULE.name())) {
|
||||
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(), eventDTO.getTriggerMode());
|
||||
} else {
|
||||
if (StringUtils.equals(eventDTO.getTriggerMode(), ReportTriggerMode.API.name())) {
|
||||
this.updateReport(testPlanReportId, ApiRunMode.JENKINS_PERFORMANCE_TEST.name(), eventDTO.getTriggerMode());
|
||||
} else {
|
||||
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(), eventDTO.getTriggerMode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<span>
|
||||
<span v-if="triggerMode === 'TEST_PLAN_API'">{{ $t('commons.trigger_mode.api') }}</span>
|
||||
<span v-if="triggerMode === 'MANUAL'">{{$t('commons.trigger_mode.manual')}}</span>
|
||||
<span v-if="triggerMode === 'SCHEDULE'">{{$t('commons.trigger_mode.schedule')}}</span>
|
||||
<span v-if="triggerMode === 'TEST_PLAN_SCHEDULE'">{{$t('commons.trigger_mode.schedule')}}</span>
|
||||
|
|
Loading…
Reference in New Issue