Merge remote-tracking branch 'origin/master'

This commit is contained in:
Captain.B 2020-12-24 11:22:15 +08:00
commit 7af4e161c4
5 changed files with 17 additions and 32 deletions

View File

@ -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;

View File

@ -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<String, String> 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) {

View File

@ -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(),

View File

@ -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

View File

@ -231,6 +231,7 @@
<select id="selectTestPlanByRelevancy" resultMap="BaseResultMap" parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
SELECT * FROM TEST_PLAN p LEFT JOIN test_plan_project t ON t.test_plan_id=p.id
<where>
AND t.project_id = #{request.projectId}
<if test="request.scenarioId != null">
AND p.id IN (SELECT test_plan_id FROM test_plan_api_scenario WHERE api_scenario_id = #{request.scenarioId} )
</if>