From cf4ca36b97d325621674df287df4106645052029 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 2 Jun 2023 18:47:56 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=9C=BA=E6=99=AF=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1026626 --user=王孝刚 [接口测试]GitHub#24694场景加载环境报错,无法调试 (特殊数据) https://www.tapd.cn/55049933/s/1378398 --- .../api/exec/api/ApiExecuteService.java | 3 --- .../service/scenario/ApiScenarioService.java | 10 +++++++--- api-test/frontend/src/api/scenario.js | 14 +++++++++++++- .../automation/scenario/EditApiScenario.vue | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java index a80b91bdf0..05ddbe8e70 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java @@ -133,9 +133,6 @@ public class ApiExecuteService { : request.getReportId(), request.getRunMode(), null); if (testCase != null && StringUtils.isNotEmpty(testCase.getRequest())) { try { - HashTree jmeterHashTree = this.generateHashTree(request, testCase, runModeConfigDTO); - // 调用执行方法 - runRequest.setHashTree(jmeterHashTree); if (MapUtils.isNotEmpty(extendedParameters)) { runRequest.setExtendedParameters(extendedParameters); } diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index daa9c0e8d4..47649f6777 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -801,16 +801,20 @@ public class ApiScenarioService { public ParameterConfig getConfig(ApiScenarioDTO scenario) { try { + ParameterConfig config = new ParameterConfig(); Map environmentMap = new HashMap<>(); String environmentType = scenario.getEnvironmentType(); String environmentGroupId = scenario.getEnvironmentGroupId(); String environmentJson = scenario.getEnvironmentJson(); - if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) { + if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name()) + && StringUtils.isNotEmpty(environmentGroupId)) { environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId); - } else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) { + } else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name()) + && StringUtils.isNotEmpty(environmentJson)) { environmentMap = JSON.parseObject(environmentJson, Map.class); + } else { + return config; } - ParameterConfig config = new ParameterConfig(); apiScenarioEnvService.setEnvConfig(environmentMap, config); return config; } catch (Exception e) { diff --git a/api-test/frontend/src/api/scenario.js b/api-test/frontend/src/api/scenario.js index a12bf7e31b..8d80299dc2 100644 --- a/api-test/frontend/src/api/scenario.js +++ b/api-test/frontend/src/api/scenario.js @@ -103,8 +103,20 @@ export function listWithIds(params) { return post('/api/automation/list-blobs', params); } +export function getUploadConfig(url, formData) { + return { + method: 'POST', + url: url, + data: formData, + headers: { + 'Content-Type': "application/octet-stream", + }, + }; +} + export function getApiScenarioEnv(params) { - return post('/api/automation/scenario-env', params); + let reqParams = getUploadConfig('/api/automation/scenario-env', params); + return request( reqParams); } export function batchEditScenario(params) { diff --git a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue index 6ca4434a93..cb0f41a7de 100644 --- a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue +++ b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue @@ -1965,7 +1965,7 @@ export default { return new Promise((resolve) => { const encoder = new TextEncoder(); const bytes = encoder.encode(definition, 'utf-8'); - getApiScenarioEnv({ definition: bytes }).then((res) => { + getApiScenarioEnv(bytes ).then((res) => { if (res.data) { this.projectIds = new Set(res.data.projectIds); this.projectIds.add(this.projectId);