diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index 3006f0af17..421eec048a 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -268,7 +268,7 @@ public class APITestController { if(allCount!=0){ float coverageRageNumber =(float)apiCountResult.getExecutionPassCount()*100/allCount; DecimalFormat df = new DecimalFormat("0.0"); - apiCountResult.setCoverageRage(df.format(coverageRageNumber)+"%"); + apiCountResult.setPassRage(df.format(coverageRageNumber)+"%"); } return apiCountResult; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 0edce5e72d..44c7cbdea7 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -206,35 +206,17 @@ public class MsHTTPSamplerProxy extends MsTestElement { this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue -> keyValueMap.put(keyValue.getName(), keyValue.getValue()) ); - // 这块是否使用jmeter自身机制? - Map pubKeyValueMap = new HashMap<>(); - if (config != null && config.getVariables() != null) { - config.getVariables().stream().forEach(keyValue -> { - pubKeyValueMap.put(keyValue.getName(), keyValue.getValue()); - }); - } - for (String key : keyValueMap.keySet()) { - if (keyValueMap.get(key) != null && keyValueMap.get(key).startsWith("$")) { - String pubKey = keyValueMap.get(key).substring(2, keyValueMap.get(key).length() - 1); - keyValueMap.put(key, pubKeyValueMap.get(pubKey)); - } - } - - Pattern p = Pattern.compile("(\\{)([\\w]+)(\\})"); - Matcher m = p.matcher(path); - StringBuffer sb = new StringBuffer(); try { + Pattern p = Pattern.compile("(\\{)([\\w]+)(\\})"); + Matcher m = p.matcher(path); while (m.find()) { String group = m.group(2); - //替换并且把替换好的值放到sb中 - m.appendReplacement(sb, keyValueMap.get(group)); + path = path.replace("{" + group + "}", keyValueMap.get(group)); } } catch (Exception ex) { ex.printStackTrace(); } - //把符合的数据追加到sb尾 - m.appendTail(sb); - return sb.toString(); + return path; } private String getPostQueryParameters(String path) { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 1a85a2dd6c..553dfdcbbc 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -30,9 +30,6 @@ import io.metersphere.service.ScheduleService; import io.metersphere.track.dto.TestPlanDTO; import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; -import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest; -import io.metersphere.track.service.TestPlanApiCaseService; -import io.metersphere.track.service.TestPlanScenarioCaseService; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; @@ -47,8 +44,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; @Service @Transactional(rollbackFor = Exception.class) @@ -343,7 +338,6 @@ public class ApiAutomationService { ParameterConfig config = new ParameterConfig(); config.setConfig(envConfig); HashTree hashTree = request.getTestElement().generateHashTree(config); - request.getTestElement().getJmx(hashTree); // 调用执行方法 jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.SCENARIO.name()); createAPIScenarioReportResult(request.getId(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(), diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml index 254b8576b7..6d66b45840 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml @@ -50,12 +50,20 @@ ) caseErrorCountData ON caseErrorCountData.testCaseID =testCase.testCaseID WHERE caseErrorCountData.executeTime >= #{startTimestamp} UNION - SELECT scene.`name` AS caseName,testPlan.`name` AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType + SELECT scene.`name` AS caseName,apiScene.testPlanName AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType FROM api_scenario_report report INNER JOIN api_scenario_report_detail reportDetail ON report.id = reportDetail.report_id INNER JOIN api_scenario scene ON reportDetail.content like concat('%"', scene.`name`,'"%') - LEFT JOIN test_plan_api_scenario apiScene ON apiScene.api_scenario_id = scene.id - LEFT JOIN test_plan testPlan ON testPlan.id = apiScene.test_plan_id + LEFT JOIN + ( + SELECT + apiScene.api_scenario_id, + group_concat(testPlan.`name`) AS testPlanName + FROM + test_plan_api_scenario apiScene + INNER JOIN test_plan testPlan ON testPlan.id = apiScene.test_plan_id + GROUP BY apiScene.api_scenario_id + )apiScene ON apiScene.api_scenario_id = scene.id WHERE report.project_id = #{projectId} AND report.status = 'Error' AND report.create_time >= #{startTimestamp} GROUP BY scene.id diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml index e3dbb2b706..9b757043a1 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml @@ -231,6 +231,7 @@