fix(UI自动化): 修复定时删除UI报告失效问题
--bug=1017072 --user=刘瑶 【UI测试】定时删除报告失败 https://www.tapd.cn/55049933/s/1248763
This commit is contained in:
parent
d425a43cd0
commit
1051ab591a
|
@ -56,6 +56,14 @@ public enum ProjectApplicationType {
|
||||||
* 清理时间配置 (Y|M|D)
|
* 清理时间配置 (Y|M|D)
|
||||||
*/
|
*/
|
||||||
CLEAN_API_REPORT_EXPR,
|
CLEAN_API_REPORT_EXPR,
|
||||||
|
/**
|
||||||
|
* 是否开启定时清理接口测试报告
|
||||||
|
*/
|
||||||
|
CLEAN_UI_REPORT,
|
||||||
|
/**
|
||||||
|
* 清理时间配置 (Y|M|D)
|
||||||
|
*/
|
||||||
|
CLEAN_UI_REPORT_EXPR,
|
||||||
/**
|
/**
|
||||||
* 是否开启定时清理接口测试报告
|
* 是否开启定时清理接口测试报告
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,6 +19,8 @@ public class AddProjectRequest extends Project {
|
||||||
private String cleanTrackReportExpr;
|
private String cleanTrackReportExpr;
|
||||||
private Boolean cleanApiReport;
|
private Boolean cleanApiReport;
|
||||||
private String cleanApiReportExpr;
|
private String cleanApiReportExpr;
|
||||||
|
private Boolean cleanUiReport;
|
||||||
|
private String cleanUiReportExpr;
|
||||||
private Boolean cleanLoadReport;
|
private Boolean cleanLoadReport;
|
||||||
private String cleanLoadReportExpr;
|
private String cleanLoadReportExpr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class ProjectApplicationService {
|
||||||
this.doHandleMockTcpPort(projectId, value);
|
this.doHandleMockTcpPort(projectId, value);
|
||||||
} else if (StringUtils.equals(type, ProjectApplicationType.CLEAN_TRACK_REPORT.name())
|
} else if (StringUtils.equals(type, ProjectApplicationType.CLEAN_TRACK_REPORT.name())
|
||||||
|| StringUtils.equals(type, ProjectApplicationType.CLEAN_API_REPORT.name())
|
|| StringUtils.equals(type, ProjectApplicationType.CLEAN_API_REPORT.name())
|
||||||
|
|| StringUtils.equals(type, ProjectApplicationType.CLEAN_UI_REPORT.name())
|
||||||
|| StringUtils.equals(type, ProjectApplicationType.CLEAN_LOAD_REPORT.name())) {
|
|| StringUtils.equals(type, ProjectApplicationType.CLEAN_LOAD_REPORT.name())) {
|
||||||
this.doHandleCleanUp(projectId, type, value);
|
this.doHandleCleanUp(projectId, type, value);
|
||||||
}
|
}
|
||||||
|
@ -81,11 +82,14 @@ public class ProjectApplicationService {
|
||||||
config.setCleanApiReport(cleanUp);
|
config.setCleanApiReport(cleanUp);
|
||||||
} else if (StringUtils.equals(type, ProjectApplicationType.CLEAN_LOAD_REPORT.name())) {
|
} else if (StringUtils.equals(type, ProjectApplicationType.CLEAN_LOAD_REPORT.name())) {
|
||||||
config.setCleanLoadReport(cleanUp);
|
config.setCleanLoadReport(cleanUp);
|
||||||
|
} else if(StringUtils.equals(type, ProjectApplicationType.CLEAN_UI_REPORT.name())){
|
||||||
|
config.setCleanUiReport(cleanUp);
|
||||||
}
|
}
|
||||||
// 根据这三个状态判断定时清理任务是否开启
|
// 根据这三个状态判断定时清理任务是否开启
|
||||||
request.setCleanTrackReport(config.getCleanTrackReport());
|
request.setCleanTrackReport(config.getCleanTrackReport());
|
||||||
request.setCleanApiReport(config.getCleanApiReport());
|
request.setCleanApiReport(config.getCleanApiReport());
|
||||||
request.setCleanLoadReport(config.getCleanLoadReport());
|
request.setCleanLoadReport(config.getCleanLoadReport());
|
||||||
|
request.setCleanUiReport(config.getCleanUiReport());
|
||||||
}
|
}
|
||||||
projectService.addOrUpdateCleanUpSchedule(request);
|
projectService.addOrUpdateCleanUpSchedule(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import io.metersphere.api.dto.DeleteAPITestRequest;
|
import io.metersphere.api.dto.DeleteAPITestRequest;
|
||||||
import io.metersphere.api.dto.QueryAPITestRequest;
|
import io.metersphere.api.dto.QueryAPITestRequest;
|
||||||
import io.metersphere.api.dto.automation.ExecuteType;
|
import io.metersphere.api.dto.automation.ExecuteType;
|
||||||
|
@ -507,14 +508,16 @@ public class ProjectService {
|
||||||
Boolean cleanTrackReport = project.getCleanTrackReport();
|
Boolean cleanTrackReport = project.getCleanTrackReport();
|
||||||
Boolean cleanApiReport = project.getCleanApiReport();
|
Boolean cleanApiReport = project.getCleanApiReport();
|
||||||
Boolean cleanLoadReport = project.getCleanLoadReport();
|
Boolean cleanLoadReport = project.getCleanLoadReport();
|
||||||
LogUtil.info("clean track/api/performance report: " + cleanTrackReport + "/" + cleanApiReport + "/" + cleanLoadReport);
|
Boolean cleanUiReport = project.getCleanUiReport();
|
||||||
|
LogUtil.info("clean track/api/performance report: " + cleanTrackReport + "/" + cleanApiReport + "/" + cleanLoadReport + "/" + cleanUiReport);
|
||||||
// 未设置则不更新定时任务
|
// 未设置则不更新定时任务
|
||||||
if (cleanTrackReport == null && cleanApiReport == null && cleanLoadReport == null) {
|
if (cleanTrackReport == null && cleanApiReport == null && cleanLoadReport == null && cleanUiReport == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String projectId = project.getId();
|
String projectId = project.getId();
|
||||||
Boolean enable = BooleanUtils.isTrue(cleanTrackReport) ||
|
Boolean enable = BooleanUtils.isTrue(cleanTrackReport) ||
|
||||||
BooleanUtils.isTrue(cleanApiReport) ||
|
BooleanUtils.isTrue(cleanApiReport) ||
|
||||||
|
BooleanUtils.isTrue(cleanUiReport) ||
|
||||||
BooleanUtils.isTrue(cleanLoadReport);
|
BooleanUtils.isTrue(cleanLoadReport);
|
||||||
Schedule schedule = scheduleService.getScheduleByResource(projectId, ScheduleGroup.CLEAN_UP_REPORT.name());
|
Schedule schedule = scheduleService.getScheduleByResource(projectId, ScheduleGroup.CLEAN_UP_REPORT.name());
|
||||||
if (schedule != null && StringUtils.isNotBlank(schedule.getId())) {
|
if (schedule != null && StringUtils.isNotBlank(schedule.getId())) {
|
||||||
|
@ -1051,14 +1054,12 @@ public class ProjectService {
|
||||||
ApiScenarioReportExample example = new ApiScenarioReportExample();
|
ApiScenarioReportExample example = new ApiScenarioReportExample();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andProjectIdEqualTo(projectId)
|
.andProjectIdEqualTo(projectId)
|
||||||
.andCreateTimeLessThan(backupTime).andReportTypeEqualTo(ReportTypeConstants.UI_INDEPENDENT.name())
|
.andCreateTimeLessThan(backupTime).andReportTypeIn(Lists.newArrayList(ReportTypeConstants.UI_INDEPENDENT.name(),
|
||||||
.andExecuteTypeEqualTo(ExecuteType.Debug.name());
|
ReportTypeConstants.UI_INTEGRATED.name()))
|
||||||
|
.andExecuteTypeIn(Lists.newArrayList(ExecuteType.Debug.name(), ExecuteType.Saved.name()));
|
||||||
List<ApiScenarioReport> apiScenarioReports = apiScenarioReportMapper.selectByExample(example);
|
List<ApiScenarioReport> apiScenarioReports = apiScenarioReportMapper.selectByExample(example);
|
||||||
// 删除调试报告的截图
|
// 删除调试报告的截图
|
||||||
for (ApiScenarioReport apiScenarioReport : apiScenarioReports) {
|
for (ApiScenarioReport apiScenarioReport : apiScenarioReports) {
|
||||||
if (FileUtil.deleteDir(new File(FileUtils.UI_IMAGE_DIR + "/" + apiScenarioReport.getId()))) {
|
|
||||||
LogUtil.info("删除 UI 调试报告截图成功,报告 ID 为 :" + apiScenarioReport.getId());
|
|
||||||
|
|
||||||
// 删除调试报告
|
// 删除调试报告
|
||||||
ApiScenarioReportResultExample resultExample = new ApiScenarioReportResultExample();
|
ApiScenarioReportResultExample resultExample = new ApiScenarioReportResultExample();
|
||||||
resultExample.createCriteria().andReportIdEqualTo(apiScenarioReport.getId());
|
resultExample.createCriteria().andReportIdEqualTo(apiScenarioReport.getId());
|
||||||
|
@ -1069,6 +1070,9 @@ public class ProjectService {
|
||||||
apiScenarioReportResultMapper.deleteByExample(resultExample);
|
apiScenarioReportResultMapper.deleteByExample(resultExample);
|
||||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||||
apiScenarioReportMapper.deleteByPrimaryKey(apiScenarioReport.getId());
|
apiScenarioReportMapper.deleteByPrimaryKey(apiScenarioReport.getId());
|
||||||
|
//如果有截图数据则删除
|
||||||
|
if (FileUtil.deleteDir(new File(FileUtils.UI_IMAGE_DIR + "/" + apiScenarioReport.getId()))) {
|
||||||
|
LogUtil.info("删除 UI 调试报告截图成功,报告 ID 为 :" + apiScenarioReport.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 29d59730956b073e36aeac3b957211959dc91427
|
Subproject commit a7499a636342d4b58bb799c45468eb1245ce6e6b
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8fae61212eea4f7b2a3d22a8b78666185d43d24f
|
Subproject commit 90ebdc95e77e628581e2ac083568a3e543cb7c00
|
Loading…
Reference in New Issue