fix(测试跟踪): 修复任务中心状态和执行状态不一致问题。

This commit is contained in:
fit2-zhao 2021-06-30 11:13:59 +08:00 committed by fit2-zhao
parent 5131f04e76
commit a971d3fba3
4 changed files with 41 additions and 16 deletions

View File

@ -7,6 +7,7 @@ import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ApiDefinitionMapper;
import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.TestCaseReviewApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.DelimiterConstants;
@ -46,6 +47,8 @@ public class ApiDefinitionExecResultService {
private TestCaseReviewApiCaseService testCaseReviewApiCaseService;
@Resource
private ApiDefinitionMapper apiDefinitionMapper;
@Resource
TestCaseReviewApiCaseMapper testCaseReviewApiCaseMapper;
@Resource
SqlSessionFactory sqlSessionFactory;
@ -66,18 +69,20 @@ public class ApiDefinitionExecResultService {
boolean saved = true;
if (saveResult == null) {
saveResult = new ApiDefinitionExecResult();
saveResult.setId(UUID.randomUUID().toString());
saveResult.setId(result.getTestId());
saveResult.setActuator("LOCAL");
saveResult.setName(item.getName());
saveResult.setTriggerMode(triggerMode);
saveResult.setType(type);
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(item.getName());
if (apiDefinitionWithBLOBs != null) {
saveResult.setName(apiDefinitionWithBLOBs.getName());
} else {
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(item.getName());
if (caseWithBLOBs != null) {
saveResult.setName(caseWithBLOBs.getName());
if (!StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(item.getName());
if (apiDefinition != null) {
saveResult.setName(apiDefinition.getName());
} else {
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(item.getName());
if (caseWithBLOBs != null) {
saveResult.setName(caseWithBLOBs.getName());
}
}
}
if (StringUtils.isNotEmpty(result.getUserId())) {
@ -98,8 +103,22 @@ public class ApiDefinitionExecResultService {
saveResult.setEndTime(item.getResponseResult().getResponseTime());
saveResult.setStatus(status);
if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
testPlanApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
testCaseReviewApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
TestPlanApiCase testPlanApiCase = testPlanApiCaseService.getById(item.getName());
String id = null;
if (testPlanApiCase != null) {
testPlanApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
id = testPlanApiCase.getApiCaseId();
}
TestCaseReviewApiCase testCaseReviewApiCase = testCaseReviewApiCaseMapper.selectByPrimaryKey(item.getName());
if (testCaseReviewApiCase != null) {
testCaseReviewApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
id = testCaseReviewApiCase.getApiCaseId();
}
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(id);
if (caseWithBLOBs != null) {
saveResult.setName(caseWithBLOBs.getName());
saveResult.setResourceId(id);
}
}
// 清空上次执行结果的内容只保留当前最新一条内容

View File

@ -339,7 +339,7 @@ public class TestPlanApiCaseService {
if (caseWithBLOBs != null) {
apiResult.setName(caseWithBLOBs.getName());
}
apiResult.setTriggerMode(TriggerMode.MANUAL.name());
apiResult.setTriggerMode(TriggerMode.BATCH.name());
apiResult.setActuator("LOCAL");
if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) {
apiResult.setActuator(request.getConfig().getResourcePoolId());
@ -368,8 +368,8 @@ public class TestPlanApiCaseService {
public void run() {
for (TestPlanApiCase key : planApiCases) {
try {
RunModeDataDTO modeDataDTO = null;
if (StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
RunModeDataDTO modeDataDTO;
if (request.getConfig()!= null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
modeDataDTO = new RunModeDataDTO(key.getId(), UUID.randomUUID().toString());
} else {
// 生成报告和HashTree

View File

@ -39,7 +39,7 @@ import ThreadGroup from "./jmeter/components/thread-group";
if (this.debug) {
url = "/api/definition/report/get/" + this.runId + "/" + "debug";
} else {
url = "/api/definition/report/get/" + this.runId + "/" + "run";
url = "/api/definition/report/get/" + this.runId;
}
this.$get(url, response => {
if (response.data) {

View File

@ -45,7 +45,7 @@
<span>执行器{{ item.actuator }} {{ item.executor }} {{ item.executionTime | timestampFormatDate }} {{ getMode(item.triggerMode) }}</span><br/>
<el-row>
<el-col :span="20">
<el-progress :percentage="getPercentage(item.executionStatus)"/>
<el-progress :percentage="getPercentage(item.executionStatus)" :format="format"/>
</el-col>
<el-col :span="4">
<span>{{ item.executionStatus }}</span>
@ -110,6 +110,9 @@ export default {
color: String
},
methods: {
format(item) {
return '';
},
showTaskCenter() {
this.init();
this.taskVisible = true;
@ -127,7 +130,6 @@ export default {
return 100;
}
}
//return Math.round(Math.random() * 80 + 20);
return 60;
},
showReport(row, env) {
@ -271,6 +273,10 @@ export default {
border-color: #783887;
}
/deep/ .el-progress-bar {
padding-right: 20px;
}
/deep/ .el-menu-item {
padding-left: 0;
padding-right: 0;