feat(接口自动化): 数据迁移

This commit is contained in:
fit2-zhao 2021-01-06 14:18:51 +08:00
parent 643db9c863
commit 59de447719
3 changed files with 14 additions and 3 deletions

View File

@ -14,7 +14,6 @@ import io.metersphere.api.service.*;
import io.metersphere.base.domain.ApiTest;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.constants.ScheduleGroup;
import io.metersphere.commons.utils.CronUtils;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -59,7 +58,7 @@ public class APITestController {
@Resource
private ScheduleService scheduleService;
@Resource
private APIReportService apiReportService;
private HistoricalDataUpgradeService historicalDataUpgradeService;
@GetMapping("recent/{count}")
public List<APITestResult> recentTest(@PathVariable int count) {
@ -359,4 +358,8 @@ public class APITestController {
schedule.setEnable(request.isEnable());
apiAutomationService.updateSchedule(schedule);
}
@PostMapping(value = "/historicalDataUpgrade")
public String historicalDataUpgrade(@RequestBody SaveHistoricalDataUpgrade request) {
return historicalDataUpgradeService.upgrade(request);
}
}

View File

@ -42,7 +42,11 @@ public class Body {
return true;
} else return false;
}
public boolean isOldKV() {
if (StringUtils.equals(type, KV)) {
return true;
} else return false;
}
public List<KeyValue> getBodyParams(HTTPSamplerProxy sampler, String requestId) {
List<KeyValue> body = new ArrayList<>();
if (this.isKV() || this.isBinary()) {

View File

@ -15,6 +15,7 @@ import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
import io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler;
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
import io.metersphere.api.dto.definition.request.timer.MsConstantTimer;
import io.metersphere.api.dto.scenario.Body;
import io.metersphere.api.dto.scenario.Scenario;
import io.metersphere.api.dto.scenario.request.*;
import io.metersphere.base.domain.*;
@ -103,6 +104,9 @@ public class HistoricalDataUpgradeService {
LogUtil.error(ex.getMessage());
}
}
if (request1.getBody() != null && request1.getBody().isOldKV()) {
request1.getBody().setType(Body.FORM_DATA);
}
BeanUtils.copyBean(element, request1);
((MsHTTPSamplerProxy) element).setProtocol(RequestType.HTTP);
((MsHTTPSamplerProxy) element).setArguments(request1.getParameters());