fix(测试跟踪): 测试计划性能测试用例执行完成状态未更新

--bug=1024523 --user=李玉号 【测试跟踪】测试计划-性能测试用例-执行完成-执行状态仍显示为run
https://www.tapd.cn/55049933/s/1351482
This commit is contained in:
shiziyuan9527 2023-03-16 15:15:28 +08:00 committed by lyh
parent b408e5ac9f
commit f9a916f47f
5 changed files with 20 additions and 15 deletions

View File

@ -347,7 +347,7 @@ export default {
"the data you checked does not detect a scheduled task", "the data you checked does not detect a scheduled task",
load_case: { load_case: {
case: "Load Case", case: "Load Case",
execution_status: "Execution status", execution_status: "Execution result",
report: "report", report: "report",
view_report: "View report", view_report: "View report",
unlink_in_bulk: "Unlink in bulk", unlink_in_bulk: "Unlink in bulk",

View File

@ -313,7 +313,7 @@ export default {
no_check_schedule_enabled: "您勾选的数据没有检测到定时任务", no_check_schedule_enabled: "您勾选的数据没有检测到定时任务",
load_case: { load_case: {
case: "性能用例", case: "性能用例",
execution_status: "执行状态", execution_status: "执行结果",
report: "报告", report: "报告",
view_report: "查看报告", view_report: "查看报告",
unlink_in_bulk: "批量取消关联", unlink_in_bulk: "批量取消关联",

View File

@ -312,7 +312,7 @@ export default {
no_check_schedule_enabled: "您勾選的數據沒有檢測到定時任務", no_check_schedule_enabled: "您勾選的數據沒有檢測到定時任務",
load_case: { load_case: {
case: "性能用例", case: "性能用例",
execution_status: "執行狀態", execution_status: "執行結果",
report: "報告", report: "報告",
view_report: "查看報告", view_report: "查看報告",
unlink_in_bulk: "批量取消關聯", unlink_in_bulk: "批量取消關聯",

View File

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

View File

@ -239,7 +239,7 @@ public class TestCaseSyncStatusUtil {
errorStatus = execResult; errorStatus = execResult;
} else if (StringUtils.equalsIgnoreCase(ApiReportStatus.FAKE_ERROR.name(), execResult.getExecResult())) { } else if (StringUtils.equalsIgnoreCase(ApiReportStatus.FAKE_ERROR.name(), execResult.getExecResult())) {
fakeErrorStatus = execResult; fakeErrorStatus = execResult;
} else if (StringUtils.equalsAnyIgnoreCase(execResult.getExecResult(), ApiReportStatus.FAKE_ERROR.name(), TestPlanStatus.Completed.name())) { } else if (StringUtils.equalsAnyIgnoreCase(execResult.getExecResult(), ApiReportStatus.SUCCESS.name(), TestPlanStatus.Completed.name())) {
successStatus = execResult; successStatus = execResult;
} else if (StringUtils.isEmpty(execResult.getExecResult())) { } else if (StringUtils.isEmpty(execResult.getExecResult())) {
hasNoneStatus = true; hasNoneStatus = true;