fix(测试跟踪): 修复任务中心状态和执行状态不一致问题。
This commit is contained in:
parent
5131f04e76
commit
a971d3fba3
|
@ -7,6 +7,7 @@ import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||||
|
import io.metersphere.base.mapper.TestCaseReviewApiCaseMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||||
import io.metersphere.commons.constants.ApiRunMode;
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
import io.metersphere.commons.constants.DelimiterConstants;
|
import io.metersphere.commons.constants.DelimiterConstants;
|
||||||
|
@ -46,6 +47,8 @@ public class ApiDefinitionExecResultService {
|
||||||
private TestCaseReviewApiCaseService testCaseReviewApiCaseService;
|
private TestCaseReviewApiCaseService testCaseReviewApiCaseService;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionMapper apiDefinitionMapper;
|
private ApiDefinitionMapper apiDefinitionMapper;
|
||||||
|
@Resource
|
||||||
|
TestCaseReviewApiCaseMapper testCaseReviewApiCaseMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
SqlSessionFactory sqlSessionFactory;
|
SqlSessionFactory sqlSessionFactory;
|
||||||
|
@ -66,18 +69,20 @@ public class ApiDefinitionExecResultService {
|
||||||
boolean saved = true;
|
boolean saved = true;
|
||||||
if (saveResult == null) {
|
if (saveResult == null) {
|
||||||
saveResult = new ApiDefinitionExecResult();
|
saveResult = new ApiDefinitionExecResult();
|
||||||
saveResult.setId(UUID.randomUUID().toString());
|
saveResult.setId(result.getTestId());
|
||||||
saveResult.setActuator("LOCAL");
|
saveResult.setActuator("LOCAL");
|
||||||
saveResult.setName(item.getName());
|
saveResult.setName(item.getName());
|
||||||
saveResult.setTriggerMode(triggerMode);
|
saveResult.setTriggerMode(triggerMode);
|
||||||
saveResult.setType(type);
|
saveResult.setType(type);
|
||||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(item.getName());
|
if (!StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
|
||||||
if (apiDefinitionWithBLOBs != null) {
|
ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(item.getName());
|
||||||
saveResult.setName(apiDefinitionWithBLOBs.getName());
|
if (apiDefinition != null) {
|
||||||
} else {
|
saveResult.setName(apiDefinition.getName());
|
||||||
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(item.getName());
|
} else {
|
||||||
if (caseWithBLOBs != null) {
|
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(item.getName());
|
||||||
saveResult.setName(caseWithBLOBs.getName());
|
if (caseWithBLOBs != null) {
|
||||||
|
saveResult.setName(caseWithBLOBs.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(result.getUserId())) {
|
if (StringUtils.isNotEmpty(result.getUserId())) {
|
||||||
|
@ -98,8 +103,22 @@ public class ApiDefinitionExecResultService {
|
||||||
saveResult.setEndTime(item.getResponseResult().getResponseTime());
|
saveResult.setEndTime(item.getResponseResult().getResponseTime());
|
||||||
saveResult.setStatus(status);
|
saveResult.setStatus(status);
|
||||||
if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
|
if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
|
||||||
testPlanApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
|
TestPlanApiCase testPlanApiCase = testPlanApiCaseService.getById(item.getName());
|
||||||
testCaseReviewApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空上次执行结果的内容,只保留当前最新一条内容
|
// 清空上次执行结果的内容,只保留当前最新一条内容
|
||||||
|
|
|
@ -339,7 +339,7 @@ public class TestPlanApiCaseService {
|
||||||
if (caseWithBLOBs != null) {
|
if (caseWithBLOBs != null) {
|
||||||
apiResult.setName(caseWithBLOBs.getName());
|
apiResult.setName(caseWithBLOBs.getName());
|
||||||
}
|
}
|
||||||
apiResult.setTriggerMode(TriggerMode.MANUAL.name());
|
apiResult.setTriggerMode(TriggerMode.BATCH.name());
|
||||||
apiResult.setActuator("LOCAL");
|
apiResult.setActuator("LOCAL");
|
||||||
if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) {
|
if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) {
|
||||||
apiResult.setActuator(request.getConfig().getResourcePoolId());
|
apiResult.setActuator(request.getConfig().getResourcePoolId());
|
||||||
|
@ -368,8 +368,8 @@ public class TestPlanApiCaseService {
|
||||||
public void run() {
|
public void run() {
|
||||||
for (TestPlanApiCase key : planApiCases) {
|
for (TestPlanApiCase key : planApiCases) {
|
||||||
try {
|
try {
|
||||||
RunModeDataDTO modeDataDTO = null;
|
RunModeDataDTO modeDataDTO;
|
||||||
if (StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
|
if (request.getConfig()!= null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
|
||||||
modeDataDTO = new RunModeDataDTO(key.getId(), UUID.randomUUID().toString());
|
modeDataDTO = new RunModeDataDTO(key.getId(), UUID.randomUUID().toString());
|
||||||
} else {
|
} else {
|
||||||
// 生成报告和HashTree
|
// 生成报告和HashTree
|
||||||
|
|
|
@ -39,7 +39,7 @@ import ThreadGroup from "./jmeter/components/thread-group";
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
url = "/api/definition/report/get/" + this.runId + "/" + "debug";
|
url = "/api/definition/report/get/" + this.runId + "/" + "debug";
|
||||||
} else {
|
} else {
|
||||||
url = "/api/definition/report/get/" + this.runId + "/" + "run";
|
url = "/api/definition/report/get/" + this.runId;
|
||||||
}
|
}
|
||||||
this.$get(url, response => {
|
this.$get(url, response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<span>执行器:{{ item.actuator }} 由 {{ item.executor }} {{ item.executionTime | timestampFormatDate }} {{ getMode(item.triggerMode) }}</span><br/>
|
<span>执行器:{{ item.actuator }} 由 {{ item.executor }} {{ item.executionTime | timestampFormatDate }} {{ getMode(item.triggerMode) }}</span><br/>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="20">
|
<el-col :span="20">
|
||||||
<el-progress :percentage="getPercentage(item.executionStatus)"/>
|
<el-progress :percentage="getPercentage(item.executionStatus)" :format="format"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<span>{{ item.executionStatus }}</span>
|
<span>{{ item.executionStatus }}</span>
|
||||||
|
@ -110,6 +110,9 @@ export default {
|
||||||
color: String
|
color: String
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
format(item) {
|
||||||
|
return '';
|
||||||
|
},
|
||||||
showTaskCenter() {
|
showTaskCenter() {
|
||||||
this.init();
|
this.init();
|
||||||
this.taskVisible = true;
|
this.taskVisible = true;
|
||||||
|
@ -127,7 +130,6 @@ export default {
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return Math.round(Math.random() * 80 + 20);
|
|
||||||
return 60;
|
return 60;
|
||||||
},
|
},
|
||||||
showReport(row, env) {
|
showReport(row, env) {
|
||||||
|
@ -271,6 +273,10 @@ export default {
|
||||||
border-color: #783887;
|
border-color: #783887;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/deep/ .el-progress-bar {
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
/deep/ .el-menu-item {
|
/deep/ .el-menu-item {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
|
|
Loading…
Reference in New Issue