fix(接口测试): 兼容历史数据
【【接口测试】场景详情-当前项目环境未选择-调试场景-当前项目步骤执获取跨项目环境执行了】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001028870 Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
baac86b26c
commit
a5b3622605
|
@ -14,7 +14,6 @@ import io.metersphere.base.mapper.ApiScenarioMapper;
|
|||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.environment.service.BaseEnvGroupProjectService;
|
||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
|
@ -78,17 +77,7 @@ public class MsScenario extends MsTestElement {
|
|||
|
||||
// 设置共享cookie
|
||||
config.setEnableCookieShare(enableCookieShare);
|
||||
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
|
||||
if (MapUtils.isEmpty(config.getConfig())) {
|
||||
// 兼容历史数据
|
||||
if (this.environmentMap == null || this.environmentMap.isEmpty()) {
|
||||
this.environmentMap = new HashMap<>(16);
|
||||
if (StringUtils.isNotBlank(environmentId)) {
|
||||
// 兼容1.8之前 没有environmentMap但有environmentId的数据
|
||||
this.environmentMap.put(RunModeConstants.HIS_PRO_ID.toString(), environmentId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (MapUtils.isNotEmpty(config.getConfig())) {
|
||||
Map<String, EnvironmentConfig> map = config.getConfig();
|
||||
for (EnvironmentConfig evnConfig : map.values()) {
|
||||
if (evnConfig.getHttpConfig() != null) {
|
||||
|
@ -103,7 +92,7 @@ public class MsScenario extends MsTestElement {
|
|||
// 取出自身场景环境
|
||||
ParameterConfig newConfig = new ParameterConfig(this.getProjectId(), false);
|
||||
if (this.isEnvironmentEnable()) {
|
||||
this.setNewConfig(envConfig, newConfig);
|
||||
this.setNewConfig(newConfig);
|
||||
newConfig.setRetryNum(config.getRetryNum());
|
||||
}
|
||||
if (StringUtils.equals(this.getId(), config.getScenarioId())) {
|
||||
|
@ -232,7 +221,8 @@ public class MsScenario extends MsTestElement {
|
|||
return false;
|
||||
}
|
||||
|
||||
private void setNewConfig(Map<String, EnvironmentConfig> envConfig, ParameterConfig newConfig) {
|
||||
private void setNewConfig( ParameterConfig newConfig) {
|
||||
Map<String, EnvironmentConfig> envConfig = new HashMap<>();
|
||||
if (this.isEnvironmentEnable()) {
|
||||
ApiScenarioMapper apiScenarioMapper = CommonBeanFactory.getBean(ApiScenarioMapper.class);
|
||||
BaseEnvGroupProjectService environmentGroupProjectService = CommonBeanFactory.getBean(BaseEnvGroupProjectService.class);
|
||||
|
|
|
@ -12,7 +12,6 @@ import io.metersphere.base.domain.TestPlanApiCase;
|
|||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ConditionType;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.environment.ssl.MsKeyStore;
|
||||
import io.metersphere.jmeter.utils.ScriptEngineUtils;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
|
@ -206,24 +205,11 @@ public class ParameterConfig extends MsParameter {
|
|||
}
|
||||
|
||||
// 数据兼容处理
|
||||
if (this.getConfig() != null && StringUtils.isNotEmpty(samplerProxy.getProjectId()) && this.getConfig().containsKey(samplerProxy.getProjectId())) {
|
||||
// 1.8 之后 当前正常数据
|
||||
} else if (this.getConfig() != null && this.getConfig().containsKey(getParentProjectId(samplerProxy))) {
|
||||
if (StringUtils.isBlank(samplerProxy.getProjectId())
|
||||
&& this.getConfig() != null
|
||||
&& this.getConfig().containsKey(getParentProjectId(samplerProxy))) {
|
||||
// 1.8 前后 混合数据
|
||||
samplerProxy.setProjectId(getParentProjectId(samplerProxy));
|
||||
} else {
|
||||
// 1.8 之前 数据
|
||||
if (this.getConfig() != null) {
|
||||
if (!this.getConfig().containsKey(RunModeConstants.HIS_PRO_ID.toString())) {
|
||||
// 测试计划执行
|
||||
Iterator<String> it = this.getConfig().keySet().iterator();
|
||||
if (it.hasNext()) {
|
||||
samplerProxy.setProjectId(it.next());
|
||||
}
|
||||
} else {
|
||||
samplerProxy.setProjectId(RunModeConstants.HIS_PRO_ID.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue