From b49a8bde80d91d19bb2cd2311bc1ab9baf581626 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 19 Apr 2022 17:10:11 +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=E5=AF=BC=E5=85=A5JMX=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AF=B7=E6=B1=82=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=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=1012410 --user=赵勇 [接口测试] github#12793接口自动化导入jmx文件, 第一次执行,接口请求返回404 https://www.tapd.cn/55049933/s/1139654 --- .../metersphere/api/dto/automation/parse/MsJmeterParser.java | 1 + .../api/dto/definition/request/unknown/MsJmeterElement.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java index 9f2f3614e8..d66e580fcf 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java @@ -333,6 +333,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { if (url != null) { samplerProxy.setUrl(this.getUrl(source)); samplerProxy.setPath(null); + samplerProxy.setCustomizeReq(true); } samplerProxy.setId(UUID.randomUUID().toString()); samplerProxy.setType("HTTPSamplerProxy"); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java index 0d57be5d8a..a88250c9c7 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java @@ -114,6 +114,10 @@ public class MsJmeterElement extends MsTestElement { for (ScenarioVariable item : list) { if (CollectionUtils.isNotEmpty(item.getFiles())) { List names = item.getFiles().stream().map(BodyFile::getName).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(names) && !names.contains(name) && name.contains("_")) { + String pathArr[] = name.split("_"); + name = pathArr[pathArr.length - 1]; + } if (CollectionUtils.isNotEmpty(names) && names.contains(name)) { if (!config.isOperating() && !new File(FileUtils.BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) { MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ CSV文件不存在 ]");