fix(接口测试): 修复场景失败重试多次后报告状态统计错误问题
--bug=1017152 --user=赵勇 【测试计划】接口场景失败重试,重试过程中成功了,但是场景结果是失败 https://www.tapd.cn/55049933/s/1250032
This commit is contained in:
parent
4ff5503c9b
commit
6a12064421
|
@ -33,6 +33,7 @@ import io.metersphere.service.UserService;
|
||||||
import io.metersphere.track.dto.PlanReportCaseDTO;
|
import io.metersphere.track.dto.PlanReportCaseDTO;
|
||||||
import io.metersphere.track.dto.UiRunModeConfigDTO;
|
import io.metersphere.track.dto.UiRunModeConfigDTO;
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
|
import io.metersphere.utils.RetryResultUtil;
|
||||||
import io.metersphere.xmind.utils.FileUtil;
|
import io.metersphere.xmind.utils.FileUtil;
|
||||||
import org.apache.commons.beanutils.BeanMap;
|
import org.apache.commons.beanutils.BeanMap;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
@ -543,7 +544,7 @@ public class ApiScenarioReportService {
|
||||||
String custom = "customCommand";
|
String custom = "customCommand";
|
||||||
if (report.getExecuteType().equals(ExecuteType.Debug.name()) &&
|
if (report.getExecuteType().equals(ExecuteType.Debug.name()) &&
|
||||||
report.getReportType().equals(ReportTypeConstants.UI_INDEPENDENT.name()) &&
|
report.getReportType().equals(ReportTypeConstants.UI_INDEPENDENT.name()) &&
|
||||||
!StringUtils.equalsIgnoreCase(scenario.getScenarioType(), custom)
|
!StringUtils.equalsIgnoreCase(scenario.getScenarioType(), custom)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -948,6 +949,29 @@ public class ApiScenarioReportService {
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RequestResult> filterRetryResults(List<RequestResult> results) {
|
||||||
|
List<RequestResult> list = new LinkedList<>();
|
||||||
|
if (CollectionUtils.isNotEmpty(results)) {
|
||||||
|
Map<String, List<RequestResult>> resultMap = results.stream().collect(Collectors.groupingBy(RequestResult::getResourceId));
|
||||||
|
resultMap.forEach((k, v) -> {
|
||||||
|
if (CollectionUtils.isNotEmpty(v)) {
|
||||||
|
// 校验是否含重试结果
|
||||||
|
List<RequestResult> isRetryResults = v
|
||||||
|
.stream()
|
||||||
|
.filter(c -> StringUtils.isNotEmpty(c.getName()) && c.getName().startsWith(RetryResultUtil.RETRY_CN))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(isRetryResults)) {
|
||||||
|
list.add(isRetryResults.get(isRetryResults.size() - 1));
|
||||||
|
} else {
|
||||||
|
// 成功的结果
|
||||||
|
list.addAll(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回正确的报告状态
|
* 返回正确的报告状态
|
||||||
*
|
*
|
||||||
|
@ -959,7 +983,9 @@ public class ApiScenarioReportService {
|
||||||
// 资源池执行整体传输失败,单条传输内容,获取资源池执行统计的状态
|
// 资源池执行整体传输失败,单条传输内容,获取资源池执行统计的状态
|
||||||
return String.valueOf(dto.getArbitraryData().get("REPORT_STATUS"));
|
return String.valueOf(dto.getArbitraryData().get("REPORT_STATUS"));
|
||||||
}
|
}
|
||||||
long errorSize = dto.getRequestResults().stream().filter(requestResult ->
|
// 过滤掉重试结果后进行统计
|
||||||
|
List<RequestResult> requestResults = filterRetryResults(dto.getRequestResults());
|
||||||
|
long errorSize = requestResults.stream().filter(requestResult ->
|
||||||
StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Error.name())).count();
|
StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Error.name())).count();
|
||||||
|
|
||||||
long errorReportResultSize = dto.getRequestResults().stream().filter(requestResult ->
|
long errorReportResultSize = dto.getRequestResults().stream().filter(requestResult ->
|
||||||
|
|
Loading…
Reference in New Issue