fix(测试跟踪): 修复测试计划中批量执行用例误报接口状态错误问题
--bug=1020052 --user=赵勇 【测试跟踪】测试计划中批量执行用例,任务中心 - 接口用例的误报状态没显示 https://www.tapd.cn/55049933/s/1301288
This commit is contained in:
parent
41990ea2c4
commit
f241aafb3d
|
@ -20,7 +20,6 @@ import io.metersphere.dto.ResultDTO;
|
|||
import io.metersphere.notice.sender.NoticeModel;
|
||||
import io.metersphere.notice.service.NoticeSendService;
|
||||
import io.metersphere.service.ServiceUtils;
|
||||
import io.metersphere.service.plan.remote.TestPlanService;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import org.apache.commons.beanutils.BeanMap;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
@ -32,7 +31,6 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
|||
import org.mybatis.spring.SqlSessionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -63,8 +61,6 @@ public class ApiDefinitionExecResultService {
|
|||
@Resource
|
||||
private ApiCaseExecutionInfoService apiCaseExecutionInfoService;
|
||||
@Resource
|
||||
private TestPlanService testPlanService;
|
||||
@Resource
|
||||
private ExtApiTestCaseMapper extApiTestCaseMapper;
|
||||
|
||||
/**
|
||||
|
@ -283,23 +279,14 @@ public class ApiDefinitionExecResultService {
|
|||
for (RequestResult item : dto.getRequestResults()) {
|
||||
LoggerUtil.info("执行结果【 " + item.getName() + " 】入库存储");
|
||||
if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
|
||||
//对响应内容进行进一步解析和处理。如果有附加信息(比如误报库信息),则根据附加信息内的数据进行其他判读
|
||||
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(item);
|
||||
|
||||
ApiDefinitionExecResult reportResult = this.editResult(item, dto.getReportId(), dto.getConsole(), dto.getRunMode(), dto.getTestId(), null);
|
||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("userId")) {
|
||||
reportResult.setUserId(String.valueOf(dto.getExtendedParameters().get("userId")));
|
||||
}
|
||||
String status = item.isSuccess() ? ApiReportStatus.SUCCESS.name() : ApiReportStatus.ERROR.name();
|
||||
String triggerMode = StringUtils.EMPTY;
|
||||
if (reportResult != null) {
|
||||
status = reportResult.getStatus();
|
||||
triggerMode = reportResult.getTriggerMode();
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(expandDTO.getStatus())) {
|
||||
status = expandDTO.getStatus();
|
||||
}
|
||||
if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
TestPlanApiCase apiCase = testPlanApiCaseMapper.selectByPrimaryKey(dto.getTestId());
|
||||
if (apiCase != null) {
|
||||
|
@ -307,9 +294,9 @@ public class ApiDefinitionExecResultService {
|
|||
String projectId = dto.getExtendedParameters().get("projectId").toString();
|
||||
ApiDefinition apiDefinition = extApiTestCaseMapper.selectApiBasicInfoByCaseId(apiCase.getId());
|
||||
String version = apiDefinition == null ? "" : apiDefinition.getVersionId();
|
||||
apiCaseExecutionInfoService.insertExecutionInfo(apiCase.getId(), status, triggerMode, projectId, ExecutionExecuteTypeEnum.TEST_PLAN.name(), version);
|
||||
apiCaseExecutionInfoService.insertExecutionInfo(apiCase.getId(), reportResult.getStatus(), triggerMode, projectId, ExecutionExecuteTypeEnum.TEST_PLAN.name(), version);
|
||||
}
|
||||
apiCase.setStatus(status);
|
||||
apiCase.setStatus(reportResult.getStatus());
|
||||
apiCase.setUpdateTime(System.currentTimeMillis());
|
||||
testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase);
|
||||
|
||||
|
@ -320,28 +307,13 @@ public class ApiDefinitionExecResultService {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
this.setExecResult(dto.getTestId(), status, item.getStartTime());
|
||||
this.setExecResult(dto.getTestId(), reportResult.getStatus(), item.getStartTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteByResourceId(String resourceId) {
|
||||
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId);
|
||||
apiDefinitionExecResultMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public void deleteByResourceIds(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample();
|
||||
example.createCriteria().andResourceIdIn(ids);
|
||||
apiDefinitionExecResultMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public long countByTestCaseIDInProjectAndExecutedInThisWeek(String projectId, String version) {
|
||||
Date firstTime = DateUtils.getWeedFirstTimeAndLastTime(new Date()).get("firstTime");
|
||||
Date lastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date()).get("lastTime");
|
||||
|
@ -352,11 +324,6 @@ public class ApiDefinitionExecResultService {
|
|||
}
|
||||
}
|
||||
|
||||
public long countByTestCaseIDInProject(String projectId) {
|
||||
return extApiDefinitionExecResultMapper.countByTestCaseIDInProject(projectId);
|
||||
|
||||
}
|
||||
|
||||
public List<ExecutedCaseInfoResult> findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(String projectId, boolean selectFunctionCase, int limitNumber) {
|
||||
|
||||
//获取7天之前的日期
|
||||
|
@ -442,11 +409,6 @@ public class ApiDefinitionExecResultService {
|
|||
}
|
||||
}
|
||||
|
||||
public ApiDefinitionExecResult getInfo(String id) {
|
||||
return apiDefinitionExecResultMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
|
||||
public List<ApiDefinitionExecResultExpand> apiReportList(QueryAPIReportRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders(), "end_time"));
|
||||
this.initReportRequest(request);
|
||||
|
@ -468,14 +430,6 @@ public class ApiDefinitionExecResultService {
|
|||
}
|
||||
}
|
||||
|
||||
public void deleteByRelevanceTestPlanReportIds(List<String> testPlanReportIdList) {
|
||||
if (CollectionUtils.isNotEmpty(testPlanReportIdList)) {
|
||||
ApiDefinitionExecResultExample apiDefinitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||
apiDefinitionExecResultExample.createCriteria().andRelevanceTestPlanReportIdIn(testPlanReportIdList);
|
||||
apiDefinitionExecResultMapper.deleteByExample(apiDefinitionExecResultExample);
|
||||
}
|
||||
}
|
||||
|
||||
public List<PlanReportCaseDTO> selectForPlanReport(List<String> apiReportIds) {
|
||||
if (CollectionUtils.isEmpty(apiReportIds)) return new ArrayList<>();
|
||||
return extApiDefinitionExecResultMapper.selectForPlanReport(apiReportIds);
|
||||
|
|
Loading…
Reference in New Issue