fix(接口测试): 修复JDBC请求步骤所属环境未随公共环境变动问题
--bug=1011789 --user=赵勇 【接口测试】场景-引用场景为sql接口-更换运行环境-调试-返回结果后查看数据源名称-仍显示之前的数据源源名称 https://www.tapd.cn/55049933/s/1128715
This commit is contained in:
parent
f3e7897915
commit
d71bf052ce
|
@ -178,6 +178,7 @@ public class ApiCaseExecuteService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口定义case执行
|
* 接口定义case执行
|
||||||
*
|
*
|
||||||
|
@ -199,6 +200,8 @@ public class ApiCaseExecuteService {
|
||||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||||
(query) -> extApiTestCaseMapper.selectIdsByQuery((ApiTestCaseRequest) query));
|
(query) -> extApiTestCaseMapper.selectIdsByQuery((ApiTestCaseRequest) query));
|
||||||
|
|
||||||
|
List<MsExecResponseDTO> responseDTOS = new LinkedList<>();
|
||||||
|
|
||||||
ApiTestCaseExample example = new ApiTestCaseExample();
|
ApiTestCaseExample example = new ApiTestCaseExample();
|
||||||
example.createCriteria().andIdIn(request.getIds());
|
example.createCriteria().andIdIn(request.getIds());
|
||||||
List<ApiTestCaseWithBLOBs> caseList = apiTestCaseMapper.selectByExampleWithBLOBs(example);
|
List<ApiTestCaseWithBLOBs> caseList = apiTestCaseMapper.selectByExampleWithBLOBs(example);
|
||||||
|
@ -222,6 +225,7 @@ public class ApiCaseExecuteService {
|
||||||
|
|
||||||
apiScenarioReportStructureService.save(serialReportId, new ArrayList<>());
|
apiScenarioReportStructureService.save(serialReportId, new ArrayList<>());
|
||||||
apiCaseResultService.batchSave(executeQueue);
|
apiCaseResultService.batchSave(executeQueue);
|
||||||
|
responseDTOS.add(new MsExecResponseDTO(JSON.toJSONString(request.getIds()), report.getId(), request.getTriggerMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) {
|
if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) {
|
||||||
|
@ -238,7 +242,6 @@ public class ApiCaseExecuteService {
|
||||||
request.setTriggerMode(ApiRunMode.DEFINITION.name());
|
request.setTriggerMode(ApiRunMode.DEFINITION.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MsExecResponseDTO> responseDTOS = new LinkedList<>();
|
|
||||||
Map<String, ApiDefinitionExecResult> executeQueue = new LinkedHashMap<>();
|
Map<String, ApiDefinitionExecResult> executeQueue = new LinkedHashMap<>();
|
||||||
String status = request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString()) ? APITestStatus.Waiting.name() : APITestStatus.Running.name();
|
String status = request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString()) ? APITestStatus.Waiting.name() : APITestStatus.Running.name();
|
||||||
|
|
||||||
|
@ -254,8 +257,10 @@ public class ApiCaseExecuteService {
|
||||||
report.setIntegratedReportId(serialReportId);
|
report.setIntegratedReportId(serialReportId);
|
||||||
}
|
}
|
||||||
executeQueue.put(caseWithBLOBs.getId(), report);
|
executeQueue.put(caseWithBLOBs.getId(), report);
|
||||||
|
if (!StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString())) {
|
||||||
responseDTOS.add(new MsExecResponseDTO(caseWithBLOBs.getId(), report.getId(), request.getTriggerMode()));
|
responseDTOS.add(new MsExecResponseDTO(caseWithBLOBs.getId(), report.getId(), request.getTriggerMode()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
apiCaseResultService.batchSave(executeQueue);
|
apiCaseResultService.batchSave(executeQueue);
|
||||||
|
|
||||||
|
|
|
@ -349,6 +349,7 @@ public class ApiScenarioReportService {
|
||||||
execResultExample.createCriteria().andIntegratedReportIdEqualTo(reportId).andStatusEqualTo("Error");
|
execResultExample.createCriteria().andIntegratedReportIdEqualTo(reportId).andStatusEqualTo("Error");
|
||||||
long size = definitionExecResultMapper.countByExample(execResultExample);
|
long size = definitionExecResultMapper.countByExample(execResultExample);
|
||||||
result.setStatus(size > 0 ? ScenarioStatus.Error.name() : ScenarioStatus.Success.name());
|
result.setStatus(size > 0 ? ScenarioStatus.Error.name() : ScenarioStatus.Success.name());
|
||||||
|
result.setEndTime(System.currentTimeMillis());
|
||||||
definitionExecResultMapper.updateByPrimaryKeySelective(result);
|
definitionExecResultMapper.updateByPrimaryKeySelective(result);
|
||||||
} else {
|
} else {
|
||||||
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(reportId);
|
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(reportId);
|
||||||
|
|
|
@ -58,6 +58,8 @@ public class MsHashTreeService {
|
||||||
private static final String BODY = "body";
|
private static final String BODY = "body";
|
||||||
private static final String ARGUMENTS = "arguments";
|
private static final String ARGUMENTS = "arguments";
|
||||||
private static final String AUTH_MANAGER = "authManager";
|
private static final String AUTH_MANAGER = "authManager";
|
||||||
|
private static final String PROJECT_ID = "projectId";
|
||||||
|
private static final String ACTIVE = "active";
|
||||||
|
|
||||||
public void setHashTree(JSONArray hashTree) {
|
public void setHashTree(JSONArray hashTree) {
|
||||||
// 将引用转成复制
|
// 将引用转成复制
|
||||||
|
@ -187,11 +189,12 @@ public class MsHashTreeService {
|
||||||
element.put(REST, refElement.get(REST));
|
element.put(REST, refElement.get(REST));
|
||||||
element.put(PATH, refElement.get(PATH));
|
element.put(PATH, refElement.get(PATH));
|
||||||
element.put(BODY, refElement.get(BODY));
|
element.put(BODY, refElement.get(BODY));
|
||||||
element.put("active", false);
|
element.put(ACTIVE, false);
|
||||||
element.put(AUTH_MANAGER, refElement.get(AUTH_MANAGER));
|
element.put(AUTH_MANAGER, refElement.get(AUTH_MANAGER));
|
||||||
element.put(ARGUMENTS, refElement.get(ARGUMENTS));
|
element.put(ARGUMENTS, refElement.get(ARGUMENTS));
|
||||||
|
element.put(PROJECT_ID, apiTestCase.getProjectId());
|
||||||
if (array != null) {
|
if (array != null) {
|
||||||
JSONArray sourceHashTree = element.getJSONArray("hashTree");
|
JSONArray sourceHashTree = element.getJSONArray(HASH_TREE);
|
||||||
Map<String, List<JSONObject>> groupMap = ElementUtil.group(sourceHashTree);
|
Map<String, List<JSONObject>> groupMap = ElementUtil.group(sourceHashTree);
|
||||||
Map<String, List<JSONObject>> targetGroupMap = ElementUtil.group(refElement.getJSONArray(HASH_TREE));
|
Map<String, List<JSONObject>> targetGroupMap = ElementUtil.group(refElement.getJSONArray(HASH_TREE));
|
||||||
|
|
||||||
|
@ -208,7 +211,7 @@ public class MsHashTreeService {
|
||||||
if (CollectionUtils.isNotEmpty(rules)) {
|
if (CollectionUtils.isNotEmpty(rules)) {
|
||||||
step.addAll(rules);
|
step.addAll(rules);
|
||||||
}
|
}
|
||||||
element.put("hashTree", step);
|
element.put(HASH_TREE, step);
|
||||||
}
|
}
|
||||||
element.put(REFERENCED, REF);
|
element.put(REFERENCED, REF);
|
||||||
element.put(DISABLED, true);
|
element.put(DISABLED, true);
|
||||||
|
|
|
@ -734,11 +734,6 @@ export default {
|
||||||
this.getEnvDomain(data.hashTree, domainMap);
|
this.getEnvDomain(data.hashTree, domainMap);
|
||||||
this.margeDomain(this.scenarioDefinition, domainMap);
|
this.margeDomain(this.scenarioDefinition, domainMap);
|
||||||
this.cancelBatchProcessing();
|
this.cancelBatchProcessing();
|
||||||
if (this.$store.state.currentApiCase) {
|
|
||||||
this.$store.state.currentApiCase.resetDataSource = getUUID();
|
|
||||||
} else {
|
|
||||||
this.$store.state.currentApiCase = {resetDataSource: getUUID()};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -270,32 +270,16 @@ export default {
|
||||||
if (requireComponent != null && JSON.stringify(esbDefinition) != '{}' && JSON.stringify(esbDefinitionResponse) != '{}') {
|
if (requireComponent != null && JSON.stringify(esbDefinition) != '{}' && JSON.stringify(esbDefinitionResponse) != '{}') {
|
||||||
this.showXpackCompnent = true;
|
this.showXpackCompnent = true;
|
||||||
}
|
}
|
||||||
this.getEnvironments(this.environmentGroupId);
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
envMap(val) {
|
|
||||||
this.getEnvironments();
|
|
||||||
this.environmentMap = val;
|
|
||||||
},
|
|
||||||
message() {
|
message() {
|
||||||
this.forStatus();
|
this.forStatus();
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
environmentGroupId(val) {
|
|
||||||
this.getEnvironments(val);
|
|
||||||
},
|
|
||||||
environmentType(val) {
|
|
||||||
this.envType = val;
|
|
||||||
},
|
|
||||||
'$store.state.currentApiCase.debugLoop'() {
|
'$store.state.currentApiCase.debugLoop'() {
|
||||||
this.forStatus();
|
this.forStatus();
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
'$store.state.currentApiCase.resetDataSource'() {
|
|
||||||
if (this.request.id && this.request.referenced !== 'REF') {
|
|
||||||
this.initDataSource();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
displayColor() {
|
displayColor() {
|
||||||
|
@ -391,50 +375,7 @@ export default {
|
||||||
this.response = this.request.requestResult[0];
|
this.response = this.request.requestResult[0];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initDataSource() {
|
|
||||||
let databaseConfigsOptions = [];
|
|
||||||
if (this.request.protocol === 'SQL' || this.request.type === 'JDBCSampler') {
|
|
||||||
if (this.environment && this.environment.config) {
|
|
||||||
let config = JSON.parse(this.environment.config);
|
|
||||||
if (config && config.databaseConfigs) {
|
|
||||||
config.databaseConfigs.forEach(item => {
|
|
||||||
databaseConfigsOptions.push(item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (databaseConfigsOptions.length > 0 && this.request.environmentId !== this.environment.id) {
|
|
||||||
this.request.dataSourceId = databaseConfigsOptions[0].id;
|
|
||||||
this.request.environmentId = this.environment.id;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getEnvironments(groupId) {
|
|
||||||
this.environment = {};
|
|
||||||
let id = undefined;
|
|
||||||
if (groupId) {
|
|
||||||
this.$get("/environment/group/project/map/" + groupId, res => {
|
|
||||||
let data = res.data;
|
|
||||||
if (data) {
|
|
||||||
this.environmentMap = new Map(Object.entries(data));
|
|
||||||
id = new Map(Object.entries(data)).get(this.request.projectId);
|
|
||||||
if (id) {
|
|
||||||
this.$get('/api/environment/get/' + id, response => {
|
|
||||||
this.environment = response.data;
|
|
||||||
this.initDataSource();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
id = this.envMap.get(this.request.projectId);
|
|
||||||
if (id) {
|
|
||||||
this.$get('/api/environment/get/' + id, response => {
|
|
||||||
this.environment = response.data;
|
|
||||||
this.initDataSource();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
remove() {
|
remove() {
|
||||||
this.$emit('remove', this.request, this.node);
|
this.$emit('remove', this.request, this.node);
|
||||||
},
|
},
|
||||||
|
@ -454,78 +395,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getApiInfo() {
|
|
||||||
if (this.request.id && this.request.referenced === 'REF') {
|
|
||||||
let requestResult = this.request.requestResult;
|
|
||||||
let enable = this.request.enable;
|
|
||||||
this.$get("/api/testcase/get/" + this.request.id, response => {
|
|
||||||
if (response.data) {
|
|
||||||
let hashTree = [];
|
|
||||||
if (this.request.hashTree) {
|
|
||||||
hashTree = JSON.parse(JSON.stringify(this.request.hashTree));
|
|
||||||
}
|
|
||||||
Object.assign(this.request, JSON.parse(response.data.request));
|
|
||||||
this.request.name = response.data.name;
|
|
||||||
this.request.referenced = "REF";
|
|
||||||
this.request.enable = enable;
|
|
||||||
if (response.data.path && response.data.path != null) {
|
|
||||||
this.request.path = response.data.path;
|
|
||||||
this.request.url = response.data.url;
|
|
||||||
}
|
|
||||||
if (response.data.method && response.data.method != null) {
|
|
||||||
this.request.method = response.data.method;
|
|
||||||
}
|
|
||||||
if (requestResult && Object.prototype.toString.call(requestResult) !== '[object Array]') {
|
|
||||||
this.request.requestResult = [requestResult];
|
|
||||||
} else {
|
|
||||||
this.request.requestResult = requestResult;
|
|
||||||
}
|
|
||||||
if (response.data.num) {
|
|
||||||
this.request.num = response.data.num;
|
|
||||||
}
|
|
||||||
this.request.id = response.data.id;
|
|
||||||
this.request.disabled = true;
|
|
||||||
this.request.root = true;
|
|
||||||
this.request.projectId = response.data.projectId;
|
|
||||||
this.request.versionName = response.data.versionName;
|
|
||||||
this.request.versionEnable = response.data.versionEnable;
|
|
||||||
let req = JSON.parse(response.data.request);
|
|
||||||
if (req && this.request) {
|
|
||||||
this.request.hashTree = hashTree;
|
|
||||||
this.mergeHashTree(req.hashTree);
|
|
||||||
}
|
|
||||||
this.initDataSource();
|
|
||||||
this.forStatus();
|
|
||||||
this.sort();
|
|
||||||
this.reload();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (this.request.id && this.request.referenced === 'Copy') {
|
|
||||||
if (this.request.refType === 'CASE') {
|
|
||||||
this.$get("/api/testcase/get/" + this.request.id, response => {
|
|
||||||
if (response.data) {
|
|
||||||
if (response.data.num) {
|
|
||||||
this.request.num = response.data.num;
|
|
||||||
}
|
|
||||||
this.request.id = response.data.id;
|
|
||||||
this.request.versionName = response.data.versionName;
|
|
||||||
this.request.versionEnable = response.data.versionEnable;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (this.request.refType === 'API') {
|
|
||||||
this.$get("/api/definition/get/" + this.request.id, response => {
|
|
||||||
if (response.data) {
|
|
||||||
if (response.data.num) {
|
|
||||||
this.request.num = response.data.num;
|
|
||||||
}
|
|
||||||
this.request.id = response.data.id;
|
|
||||||
this.request.versionName = response.data.versionName;
|
|
||||||
this.request.versionEnable = response.data.versionEnable;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mergeHashTree(targetHashTree) {
|
mergeHashTree(targetHashTree) {
|
||||||
let sourceHashTree = this.request.hashTree;
|
let sourceHashTree = this.request.hashTree;
|
||||||
// 历史数据兼容
|
// 历史数据兼容
|
||||||
|
|
|
@ -161,14 +161,17 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'request.dataSourceId'() {
|
|
||||||
this.setDataSource();
|
|
||||||
},
|
|
||||||
'request.hashTree': {
|
'request.hashTree': {
|
||||||
handler(v) {
|
handler(v) {
|
||||||
this.initStepSize(this.request.hashTree);
|
this.initStepSize(this.request.hashTree);
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
|
},
|
||||||
|
'$store.state.scenarioEnvMap': {
|
||||||
|
handler(v) {
|
||||||
|
this.getEnvironments();
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -248,18 +251,25 @@
|
||||||
this.environments.forEach(environment => {
|
this.environments.forEach(environment => {
|
||||||
parseEnvironment(environment);
|
parseEnvironment(environment);
|
||||||
});
|
});
|
||||||
if (!this.request.environmentId) {
|
|
||||||
this.request.environmentId = this.$store.state.useEnvironment;
|
|
||||||
}
|
|
||||||
let hasEnvironment = false;
|
let hasEnvironment = false;
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
if (this.environments[i].id === this.request.environmentId) {
|
if (this.environments[i].id === this.request.environmentId) {
|
||||||
|
if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map) {
|
||||||
|
if (this.$store.state.scenarioEnvMap.has(this.projectId) &&
|
||||||
|
this.$store.state.scenarioEnvMap.get(this.projectId) === this.request.environmentId) {
|
||||||
hasEnvironment = true;
|
hasEnvironment = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hasEnvironment = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasEnvironment) {
|
if (!hasEnvironment) {
|
||||||
this.request.environmentId = undefined;
|
if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map
|
||||||
|
&& this.$store.state.scenarioEnvMap.has(this.projectId)) {
|
||||||
|
this.request.environmentId = this.$store.state.scenarioEnvMap.get(this.projectId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!this.request.environmentId) {
|
if (!this.request.environmentId) {
|
||||||
this.request.dataSourceId = undefined;
|
this.request.dataSourceId = undefined;
|
||||||
|
@ -272,16 +282,25 @@
|
||||||
},
|
},
|
||||||
initDataSource() {
|
initDataSource() {
|
||||||
let flag = false;
|
let flag = false;
|
||||||
|
let environment = {};
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
if (this.environments[i].id === this.request.environmentId) {
|
if (this.environments[i].id === this.request.environmentId) {
|
||||||
|
environment = this.environments[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.databaseConfigsOptions = [];
|
this.databaseConfigsOptions = [];
|
||||||
this.environments[i].config.databaseConfigs.forEach(item => {
|
if (environment.config && environment.config.databaseConfigs) {
|
||||||
|
environment.config.databaseConfigs.forEach(item => {
|
||||||
if (item.id === this.request.dataSourceId) {
|
if (item.id === this.request.dataSourceId) {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
this.databaseConfigsOptions.push(item);
|
this.databaseConfigsOptions.push(item);
|
||||||
});
|
});
|
||||||
break;
|
if (!flag && environment.config.databaseConfigs.length > 0) {
|
||||||
|
this.request.dataSourceId = environment.config.databaseConfigs[0].id;
|
||||||
|
flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
|
@ -332,10 +351,6 @@
|
||||||
margin-left: 60px;
|
margin-left: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-left-cell {
|
|
||||||
margin-top: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ms-header {
|
.ms-header {
|
||||||
background: #783887;
|
background: #783887;
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -349,10 +364,6 @@
|
||||||
padding: 7px;
|
padding: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-left-buttion {
|
|
||||||
margin: 6px 0px 8px 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/deep/ .el-form-item {
|
/deep/ .el-form-item {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue