diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigUtil.java b/api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigDTO.java similarity index 81% rename from api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigUtil.java rename to api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigDTO.java index ed5b3aa5f1..a282ab3548 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/ApiReportEnvConfigDTO.java @@ -5,7 +5,7 @@ import lombok.Setter; @Setter @Getter -public class ApiReportEnvConfigUtil { +public class ApiReportEnvConfigDTO { private String envName; diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java index b6db672028..d760b70268 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java @@ -89,12 +89,13 @@ public class JMeterService { * @param testId * @param testPlan */ - private void addDebugListener(String testId, HashTree testPlan) { + private void addDebugListener(String testId, HashTree testPlan, String runMode) { MsDebugListener resultCollector = new MsDebugListener(); resultCollector.setName(testId); resultCollector.setProperty(TestElement.TEST_CLASS, MsDebugListener.class.getName()); resultCollector.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ViewResultsFullVisualizer")); resultCollector.setEnabled(true); + resultCollector.setRunMode(runMode); // 添加DEBUG标示 HashTree test = ArrayUtils.isNotEmpty(testPlan.getArray()) ? testPlan.getTree(testPlan.getArray()[0]) : null; @@ -125,12 +126,12 @@ public class JMeterService { && request.getExtendedParameters().containsKey(ExtendedParameter.SYNC_STATUS) && (Boolean) request.getExtendedParameters().get(ExtendedParameter.SYNC_STATUS)) { LoggerUtil.debug("为请求 [ " + request.getReportId() + " ] 添加Debug Listener"); - addDebugListener(request.getReportId(), request.getHashTree()); + addDebugListener(request.getReportId(), request.getHashTree(), request.getRunMode()); } if (request.isDebug()) { LoggerUtil.debug("为请求 [ " + request.getReportId() + " ] 添加Debug Listener"); - addDebugListener(request.getReportId(), request.getHashTree()); + addDebugListener(request.getReportId(), request.getHashTree(), request.getRunMode()); } else { LoggerUtil.debug("为请求 [ " + request.getReportId() + " ] 添加同步接收结果 Listener"); JMeterBase.addBackendListener(request, request.getHashTree(), MsApiBackendListener.class.getCanonicalName()); diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java index 49a88805f1..eede8b7971 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java @@ -54,12 +54,18 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi public static final String TEST_END = "MS_TEST_END"; + private String runMode; + @Override public Object clone() { MsDebugListener clone = (MsDebugListener) super.clone(); return clone; } + public void setRunMode(String runMode) { + this.runMode = runMode; + } + public boolean isErrorLogging() { return getPropertyAsBoolean(ERROR_LOGGING); } @@ -152,6 +158,7 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi dto.setReportId("send." + this.getName()); dto.setToReport(this.getName()); + dto.setRunMode(runMode); String console = FixedCapacityUtil.getJmeterLogger(this.getName(), false); ApiDefinitionEnvService apiDefinitionEnvService = CommonBeanFactory.getBean(ApiDefinitionEnvService.class); if (StringUtils.isNotEmpty(requestResult.getName()) && requestResult.getName().startsWith("Transaction=")) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionEnvService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionEnvService.java index 7d5529e9ef..949490d940 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionEnvService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionEnvService.java @@ -1,6 +1,6 @@ package io.metersphere.service.definition; -import io.metersphere.api.dto.ApiReportEnvConfigUtil; +import io.metersphere.api.dto.ApiReportEnvConfigDTO; import io.metersphere.api.dto.MsgDTO; import io.metersphere.api.dto.RequestResultExpandDTO; import io.metersphere.base.domain.ApiDefinitionEnv; @@ -80,7 +80,7 @@ public class ApiDefinitionEnvService { if (StringUtils.isNotBlank(baseResult.getThreadName())) { ApiDefinitionExecResultWithBLOBs result = apiDefinitionExecResultMapper.selectByPrimaryKey(baseResult.getThreadName()); if (result != null && StringUtils.isNotEmpty(result.getEnvConfig())) { - ApiReportEnvConfigUtil envConfig = apiDefinitionService.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()); + ApiReportEnvConfigDTO envConfig = apiDefinitionService.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()); if (envConfig != null) { expandDTO.setEnvName(envConfig.getEnvName()); expandDTO.setPoolName(envConfig.getResourcePoolName()); @@ -93,7 +93,7 @@ public class ApiDefinitionEnvService { if (StringUtils.isNotBlank(dto.getToReport())) { ApiDefinitionExecResultWithBLOBs result = apiDefinitionExecResultMapper.selectByPrimaryKey(dto.getToReport()); if (result != null && StringUtils.isNotEmpty(result.getEnvConfig())) { - ApiReportEnvConfigUtil envConfig = apiDefinitionService.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()); + ApiReportEnvConfigDTO envConfig = apiDefinitionService.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()); if (envConfig != null) { Map map = JSON.parseObject(dto.getContent().substring(7), Map.class); map.put("envName", envConfig.getEnvName()); diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java index 4f76c21954..6ca0f67127 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java @@ -960,7 +960,7 @@ public class ApiDefinitionService { if (StringUtils.isNotBlank(contentStr)) { JSONObject content = JSONUtil.parseObject(contentStr); if (StringUtils.isNotEmpty(result.getEnvConfig())) { - ApiReportEnvConfigUtil envNameByEnvConfig = this.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()); + ApiReportEnvConfigDTO envNameByEnvConfig = this.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()); if (envNameByEnvConfig != null) { content.put("envName", envNameByEnvConfig.getEnvName()); content.put("poolName", envNameByEnvConfig.getResourcePoolName()); @@ -975,8 +975,8 @@ public class ApiDefinitionService { return reportResult; } - public ApiReportEnvConfigUtil getEnvNameByEnvConfig(String projectId, String envConfig) { - ApiReportEnvConfigUtil apiReportEnvConfig = new ApiReportEnvConfigUtil(); + public ApiReportEnvConfigDTO getEnvNameByEnvConfig(String projectId, String envConfig) { + ApiReportEnvConfigDTO apiReportEnvConfig = new ApiReportEnvConfigDTO(); RunModeConfigDTO runModeConfigDTO = null; try { runModeConfigDTO = JSON.parseObject(envConfig, RunModeConfigDTO.class);