fix(接口测试): 修复资源池运行结果存储方法

修复资源池运行结果存储方法
This commit is contained in:
song-tianyang 2022-05-17 13:21:49 +08:00 committed by 刘瑞斌
parent a05118ea5e
commit 101f06003c
2 changed files with 9 additions and 9 deletions

View File

@ -56,7 +56,9 @@ public class KafkaListenerTask implements Runnable {
if (testResult != null) { if (testResult != null) {
if (testResult.getArbitraryData() != null && testResult.getArbitraryData().containsKey("TEST_END") && (Boolean) testResult.getArbitraryData().get("TEST_END")) { if (testResult.getArbitraryData() != null && testResult.getArbitraryData().containsKey("TEST_END") && (Boolean) testResult.getArbitraryData().get("TEST_END")) {
resultDTOS.add(testResult); resultDTOS.add(testResult);
} else { }
// 携带结果
if (CollectionUtils.isNotEmpty(testResult.getRequestResults())) {
String key = RUN_MODE_MAP.get(testResult.getRunMode()); String key = RUN_MODE_MAP.get(testResult.getRunMode());
if (assortMap.containsKey(key)) { if (assortMap.containsKey(key)) {
assortMap.get(key).add(testResult); assortMap.get(key).add(testResult);
@ -68,6 +70,7 @@ public class KafkaListenerTask implements Runnable {
} }
} }
}); });
if (MapUtils.isNotEmpty(assortMap)) { if (MapUtils.isNotEmpty(assortMap)) {
LoggerUtil.info("KAFKA消费执行内容存储开始"); LoggerUtil.info("KAFKA消费执行内容存储开始");
testResultService.batchSaveResults(assortMap); testResultService.batchSaveResults(assortMap);

View File

@ -96,14 +96,6 @@ public class ApiScenarioReportService {
example.createCriteria().andReportIdEqualTo(dto.getReportId()); example.createCriteria().andReportIdEqualTo(dto.getReportId());
List<ApiScenarioReportResult> requestResults = apiScenarioReportResultMapper.selectByExample(example); List<ApiScenarioReportResult> requestResults = apiScenarioReportResultMapper.selectByExample(example);
if (StringUtils.isNotEmpty(dto.getTestPlanReportId())) {
String status = getStatus(requestResults, dto);
Map<String, String> reportMap = new HashMap<String, String>() {{
this.put(dto.getReportId(), status);
}};
testPlanLog.info("TestPlanReportId" + JSONArray.toJSONString(dto.getReportId()) + " EXECUTE OVER. SCENARIO STATUS : " + JSONObject.toJSONString(reportMap));
}
ApiScenarioReport scenarioReport; ApiScenarioReport scenarioReport;
if (StringUtils.equals(dto.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) { if (StringUtils.equals(dto.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {
scenarioReport = updatePlanCase(requestResults, dto); scenarioReport = updatePlanCase(requestResults, dto);
@ -287,6 +279,11 @@ public class ApiScenarioReportService {
long errorSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Error.name())).count(); long errorSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Error.name())).count();
String status = getStatus(requestResults, dto); String status = getStatus(requestResults, dto);
List<String> requestResultIdList = new ArrayList<>();
for (ApiScenarioReportResult result : requestResults) {
requestResultIdList.add(result.getId());
}
testPlanLog.info("TestPlanReportId" + JSONArray.toJSONString(dto.getReportId()) + " EXECUTE OVER. STATUS : " + status + ", ResultIds:" + JSONObject.toJSONString(requestResultIdList));
ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), status, dto.getRunMode()); ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), status, dto.getRunMode());
if (report != null) { if (report != null) {
if (StringUtils.isNotEmpty(dto.getTestPlanReportId()) && !testPlanReportIdList.contains(dto.getTestPlanReportId())) { if (StringUtils.isNotEmpty(dto.getTestPlanReportId()) && !testPlanReportIdList.contains(dto.getTestPlanReportId())) {