fix(测试计划): 修复测试计划请求性能测试报告时json数据格式化的错误

--bug=1024105 --user=宋天阳 【测试跟踪】测试计划导出的报告-性能测试用例没有数据
https://www.tapd.cn/55049933/s/1350729
This commit is contained in:
song-tianyang 2023-03-15 18:27:43 +08:00 committed by 建国
parent f6daf41896
commit dae7e3cf8f
11 changed files with 54 additions and 10 deletions

View File

@ -9,8 +9,11 @@ public class LoadTestExportJmx {
private String name;
private String jmx;
public LoadTestExportJmx() {
}
public LoadTestExportJmx(String name, String jmx) {
this.name = name;
this.jmx = jmx;
}
}
}

View File

@ -0,0 +1,16 @@
package io.metersphere.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class MetricData {
private String uniqueLabel;
private String seriesName;
private List<Double> values;
private List<String> timestamps;
private String instance;
}

View File

@ -0,0 +1,16 @@
package io.metersphere.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class Monitor {
private String name;
private String ip;
private String port;
private String description;
private List<MonitorItem> monitorConfig;
}

View File

@ -0,0 +1,11 @@
package io.metersphere.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class MonitorItem {
private String value; // 表达式
private String name; // 监控项
}

View File

@ -6,11 +6,9 @@ import io.metersphere.plan.dto.ChartsData;
import io.metersphere.plan.dto.Errors;
import io.metersphere.plan.dto.ErrorsTop5;
import io.metersphere.plan.dto.Statistics;
import io.opentelemetry.sdk.metrics.data.MetricData;
import lombok.Getter;
import lombok.Setter;
import javax.management.monitor.Monitor;
import java.util.List;
import java.util.Map;

View File

@ -1423,8 +1423,10 @@ public class TestPlanService {
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
report.setApiAllCases(planTestPlanApiCaseService.buildResponse(report.getApiAllCases()));
report.setApiFailureCases(planTestPlanApiCaseService.buildResponse(report.getApiFailureCases()));
report.setErrorReportCases(planTestPlanApiCaseService.buildResponse(report.getErrorReportCases()));
report.setScenarioAllCases(planTestPlanScenarioCaseService.buildResponse(report.getScenarioAllCases()));
report.setScenarioFailureCases(planTestPlanScenarioCaseService.buildResponse(report.getScenarioFailureCases()));
report.setErrorReportScenarios(planTestPlanScenarioCaseService.buildResponse(report.getErrorReportScenarios()));
}
if (serviceIdSet.contains(MicroServiceName.UI_TEST)) {
@ -1455,7 +1457,8 @@ public class TestPlanService {
String line = null;
while (null != (line = bufferedReader.readLine())) {
if (line.contains("\"#report\"")) {
line = line.replace("\"#report\"", new Gson().toJson(report));
String reportInfo = new Gson().toJson(report);
line = line.replace("\"#report\"", reportInfo);
}
line += StringUtils.LF;
byte[] lineBytes = line.getBytes(StandardCharsets.UTF_8);

View File

@ -138,7 +138,8 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
if (CollectionUtils.isEmpty(loadCases)) {
return null;
}
return microService.postForDataArray(serviceName, BASE_UEL + "/build/response", loadCases, TestPlanLoadCaseDTO.class);
List<TestPlanLoadCaseDTO> returnList = microService.postForDataArray(serviceName, BASE_UEL + "/build/response", loadCases, TestPlanLoadCaseDTO.class);
return returnList;
}
public Object relevanceList(int pageNum, int pageSize, LoadCaseRequest request) {

View File

@ -3,7 +3,6 @@ package io.metersphere.plan.utils;
import io.metersphere.base.domain.TestCaseTest;
import io.metersphere.commons.constants.TestPlanStatus;
import io.metersphere.dto.*;
import io.metersphere.i18n.Translator;
import io.metersphere.plan.constant.ApiReportStatus;
import io.metersphere.plan.dto.CaseExecResult;
import io.metersphere.plan.enums.FunctionCaseExecResult;
@ -259,6 +258,6 @@ public class TestCaseSyncStatusUtil {
}
public static String generateCommentDesc(String testPlanName, String caseName, String status) {
return String.format(Translator.get("test_case_sync_status_comment"), caseName, testPlanName, status);
return String.format("关联的case %s 在测试计划【%s】内的执行结果出现%s。", caseName, testPlanName, status);
}
}

View File

@ -228,6 +228,5 @@ test_plan_delete_exec_error=The test plan is being executed
test_case_review_status_underway=Underway
test_case_review_status_re_review=ReReview
api_status_fake_error=Fake error
test_case_sync_status_comment=Relevance case %s in test plan [%s] has be executed by result %s。
serial=Serial
parallel=Parallel

View File

@ -199,6 +199,5 @@ test_plan_delete_exec_error=测试计划正在执行中
test_case_review_status_underway=评审中
test_case_review_status_re_review=重新提审
api_status_fake_error=误报
test_case_sync_status_comment=关联的case %s 在测试计划【%s】内的执行结果出现%s。
serial=串行
parallel=并行

View File

@ -199,6 +199,5 @@ test_plan_delete_exec_error=測試計劃正在執行中
test_case_review_status_underway=評審中
test_case_review_status_re_review=重新提審
api_status_fake_error=誤報
test_case_sync_status_comment=關聯的case %s 在測試計劃【%s】內的執行結果出現%s。
serial=串行
parallel=並行