refactor(测试跟踪): 测试计划保存的配置信息的运行环境信息用于默认值

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-08-02 11:25:22 +08:00 committed by 建国
parent 9f9ebfcca0
commit 7292d04a32
3 changed files with 24 additions and 22 deletions

View File

@ -215,6 +215,12 @@ public class TestPlanController {
return testPlanService.runPlan(testplanRunRequest);
}
@PostMapping("/run/save")
public String runAndSave(@RequestBody TestPlanRunRequest testplanRunRequest) {
testPlanService.updateRunModeConfig(testplanRunRequest);
return testPlanService.runPlan(testplanRunRequest);
}
@PostMapping(value = "/run/batch")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.testPlanIds)", msClass = TestPlanService.class)
public void runBatch(@RequestBody TestPlanRunRequest request) {

View File

@ -975,30 +975,27 @@ public class TestPlanService {
LogUtil.error(e);
}
if (runModeConfig == null) {
runModeConfig = buildRunModeConfigDTO();
}
//环境参数为空时依据测试计划保存的环境执行
if ((StringUtils.equals("GROUP", runModeConfig.getEnvironmentType()) && StringUtils.isBlank(runModeConfig.getEnvironmentGroupId()))
|| (!StringUtils.equals("GROUP", runModeConfig.getEnvironmentType()) && MapUtils.isEmpty(runModeConfig.getEnvMap()))) {
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanID);
if (StringUtils.isNotEmpty(testPlanWithBLOBs.getRunModeConfig())) {
try {
JSONObject json = JSONObject.parseObject(testPlanWithBLOBs.getRunModeConfig());
TestPlanRequestUtil.changeStringToBoolean(json);
TestPlanRunRequest testPlanRunRequest = JSON.toJavaObject(json, TestPlanRunRequest.class);
if (StringUtils.equals("GROUP", testPlanRunRequest.getEnvironmentType()) && StringUtils.isBlank(testPlanRunRequest.getEnvironmentGroupId())) {
runModeConfig = buildRunModeConfigDTO();
} else {
runModeConfig = new RunModeConfigDTO();
runModeConfig.setMode(testPlanRunRequest.getMode());
runModeConfig.setReportType(testPlanRunRequest.getReportType());
if (testPlanRunRequest.getEnvMap() == null) {
runModeConfig.setEnvMap(new HashMap<>());
} else {
runModeConfig.setEnvMap(testPlanRunRequest.getEnvMap());
if (testPlanRunRequest != null) {
String envType = testPlanRunRequest.getEnvironmentType();
Map<String, String> envMap = testPlanRunRequest.getEnvMap();
String environmentGroupId = testPlanRunRequest.getEnvironmentGroupId();
runModeConfig = getRunModeConfigDTO(testPlanRunRequest, envType, envMap, environmentGroupId, testPlanID);
}
runModeConfig.setOnSampleError(testPlanRunRequest.isOnSampleError());
} catch (Exception e) {
LogUtil.error("获取测试计划保存的环境信息出错!", e);
}
} else {
runModeConfig = buildRunModeConfigDTO();
}
} else {
if (runModeConfig.getEnvMap() == null) {
runModeConfig.setEnvMap(new HashMap<>());
}
}
if (planReportId == null) {
@ -2129,7 +2126,6 @@ public class TestPlanService {
String testPlanId = testplanRunRequest.getTestPlanId();
RunModeConfigDTO runModeConfig = getRunModeConfigDTO(testplanRunRequest, envType, envMap, environmentGroupId, testPlanId);
String apiRunConfig = JSONObject.toJSONString(runModeConfig);
updatePlan(testplanRunRequest, testPlanId);
return this.run(testPlanId, testplanRunRequest.getProjectId(),
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), testplanRunRequest.getReportId(), apiRunConfig);

View File

@ -814,7 +814,7 @@ export default {
param.headlessEnabled = config.headlessEnabled;
if (config.isRun === true) {
this.$refs.taskCenter.open();
this.result = this.$post('test/plan/run/', param, () => {
this.result = this.$post('test/plan/run/save', param, () => {
this.$success(this.$t('commons.run_success'));
});
} else {