diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index e74455f337..8d91e360f6 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -91,6 +91,7 @@ public class MsScenario extends MsTestElement { HashTree scenarioTree = tree; // 取出自身场景环境 ParameterConfig newConfig = new ParameterConfig(this.getProjectId(), false); + newConfig.setReportId(config.getReportId()); if (this.isEnvironmentEnable()) { this.setNewConfig(newConfig); newConfig.setRetryNum(config.getRetryNum()); diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 29fb6aea05..9ccad6f042 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -136,6 +136,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName()); sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HttpTestSampleGui")); String resourceId = ElementUtil.setBaseParams(sampler, this.getParent(), config, this.getId(), this.getIndex()); + resourceId = StringUtils.isNotBlank(config.getReportId()) ? config.getReportId() : resourceId; + LogUtil.info("设置SSL证书配置{}", resourceId); + sampler.setProperty("MS-KEYSTORE-ID", resourceId); sampler.setMethod(this.getMethod()); sampler.setContentEncoding(StandardCharsets.UTF_8.name()); @@ -551,7 +554,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { keystoreConfig.setProperty("startIndex", 0); keystoreConfig.setProperty(ElementConstants.MS_KEYSTORE_FILE_PATH, msKeyStore.getPath()); keystoreConfig.setProperty(ElementConstants.MS_KEYSTORE_FILE_PASSWORD, msKeyStore.getPassword()); - keystoreConfig.setProperty("MS-RESOURCE-ID", resourceId); + keystoreConfig.setProperty("MS-KEYSTORE-ID", resourceId); httpSamplerTree.add(keystoreConfig); config.getKeyStoreMap().put(this.getProjectId(), new MsKeyStore(msKeyStore.getPath(), msKeyStore.getPassword())); } diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java index e0bb6576a1..7ca0f8d2c5 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java @@ -140,6 +140,7 @@ public class ApiCaseSerialService { if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) { config.setRetryNum(runRequest.getRetryNum()); } + config.setReportId(runRequest.getReportId()); testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), config); LoggerUtil.info("用例资源:" + caseWithBLOBs.getName() + ", 生成执行脚本JMX成功", runRequest.getReportId()); return jmeterHashTree; diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java index 6bab3e7e4d..14abf18e0a 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java @@ -442,6 +442,7 @@ public class ApiScenarioExecuteService { } ParameterConfig config = new ParameterConfig(request.getProjectId(), false); config.setScenarioId(request.getScenarioId()); + config.setReportId(request.getReportId()); if (MapUtils.isNotEmpty(request.getEnvironmentMap())) { apiScenarioEnvService.setEnvConfig(request.getEnvironmentMap(), config); } diff --git a/api-test/backend/src/main/java/io/metersphere/commons/utils/GenerateHashTreeUtil.java b/api-test/backend/src/main/java/io/metersphere/commons/utils/GenerateHashTreeUtil.java index 364bd95dc7..4291d24d5e 100644 --- a/api-test/backend/src/main/java/io/metersphere/commons/utils/GenerateHashTreeUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/commons/utils/GenerateHashTreeUtil.java @@ -157,6 +157,8 @@ public class GenerateHashTreeUtil { config.setScenarioId(item.getId()); config.setReportType(runRequest.getReportType()); config.setConfig(getEnv(scenario.getEnvironmentMap())); + config.setReportId(runRequest.getReportId()); + if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) { config.setRetryNum(runRequest.getRetryNum()); } diff --git a/api-test/backend/src/main/java/io/metersphere/service/ApiJMeterFileService.java b/api-test/backend/src/main/java/io/metersphere/service/ApiJMeterFileService.java index dc3ea677a1..97feb0edbb 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/ApiJMeterFileService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/ApiJMeterFileService.java @@ -124,6 +124,7 @@ public class ApiJMeterFileService { JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(remoteTestId, reportId, runMode, null); runRequest.setReportType(reportType); runRequest.setQueueId(queueId); + runRequest.setReportId(reportId); BooleanPool booleanPool = new BooleanPool(); booleanPool.setK8s(true); runRequest.setPool(booleanPool); diff --git a/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/config/KeystoreConfig.java b/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/config/KeystoreConfig.java index 7018d94961..24031c118b 100644 --- a/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/config/KeystoreConfig.java +++ b/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/config/KeystoreConfig.java @@ -56,7 +56,7 @@ public class KeystoreConfig extends ConfigTestElement implements TestBean, TestS @Override public void testEnded(String host) { log.info("Destroying Keystore"); - String resourceId = this.getPropertyAsString("MS-RESOURCE-ID"); + String resourceId = this.getPropertyAsString("MS-KEYSTORE-ID"); SSLManager.getInstance().destroyKeystore(resourceId); } @@ -101,7 +101,7 @@ public class KeystoreConfig extends ConfigTestElement implements TestBean, TestS String path = this.getPropertyAsString("MS-KEYSTORE-FILE-PATH"); String password = this.getPropertyAsString("MS-KEYSTORE-FILE-PASSWORD"); // 获取请求上的资源ID - String resourceId = this.getPropertyAsString("MS-RESOURCE-ID"); + String resourceId = this.getPropertyAsString("MS-KEYSTORE-ID"); if (StringUtils.isNotBlank(resourceId)) { KeystoreDTO dto = new KeystoreDTO(); dto.setStartIndex(startIndexAsInt); diff --git a/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/util/SSLManager.java b/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/util/SSLManager.java index 2ef115327b..0e3b2e0a3a 100644 --- a/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/util/SSLManager.java +++ b/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/util/SSLManager.java @@ -150,7 +150,7 @@ public abstract class SSLManager { // 重新加载认证文件 JMeterContext threadContext = JMeterContextService.getContext(); if (threadContext != null && threadContext.getCurrentSampler() != null) { - String resourceId = threadContext.getCurrentSampler().getPropertyAsString("MS-RESOURCE-ID"); + String resourceId = threadContext.getCurrentSampler().getPropertyAsString("MS-KEYSTORE-ID"); if (StringUtils.isNotBlank(resourceId) && keyMap.containsKey(resourceId)) { log.info("重新加载认证文件{}", resourceId); KeystoreDTO dto = keyMap.get(resourceId); @@ -371,7 +371,7 @@ public abstract class SSLManager { // 重新加载认证文件 JMeterContext threadContext = JMeterContextService.getContext(); if (threadContext != null && threadContext.getCurrentSampler() != null) { - String resourceId = threadContext.getCurrentSampler().getPropertyAsString("MS-RESOURCE-ID"); + String resourceId = threadContext.getCurrentSampler().getPropertyAsString("MS-KEYSTORE-ID"); if (StringUtils.isNotBlank(resourceId) && keyMap.containsKey(resourceId)) { log.info("重新加载认证文件{}", resourceId); KeystoreDTO dto = keyMap.get(resourceId);