feat(测试跟踪): 批量执行测试计划
--user=郭雨琦 测试计划执行按钮增加单独保存测试计划运行配置的功能
This commit is contained in:
parent
0be6fe161e
commit
36c3d59660
|
@ -216,6 +216,12 @@ public class TestPlanController {
|
||||||
return testPlanService.getPlanCaseEnv(plan.getId());
|
return testPlanService.getPlanCaseEnv(plan.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/edit/runModeConfig")
|
||||||
|
public void updateRunModeConfig(@RequestBody TestplanRunRequest testplanRunRequest) {
|
||||||
|
testPlanService.updateRunModeConfig(testplanRunRequest);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/run")
|
@PostMapping("/run")
|
||||||
public String run(@RequestBody TestplanRunRequest testplanRunRequest) {
|
public String run(@RequestBody TestplanRunRequest testplanRunRequest) {
|
||||||
return testPlanService.runPlan(testplanRunRequest);
|
return testPlanService.runPlan(testplanRunRequest);
|
||||||
|
|
|
@ -73,7 +73,7 @@ import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
@ -1847,9 +1847,18 @@ public class TestPlanService {
|
||||||
String envType = testplanRunRequest.getEnvironmentType();
|
String envType = testplanRunRequest.getEnvironmentType();
|
||||||
Map<String, String> envMap = testplanRunRequest.getEnvMap();
|
Map<String, String> envMap = testplanRunRequest.getEnvMap();
|
||||||
String environmentGroupId = testplanRunRequest.getEnvironmentGroupId();
|
String environmentGroupId = testplanRunRequest.getEnvironmentGroupId();
|
||||||
|
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.getPlanScheduleReportInfoDTO() != null ? testplanRunRequest.getPlanScheduleReportInfoDTO() : null, apiRunConfig);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private RunModeConfigDTO getRunModeConfigDTO(TestplanRunRequest testplanRunRequest, String envType, Map<String, String> envMap, String environmentGroupId, String testPlanId) {
|
||||||
RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
|
RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
|
||||||
runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType());
|
runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType());
|
||||||
String testPlanId = testplanRunRequest.getTestPlanId();
|
|
||||||
if (StringUtils.equals(envType, EnvironmentType.JSON.name()) && !envMap.isEmpty()) {
|
if (StringUtils.equals(envType, EnvironmentType.JSON.name()) && !envMap.isEmpty()) {
|
||||||
runModeConfig.setEnvMap(testplanRunRequest.getEnvMap());
|
runModeConfig.setEnvMap(testplanRunRequest.getEnvMap());
|
||||||
this.setPlanCaseEnv(testPlanId, runModeConfig);
|
this.setPlanCaseEnv(testPlanId, runModeConfig);
|
||||||
|
@ -1857,7 +1866,6 @@ public class TestPlanService {
|
||||||
runModeConfig.setEnvironmentGroupId(testplanRunRequest.getEnvironmentGroupId());
|
runModeConfig.setEnvironmentGroupId(testplanRunRequest.getEnvironmentGroupId());
|
||||||
this.setPlanCaseEnv(testPlanId, runModeConfig);
|
this.setPlanCaseEnv(testPlanId, runModeConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
runModeConfig.setMode(testplanRunRequest.getMode());
|
runModeConfig.setMode(testplanRunRequest.getMode());
|
||||||
runModeConfig.setResourcePoolId(testplanRunRequest.getResourcePoolId());
|
runModeConfig.setResourcePoolId(testplanRunRequest.getResourcePoolId());
|
||||||
runModeConfig.setOnSampleError(Boolean.parseBoolean(testplanRunRequest.getOnSampleError()));
|
runModeConfig.setOnSampleError(Boolean.parseBoolean(testplanRunRequest.getOnSampleError()));
|
||||||
|
@ -1866,16 +1874,16 @@ public class TestPlanService {
|
||||||
} else {
|
} else {
|
||||||
runModeConfig.setReportType(testplanRunRequest.getReportType());
|
runModeConfig.setReportType(testplanRunRequest.getReportType());
|
||||||
}
|
}
|
||||||
String apiRunConfig = JSONObject.toJSONString(runModeConfig);
|
return runModeConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePlan(TestplanRunRequest testplanRunRequest, String testPlanId) {
|
||||||
String request = JSON.toJSONString(testplanRunRequest);
|
String request = JSON.toJSONString(testplanRunRequest);
|
||||||
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
|
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
|
||||||
if(testPlanWithBLOBs.getRunModeConfig()==null||!(StringUtils.equals(request,testPlanWithBLOBs.getRunModeConfig()))){
|
if(testPlanWithBLOBs.getRunModeConfig()==null||!(StringUtils.equals(request,testPlanWithBLOBs.getRunModeConfig()))){
|
||||||
testPlanWithBLOBs.setRunModeConfig(request);
|
testPlanWithBLOBs.setRunModeConfig(request);
|
||||||
testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlanWithBLOBs);
|
testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlanWithBLOBs);
|
||||||
}
|
}
|
||||||
return this.run(testPlanId, testplanRunRequest.getProjectId(),
|
|
||||||
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(),testplanRunRequest.getPlanScheduleReportInfoDTO() != null ? testplanRunRequest.getPlanScheduleReportInfoDTO() : null, apiRunConfig);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlanCaseEnv(String planId, RunModeConfigDTO runModeConfig) {
|
public void setPlanCaseEnv(String planId, RunModeConfigDTO runModeConfig) {
|
||||||
|
@ -2139,4 +2147,8 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateRunModeConfig(TestplanRunRequest testplanRunRequest) {
|
||||||
|
String testPlanId = testplanRunRequest.getTestPlanId();
|
||||||
|
updatePlan(testplanRunRequest, testPlanId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,18 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<ms-dialog-footer @cancel="close" @confirm="handleRunBatch"/>
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="close" >{{$t('commons.cancel')}}</el-button>
|
||||||
|
<el-dropdown @command="handleCommand" style="margin-left: 5px">
|
||||||
|
<el-button type="primary" >
|
||||||
|
{{$t('load_test.save_and_run')}}<i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
|
</el-button>
|
||||||
|
<el-dropdown-menu slot="dropdown">
|
||||||
|
<el-dropdown-item command="run">{{$t('load_test.save_and_run')}}</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="save">{{$t('commons.save')}}</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
@ -107,6 +118,14 @@ export default {
|
||||||
projectEnvListMap: {},
|
projectEnvListMap: {},
|
||||||
projectList: [],
|
projectList: [],
|
||||||
projectIds: new Set(),
|
projectIds: new Set(),
|
||||||
|
options: [{
|
||||||
|
value: 'confirmAndRun',
|
||||||
|
label: this.$t('load_test.save_and_run')
|
||||||
|
}, {
|
||||||
|
value: 'save',
|
||||||
|
label: this.$t('commons.save')
|
||||||
|
}],
|
||||||
|
value: 'confirmAndRun'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: ['planCaseIds', 'type', 'planId'],
|
props: ['planCaseIds', 'type', 'planId'],
|
||||||
|
@ -180,6 +199,15 @@ export default {
|
||||||
}
|
}
|
||||||
this.$refs.envPopover.openEnvSelect();
|
this.$refs.envPopover.openEnvSelect();
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
handleCommand(command){
|
||||||
|
if (command === 'run') {
|
||||||
|
this.runConfig.isRun = true
|
||||||
|
this.handleRunBatch();
|
||||||
|
} else {
|
||||||
|
this.runConfig.isRun = false
|
||||||
|
this.handleRunBatch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -789,12 +789,17 @@ export default {
|
||||||
param.environmentType = environmentType;
|
param.environmentType = environmentType;
|
||||||
param.environmentGroupId = environmentGroupId;
|
param.environmentGroupId = environmentGroupId;
|
||||||
param.requestOriginator = "TEST_PLAN";
|
param.requestOriginator = "TEST_PLAN";
|
||||||
|
if(config.isRun === true){
|
||||||
this.$refs.taskCenter.open();
|
this.$refs.taskCenter.open();
|
||||||
this.result = this.$post('test/plan/run/', param, () => {
|
this.result = this.$post('test/plan/run/', param, () => {
|
||||||
this.$success(this.$t('commons.run_success'));
|
this.$success(this.$t('commons.run_success'));
|
||||||
}, error => {
|
|
||||||
// this.$error(error.message);
|
|
||||||
});
|
});
|
||||||
|
}else{
|
||||||
|
this.result = this.$post('test/plan/edit/runModeConfig', param, () => {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
saveFollow(row) {
|
saveFollow(row) {
|
||||||
if (row.showFollow) {
|
if (row.showFollow) {
|
||||||
|
|
Loading…
Reference in New Issue