From b40cd1c426f72c105e3ed3bae750a8aa7bdd5519 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 26 Apr 2022 18:03:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E=E5=89=8D?= =?UTF-8?q?=E5=90=8E=E7=BD=AE=E6=AD=A5=E9=AA=A4=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1012764 --user=赵勇 【接口测试】接口前后置sql添加后,再添加其他前后置操作,数据源会消失 https://www.tapd.cn/55049933/s/1148430 --- .../api/exec/scenario/ApiScenarioEnvService.java | 6 ++++-- .../api/service/ApiDefinitionExecResultService.java | 1 - .../metersphere/api/service/ApiExecutionQueueService.java | 3 ++- .../components/api/automation/scenario/EditApiScenario.vue | 6 +++--- .../api/definition/components/case/ApiCaseList.vue | 2 +- .../components/api/definition/components/step/JmxStep.vue | 7 +++++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java index 0a0847f58b..da8e031240 100644 --- a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java +++ b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java @@ -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); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index f7f42f4c18..5ef302433a 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -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()); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java b/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java index 548f67d785..1454277f6c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java @@ -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); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index ca201efe18..90e97b4fbb 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -1626,10 +1626,10 @@ export default { this.sort(); this.$nextTick(() => { this.cancelBatchProcessing(); - if (isRefresh) { - this.reloadTree = getUUID(); - } }); + if (isRefresh) { + this.reloadTree = getUUID(); + } // 记录初始化数据 let v1 = { apiScenarioModuleId: this.currentScenario.apiScenarioModuleId, diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue index 51119a8603..7065f2a66f 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue @@ -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; diff --git a/frontend/src/business/components/api/definition/components/step/JmxStep.vue b/frontend/src/business/components/api/definition/components/step/JmxStep.vue index 55b5d034da..84d8981826 100644 --- a/frontend/src/business/components/api/definition/components/step/JmxStep.vue +++ b/frontend/src/business/components/api/definition/components/step/JmxStep.vue @@ -259,9 +259,12 @@ 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; - scenarioDefinition[i].dataSourceId = this.request.dataSourceId; + if (this.request.dataSourceId && !scenarioDefinition[i].dataSourceId) { + scenarioDefinition[i].dataSourceId = this.request.dataSourceId; + } } } },