fix(性能测试): 修复同步接口用例没有实时更新的问题
--bug=1017983 --user=刘瑞斌 【性能测试】同步场景测试最新变更更新后下载jtl请求无变化 https://www.tapd.cn/55049933/s/1261952
This commit is contained in:
parent
0d617a8c97
commit
843087819d
|
@ -0,0 +1,13 @@
|
||||||
|
package io.metersphere.api.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ApiCaseExportJmxRequest {
|
||||||
|
private List<String> caseIds;
|
||||||
|
private String envId;
|
||||||
|
}
|
|
@ -1,9 +1,6 @@
|
||||||
package io.metersphere.api.service;
|
package io.metersphere.api.service;
|
||||||
|
|
||||||
import io.metersphere.api.dto.ApiLoadType;
|
import io.metersphere.api.dto.*;
|
||||||
import io.metersphere.api.dto.ApiScenarioBatchRequest;
|
|
||||||
import io.metersphere.api.dto.ApiScenarioExportJmxDTO;
|
|
||||||
import io.metersphere.api.dto.ScenarioToPerformanceInfoDTO;
|
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiLoadTestMapper;
|
import io.metersphere.base.mapper.ApiLoadTestMapper;
|
||||||
import io.metersphere.base.mapper.LoadTestFileMapper;
|
import io.metersphere.base.mapper.LoadTestFileMapper;
|
||||||
|
@ -54,6 +51,10 @@ public class ApiPerformanceService {
|
||||||
return microService.postForData(MicroServiceName.API_TEST, "/api/automation/export/jmx", request, ScenarioToPerformanceInfoDTO.class);
|
return microService.postForData(MicroServiceName.API_TEST, "/api/automation/export/jmx", request, ScenarioToPerformanceInfoDTO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<JmxInfoDTO> exportApiCaseJmx(Object request) {
|
||||||
|
return microService.postForDataArray(MicroServiceName.API_TEST, "/api/testcase/export/jmx", request, JmxInfoDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
public Object list(int goPage, int pageSize, Object request) {
|
public Object list(int goPage, int pageSize, Object request) {
|
||||||
return microService.postForResultHolder(MicroServiceName.API_TEST, "/api/automation/list/" + goPage + "/" + pageSize, request);
|
return microService.postForResultHolder(MicroServiceName.API_TEST, "/api/automation/list/" + goPage + "/" + pageSize, request);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +120,7 @@ public class ApiPerformanceService {
|
||||||
.filter(i -> i.getType().equals(ApiLoadType.SCENARIO.name()))
|
.filter(i -> i.getType().equals(ApiLoadType.SCENARIO.name()))
|
||||||
.map(ApiLoadTest::getApiId)
|
.map(ApiLoadTest::getApiId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (!org.apache.commons.collections4.CollectionUtils.isEmpty(scenarioIds)) {
|
if (!CollectionUtils.isEmpty(scenarioIds)) {
|
||||||
ApiScenarioBatchRequest scenarioRequest = new ApiScenarioBatchRequest();
|
ApiScenarioBatchRequest scenarioRequest = new ApiScenarioBatchRequest();
|
||||||
scenarioRequest.setIds(scenarioIds);
|
scenarioRequest.setIds(scenarioIds);
|
||||||
List<ApiScenarioExportJmxDTO> apiScenrioExportJmxes = this.exportJmx(scenarioRequest).getScenarioJmxList();
|
List<ApiScenarioExportJmxDTO> apiScenrioExportJmxes = this.exportJmx(scenarioRequest).getScenarioJmxList();
|
||||||
|
@ -135,23 +136,22 @@ public class ApiPerformanceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncApiCase(LoadTestWithBLOBs loadTest, List<ApiLoadTest> apiLoadTests) {
|
public void syncApiCase(LoadTestWithBLOBs loadTest, List<ApiLoadTest> apiLoadTests) {
|
||||||
// todo
|
List<String> caseIds = apiLoadTests.stream()
|
||||||
// List<String> caseIds = apiLoadTests.stream()
|
.filter(i -> i.getType().equals(ApiLoadType.API_CASE.name()))
|
||||||
// .filter(i -> i.getType().equals(ApiLoadType.API_CASE.name()))
|
.map(ApiLoadTest::getApiId)
|
||||||
// .map(ApiLoadTest::getApiId)
|
.collect(Collectors.toList());
|
||||||
// .collect(Collectors.toList());
|
if (!CollectionUtils.isEmpty(caseIds)) {
|
||||||
// if (!org.apache.commons.collections4.CollectionUtils.isEmpty(caseIds)) {
|
ApiCaseExportJmxRequest request = new ApiCaseExportJmxRequest();
|
||||||
// ApiScenarioBatchRequest scenarioRequest = new ApiScenarioBatchRequest();
|
request.setCaseIds(caseIds);
|
||||||
// scenarioRequest.setIds(caseIds);
|
request.setEnvId(apiLoadTests.get(0).getEnvId());
|
||||||
//
|
List<JmxInfoDTO> jmxInfoDTOS = this.exportApiCaseJmx(request);
|
||||||
// List<JmxInfoDTO> jmxInfoDTOS = apiTestCaseService.exportJmx(caseIds, apiLoadTests.get(0).getEnvId());
|
deleteLoadTestFiles(loadTest.getId());
|
||||||
// deleteLoadTestFiles(loadTest.getId());
|
jmxInfoDTOS.forEach(item -> {
|
||||||
// jmxInfoDTOS.forEach(item -> {
|
this.updateVersion(loadTest.getId(), item.getId(), item.getVersion());
|
||||||
// this.updateVersion(loadTest.getId(), item.getId(), item.getVersion());
|
saveJmxFile(item.getXml(), item.getName(), loadTest.getProjectId(), loadTest.getId());
|
||||||
// saveJmxFile(item.getXml(), item.getName(), loadTest.getProjectId(), loadTest.getId());
|
saveBodyFile(item.getFileMetadataList(), loadTest.getId(), item.getId());
|
||||||
// saveBodyFile(item.getFileMetadataList(), loadTest.getId(), item.getId());
|
});
|
||||||
// });
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue