fix(接口定义): 修复本地执行不显示资源池的缺陷
This commit is contained in:
parent
c743c1ee56
commit
7a347115d5
|
@ -5,7 +5,7 @@ import lombok.Setter;
|
|||
|
||||
@Setter
|
||||
@Getter
|
||||
public class ApiReportEnvConfigUtil {
|
||||
public class ApiReportEnvConfigDTO {
|
||||
|
||||
private String envName;
|
||||
|
|
@ -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());
|
||||
|
|
|
@ -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=")) {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue