fix (接口自动化): 修复批量执行用例失败问题,修复日志关注人显示问题

--bug=1006207 --user=赵勇 【接口定义】批量执行... https://www.tapd.cn/55049933/s/1040127
--bug=1006054 --user=赵勇 【测试用例】添加/更新... https://www.tapd.cn/55049933/s/1040168
This commit is contained in:
fit2-zhao 2021-08-25 19:37:48 +08:00 committed by fit2-zhao
parent 73c398b1c8
commit 34cbd83437
3 changed files with 19 additions and 14 deletions

View File

@ -620,16 +620,12 @@ public class ApiTestCaseService {
return ids;
}
private ApiDefinitionExecResult addResult(String id, String status, ApiDefinitionExecResultMapper batchMapper) {
private ApiDefinitionExecResult addResult(String id, String status) {
ApiDefinitionExecResult apiResult = new ApiDefinitionExecResult();
apiResult.setId(UUID.randomUUID().toString());
apiResult.setCreateTime(System.currentTimeMillis());
apiResult.setStartTime(System.currentTimeMillis());
apiResult.setEndTime(System.currentTimeMillis());
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(id);
if (caseWithBLOBs != null) {
apiResult.setName(caseWithBLOBs.getName());
}
apiResult.setTriggerMode(TriggerMode.BATCH.name());
apiResult.setActuator("LOCAL");
apiResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
@ -637,11 +633,6 @@ public class ApiTestCaseService {
apiResult.setStartTime(System.currentTimeMillis());
apiResult.setType(ApiRunMode.DEFINITION.name());
apiResult.setStatus(status);
batchMapper.insert(apiResult);
caseWithBLOBs.setLastResultId(apiResult.getId());
caseWithBLOBs.setUpdateTime(System.currentTimeMillis());
caseWithBLOBs.setStatus(APITestStatus.Running.name());
apiTestCaseMapper.updateByPrimaryKey(caseWithBLOBs);
return apiResult;
}
@ -651,10 +642,20 @@ public class ApiTestCaseService {
Map<String, ApiDefinitionExecResult> executeQueue = new HashMap<>();
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiDefinitionExecResultMapper batchMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class);
request.getIds().forEach(testCaseId -> {
ApiDefinitionExecResult report = addResult(testCaseId, APITestStatus.Running.name(), batchMapper);
for (String testCaseId : request.getIds()) {
ApiDefinitionExecResult report = addResult(testCaseId, APITestStatus.Running.name());
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(testCaseId);
if (caseWithBLOBs != null) {
report.setName(caseWithBLOBs.getName());
caseWithBLOBs.setLastResultId(report.getId());
caseWithBLOBs.setUpdateTime(System.currentTimeMillis());
caseWithBLOBs.setStatus(APITestStatus.Running.name());
apiTestCaseMapper.updateByPrimaryKey(caseWithBLOBs);
}
batchMapper.insert(report);
executeQueue.put(testCaseId, report);
});
}
sqlSession.flushStatements();
for (String caseId : executeQueue.keySet()) {
RunCaseRequest runCaseRequest = new RunCaseRequest();

View File

@ -22,6 +22,7 @@ public class DefinitionReference {
definitionColumns.put("request", "请求参数");
definitionColumns.put("response", "返回参数");
definitionColumns.put("description", "描述");
definitionColumns.put("followPeople", "关注人");
// 需要深度对比的字段可以支持多个req1,req2
definitionColumns.put("ms-dff-col", "request,response,tags");
@ -33,6 +34,8 @@ public class DefinitionReference {
caseColumns.put("tags", "标签");
caseColumns.put("description", "描述");
caseColumns.put("request", "请求参数");
caseColumns.put("followPeople", "关注人");
// 深度对比字段
caseColumns.put("ms-dff-col", "request,tags");

View File

@ -339,7 +339,8 @@
close() {
this.formData = {
file: undefined,
swaggerUrl: ''
swaggerUrl: '',
modeId: this.formData.modeId,
};
this.fileList = [];
removeGoBackListener(this.close);