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()); 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.getProjectIds().add(http.getProjectId());
env.setFullUrl(false); env.setFullUrl(false);
} }
@ -132,7 +133,8 @@ public class ApiScenarioEnvService {
if (StringUtils.equals(testElement.getType(), "HTTPSamplerProxy")) { if (StringUtils.equals(testElement.getType(), "HTTPSamplerProxy")) {
// 校验是否是全路径 // 校验是否是全路径
MsHTTPSamplerProxy httpSamplerProxy = (MsHTTPSamplerProxy) testElement; 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.getProjectIds().add(httpSamplerProxy.getProjectId());
env.setFullUrl(false); env.setFullUrl(false);
} }

View File

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

View File

@ -350,7 +350,8 @@ public class ApiExecutionQueueService {
if (report == null) { if (report == null) {
executionQueueDetailMapper.deleteByPrimaryKey(item.getId()); 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.getUpdateTime() < timeout) {
report.setStatus(ScenarioStatus.Timeout.name()); report.setStatus(ScenarioStatus.Timeout.name());
apiScenarioReportMapper.updateByPrimaryKeySelective(report); apiScenarioReportMapper.updateByPrimaryKeySelective(report);

View File

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

View File

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

View File

@ -259,9 +259,12 @@ export default {
setOwnEnvironment(scenarioDefinition) { setOwnEnvironment(scenarioDefinition) {
for (let i in scenarioDefinition) { for (let i in scenarioDefinition) {
let typeArray = ["JDBCPostProcessor", "JDBCSampler", "JDBCPreProcessor"] 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; scenarioDefinition[i].environmentId = this.request.environmentId;
scenarioDefinition[i].dataSourceId = this.request.dataSourceId; if (this.request.dataSourceId && !scenarioDefinition[i].dataSourceId) {
scenarioDefinition[i].dataSourceId = this.request.dataSourceId;
}
} }
} }
}, },