fix(测试计划): 修复性能测试同步更新功能用例状态功能丢失,以及因测试计划报告重构导致的报告内部分用例不显示责任人的问题

修复性能测试同步更新功能用例状态功能丢失,以及因测试计划报告重构导致的报告内部分用例不显示责任人的问题
This commit is contained in:
song-tianyang 2023-03-09 11:31:21 +08:00 committed by 建国
parent 6c19b4985f
commit 1a4882008c
6 changed files with 41 additions and 11 deletions

View File

@ -718,7 +718,7 @@ public class TestPlanApiCaseService {
}
public List<TestPlanApiDTO> getFailureListByIds(Set<String> planApiCaseIds) {
return extTestPlanApiCaseMapper.getFailureListByIds(planApiCaseIds, null);
return buildCases(extTestPlanApiCaseMapper.getFailureListByIds(planApiCaseIds, null));
}
public List<ApiModuleDTO> getNodeByPlanId(List<String> projectIds, String planId, String protocol) {

View File

@ -994,7 +994,7 @@ public class TestPlanScenarioCaseService {
}
public List<TestPlanScenarioDTO> getListByIds(Set<String> ids) {
return extTestPlanScenarioCaseMapper.getFailureListByIds(ids, null);
return this.buildCases(extTestPlanScenarioCaseMapper.getFailureListByIds(ids, null));
}
public TestPlanEnvInfoDTO generateEnvironmentInfo(TestPlanReport testPlanReport) {

View File

@ -295,7 +295,7 @@
</select>
<select id="getCases" resultType="io.metersphere.plan.dto.TestPlanLoadCaseDTO">
select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id,
tplc.status ,tplc.create_user, tplc.load_report_id
tplc.status ,lt.create_user, tplc.load_report_id
from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id
<if test="status != null">
@ -306,7 +306,7 @@
<select id="getCasesByIds" resultType="io.metersphere.plan.dto.TestPlanLoadCaseDTO">
select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id,
tplc.create_user, tplc.load_report_id
lt.create_user, tplc.load_report_id
from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id
where tplc.id IN

View File

@ -1,24 +1,27 @@
package io.metersphere.plan.notice;
import io.metersphere.base.domain.LoadTestReport;
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
import io.metersphere.base.domain.TestPlanLoadCaseExample;
import io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs;
import io.metersphere.base.mapper.TestPlanLoadCaseMapper;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.constants.TestPlanLoadCaseStatus;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.consumer.LoadTestFinishEvent;
import io.metersphere.plan.service.PerfQueueService;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
@Component
@Transactional(rollbackFor = Exception.class)
public class LoadReportStatusEvent implements LoadTestFinishEvent {
@Resource
private ExtTestPlanLoadCaseMapper extTestPlanLoadCaseMapper;
private TestPlanLoadCaseMapper testPlanLoadCaseMapper;
private void updateLoadCaseStatus(LoadTestReport loadTestReport) {
String reportId = loadTestReport.getId();
@ -32,7 +35,20 @@ public class LoadReportStatusEvent implements LoadTestFinishEvent {
result = TestPlanLoadCaseStatus.success.name();
}
LogUtil.info("update plan load case status: " + result);
extTestPlanLoadCaseMapper.updateCaseStatus(reportId, result);
// 更新测试计划关联数据状态
TestPlanLoadCaseExample example = new TestPlanLoadCaseExample();
example.createCriteria().andIdEqualTo(loadTestReport.getTestId());
if (testPlanLoadCaseMapper.countByExample(example) > 0) {
TestPlanLoadCaseWithBLOBs loadCase = new TestPlanLoadCaseWithBLOBs();
loadCase.setId(loadTestReport.getTestId());
loadCase.setStatus(TestPlanLoadCaseStatus.success.name());
testPlanLoadCaseMapper.updateByPrimaryKeySelective(loadCase);
LogUtil.info("Execute test_plan_load_case OVER. Now send kafka to Test_Track. key:" + loadCase.getId());
PerfQueueService perfQueueService = CommonBeanFactory.getBean(PerfQueueService.class);
if (perfQueueService != null) {
perfQueueService.checkTestPlanLoadCaseExecOver(loadCase.getId(), null);
}
}
}
}

View File

@ -1180,6 +1180,21 @@ public class TestPlanReportService {
testPlanReportContentMapper.insert(content);
}
private Map<String, String> parseLoadCaseReportMap(String loadReportStructStr) {
Map<String, String> returnMap = new HashMap<>();
if (StringUtils.isNotEmpty(loadReportStructStr)) {
Map<String, String> caseReportList = null;
try {
caseReportList = JSON.parseMap(loadReportStructStr);
} catch (Exception ignored) {
}
if (MapUtils.isNotEmpty(caseReportList)) {
returnMap = caseReportList;
}
}
return returnMap;
}
private Map<String, String> parseCaseReportMap(String reportStructStr) {
Map<String, String> returnMap = new HashMap<>();
if (StringUtils.isNotEmpty(reportStructStr)) {
@ -1236,7 +1251,7 @@ public class TestPlanReportService {
//查找性能测试报告结果
if (DiscoveryUtil.hasService(MicroServiceName.PERFORMANCE_TEST)) {
LogUtil.info("测试计划报告【" + testPlanReportContentWithBLOBs.getTestPlanReportId() + "】开始查找性能测试报告结果");
Map<String, String> testPlanLoadCaseIdAndReportIdMap = this.parseCaseReportMap(testPlanReportContentWithBLOBs.getPlanLoadCaseReportStruct());
Map<String, String> testPlanLoadCaseIdAndReportIdMap = this.parseLoadCaseReportMap(testPlanReportContentWithBLOBs.getPlanLoadCaseReportStruct());
if (MapUtils.isNotEmpty(testPlanLoadCaseIdAndReportIdMap)) {
ApiPlanReportRequest request = new ApiPlanReportRequest();
request.setConfig(reportConfig);

View File

@ -890,7 +890,6 @@ public class TestPlanService {
LoggerUtil.info("预生成测试计划报告【" + reportInfoDTO.getTestPlanReport() != null ? reportInfoDTO.getTestPlanReport().getName() : StringUtils.EMPTY + "】计划报告ID[" + planReportId + "]");
List<TestPlanApiDTO> apiTestCases = null;
List<TestPlanScenarioDTO> scenarioCases = null;
List<TestPlanUiScenarioDTO> uiScenarios = null;