fix(接口定义): 修复本地执行不显示资源池的缺陷
This commit is contained in:
parent
2faa8533a2
commit
26936d760d
|
@ -5,7 +5,7 @@ import lombok.Setter;
|
|||
|
||||
@Setter
|
||||
@Getter
|
||||
public class ApiReportEnvConfigUtil {
|
||||
public class ApiReportEnvConfigDTO {
|
||||
|
||||
private String envName;
|
||||
|
|
@ -11,7 +11,10 @@ import io.metersphere.commons.config.KafkaConfig;
|
|||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.ExtendedParameter;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.commons.utils.FixedCapacityUtil;
|
||||
import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
||||
import io.metersphere.commons.utils.HashTreeUtil;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
import io.metersphere.config.JmeterProperties;
|
||||
import io.metersphere.constants.BackendListenerConstants;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
|
@ -21,9 +24,9 @@ import io.metersphere.dto.RunModeConfigDTO;
|
|||
import io.metersphere.engine.Engine;
|
||||
import io.metersphere.jmeter.JMeterBase;
|
||||
import io.metersphere.jmeter.LocalRunner;
|
||||
import io.metersphere.service.ApiPoolDebugService;
|
||||
import io.metersphere.service.RemakeReportService;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.service.ApiPoolDebugService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -91,12 +94,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;
|
||||
|
@ -127,12 +131,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,6 +54,8 @@ 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();
|
||||
|
@ -64,6 +66,10 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi
|
|||
return getPropertyAsBoolean(ERROR_LOGGING);
|
||||
}
|
||||
|
||||
public void setRunMode(String runMode) {
|
||||
this.runMode = runMode;
|
||||
}
|
||||
|
||||
public final void setSuccessOnlyLogging(boolean value) {
|
||||
if (value) {
|
||||
setProperty(new BooleanProperty(SUCCESS_ONLY_LOGGING, true));
|
||||
|
@ -151,6 +157,7 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi
|
|||
dto.setExecEnd(false);
|
||||
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);
|
||||
|
|
|
@ -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