fix(接口测试): 修复用例新增前后置步骤数据源切换错误问题

--bug=1012764 --user=赵勇 【接口测试】接口前后置sql添加后,再添加其他前后置操作,数据源会消失 https://www.tapd.cn/55049933/s/1148430
This commit is contained in:
fit2-zhao 2022-04-26 18:03:47 +08:00 committed by fit2-zhao
parent 9b9ff8a266
commit b40cd1c426
6 changed files with 15 additions and 10 deletions

View File

@ -95,7 +95,8 @@ public class ApiScenarioEnvService {
http.setUrl(StringUtils.equals(testElement.getRefType(), "CASE") ? null : http.getUrl());
// 非全路径校验
if (StringUtils.isBlank(http.getUrl()) || (http.getIsRefEnvironment() != null && http.getIsRefEnvironment())) {
if (!StringUtils.equalsIgnoreCase(http.getReferenced(), "Created") || (http.getIsRefEnvironment() != null &&
http.getIsRefEnvironment())) {
env.getProjectIds().add(http.getProjectId());
env.setFullUrl(false);
}
@ -132,7 +133,8 @@ public class ApiScenarioEnvService {
if (StringUtils.equals(testElement.getType(), "HTTPSamplerProxy")) {
// 校验是否是全路径
MsHTTPSamplerProxy httpSamplerProxy = (MsHTTPSamplerProxy) testElement;
if (StringUtils.isBlank(httpSamplerProxy.getUrl()) || (httpSamplerProxy.getIsRefEnvironment() != null && httpSamplerProxy.getIsRefEnvironment())) {
if (!StringUtils.equalsIgnoreCase(httpSamplerProxy.getReferenced(), "Created") || (httpSamplerProxy.getIsRefEnvironment() != null &&
httpSamplerProxy.getIsRefEnvironment())) {
env.getProjectIds().add(httpSamplerProxy.getProjectId());
env.setFullUrl(false);
}

View File

@ -433,7 +433,6 @@ public class ApiDefinitionExecResultService {
saveResult.setType(type);
saveResult.setStatus(status);
saveResult.setResourceId(item.getName());
saveResult.setStartTime(item.getStartTime());
saveResult.setEndTime(item.getEndTime());

View File

@ -350,7 +350,8 @@ public class ApiExecutionQueueService {
if (report == null) {
executionQueueDetailMapper.deleteByPrimaryKey(item.getId());
}
if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), TestPlanReportStatus.RUNNING.name(), APITestStatus.Waiting.name())
// 这里只处理已经开始执行的队列如果 报告状态是 Waiting 表示还没开始暂不处理
if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), TestPlanReportStatus.RUNNING.name())
&& report.getUpdateTime() < timeout) {
report.setStatus(ScenarioStatus.Timeout.name());
apiScenarioReportMapper.updateByPrimaryKeySelective(report);

View File

@ -1626,10 +1626,10 @@ export default {
this.sort();
this.$nextTick(() => {
this.cancelBatchProcessing();
});
if (isRefresh) {
this.reloadTree = getUUID();
}
});
//
let v1 = {
apiScenarioModuleId: this.currentScenario.apiScenarioModuleId,

View File

@ -291,7 +291,7 @@ export default {
this.$emit('refreshModule');
},
setNewSource(environment, obj) {
if (environment.config && environment.config.databaseConfigs) {
if (environment.config && environment.config.databaseConfigs && environment.config.databaseConfigs.length > 0) {
let dataSources = environment.config.databaseConfigs.filter(item => item.name === obj.targetDataSourceName);
if (dataSources && dataSources.length > 0) {
obj.dataSourceId = dataSources[0].id;

View File

@ -259,11 +259,14 @@ export default {
setOwnEnvironment(scenarioDefinition) {
for (let i in scenarioDefinition) {
let typeArray = ["JDBCPostProcessor", "JDBCSampler", "JDBCPreProcessor"]
if (typeArray.indexOf(scenarioDefinition[i].type) !== -1) {
if (typeArray.indexOf(scenarioDefinition[i].type) !== -1
&& this.request.environmentId && !scenarioDefinition[i].environmentId) {
scenarioDefinition[i].environmentId = this.request.environmentId;
if (this.request.dataSourceId && !scenarioDefinition[i].dataSourceId) {
scenarioDefinition[i].dataSourceId = this.request.dataSourceId;
}
}
}
},
filterNode(value, data) {
if (data.type && value.indexOf(data.type) !== -1) {