fix(接口测试): 修复切换公共数据源,不同协议接口步骤未跟随变更问题

--bug=1015391 --user=赵勇 【接口测试】所有协议包含http和其他协议接口TEST页面添加前后置sql,右上角切换数据源时,不展开的前后置sql不会更新数据源 https://www.tapd.cn/55049933/s/1212544
This commit is contained in:
fit2-zhao 2022-07-26 18:04:57 +08:00 committed by f2c-ci-robot[bot]
parent f0b70102ed
commit 0c444ec328
2 changed files with 82 additions and 4 deletions

View File

@ -404,6 +404,9 @@ public class ApiExecutionQueueService {
continue;
}
// 检查是否已经超时
ResultDTO dto = new ResultDTO();
dto.setQueueId(item.getQueueId());
dto.setTestId(item.getTestId());
if (StringUtils.equalsAnyIgnoreCase(queue.getRunMode(),
ApiRunMode.SCENARIO.name(),
ApiRunMode.SCENARIO_PLAN.name(),
@ -422,9 +425,6 @@ public class ApiExecutionQueueService {
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
LoggerUtil.info("超时处理报告:" + report.getId());
ResultDTO dto = new ResultDTO();
dto.setQueueId(item.getQueueId());
dto.setTestId(item.getTestId());
if (queue != null && StringUtils.equalsIgnoreCase(item.getType(), RunModeConstants.SERIAL.toString())) {
// 删除串行资源锁
redisTemplate.delete(RunModeConstants.SERIAL.name() + "_" + dto.getReportId());
@ -447,6 +447,12 @@ public class ApiExecutionQueueService {
result.setStatus(ScenarioStatus.Timeout.name());
apiDefinitionExecResultMapper.updateByPrimaryKeySelective(result);
executionQueueDetailMapper.deleteByPrimaryKey(item.getId());
dto.setTestPlanReportId(queue.getReportId());
dto.setReportId(queue.getReportId());
dto.setRunMode(queue.getRunMode());
dto.setRunType(item.getType());
dto.setReportType(queue.getReportType());
queueNext(dto);
}
}
}

View File

@ -132,12 +132,13 @@ import {createComponent} from "../jmeter/components";
import MsApiAssertions from "../assertion/ApiAssertions";
import MsApiExtract from "../extract/ApiExtract";
import {Assertions, Body, ConstantTimer, Extract, KeyValue} from "../../model/ApiTestModel";
import {getUUID} from "@/common/js/utils";
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
import BatchAddParameter from "../basis/BatchAddParameter";
import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
import MsConstantTimer from "../../../automation/scenario/component/ConstantTimer";
import MsJdbcProcessor from "@/business/components/api/automation/scenario/component/JDBCProcessor";
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
import {parseEnvironment} from "../../model/EnvironmentModel";
export default {
name: "MsJmxStep",
@ -177,6 +178,14 @@ export default {
default: false
}
},
watch: {
// /
'$store.state.useEnvironment': function () {
if (this.request.hashTree && this.request.hashTree.length > 0 && !this.scenarioId) {
this.setSubset(this.request.hashTree, this.$store.state.useEnvironment);
}
},
},
data() {
let validateURL = (rule, value, callback) => {
try {
@ -220,6 +229,7 @@ export default {
isReloadData: false,
isBodyShow: true,
dialogVisible: false,
environments: [],
}
},
created() {
@ -271,6 +281,67 @@ export default {
this.sort();
this.reload();
},
setSubset(scenarioDefinition, env) {
for (let i in scenarioDefinition) {
let typeArray = ["JDBCPostProcessor", "JDBCSampler", "JDBCPreProcessor"]
if (typeArray.indexOf(scenarioDefinition[i].type) !== -1) {
//
this.getTargetSource(scenarioDefinition[i])
scenarioDefinition[i].environmentId = env;
this.setSameSourceId(env, scenarioDefinition[i])
}
if (scenarioDefinition[i].hashTree !== undefined && scenarioDefinition[i].hashTree.length > 0) {
this.setSubset(scenarioDefinition[i].hashTree, env);
}
}
},
getEnvs() {
if (!this.scenarioId) {
let projectId = this.request.projectId ? this.request.projectId : getCurrentProjectID();
this.result = this.$get('/api/environment/list/' + projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
});
});
}
},
getTargetSource(obj) {
this.environments.forEach(environment => {
//
if (environment.id === obj.environmentId) {
if (environment.config && environment.config.databaseConfigs) {
environment.config.databaseConfigs.forEach(item => {
if (item.id === obj.dataSourceId) {
obj.targetDataSourceName = item.name;
}
});
}
}
});
},
setSameSourceId(envId, obj) {
let currentEnvironment;
for (let i in this.environments) {
if (this.environments[i].id === envId) {
currentEnvironment = this.environments[i];
break;
}
}
let isSame = false;
if (currentEnvironment && currentEnvironment.config && currentEnvironment.config.databaseConfigs) {
currentEnvironment.config.databaseConfigs.forEach(item => {
//
if (item.name === obj.targetDataSourceName) {
obj.dataSourceId = item.id;
isSame = true;
}
});
if (!isSame && currentEnvironment.config.databaseConfigs.length > 0) {
obj.dataSourceId = currentEnvironment.config.databaseConfigs[0].id;
}
}
},
setOwnEnvironment(scenarioDefinition) {
for (let i in scenarioDefinition) {
let typeArray = ["JDBCPostProcessor", "JDBCSampler", "JDBCPreProcessor"]
@ -455,6 +526,7 @@ export default {
this.request.arguments = [];
}
this.sort();
this.getEnvs();
},
sort() {
let index = 1;