fix(接口测试): 修复JDBC请求历史数据源未清理导致执行错误问题

--bug=1013120 --user=赵勇 【接口测试】-场景中复制sql协议-切换无数据源的环境执行后未提示数据源为空 https://www.tapd.cn/55049933/s/1157017
This commit is contained in:
fit2-zhao 2022-05-12 16:11:44 +08:00 committed by 刘瑞斌
parent fe0c10c5d1
commit fe04f54a19
3 changed files with 8 additions and 2 deletions

View File

@ -78,6 +78,8 @@ public class MsJDBCPostProcessor extends MsTestElement {
@Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
ParameterConfig config = (ParameterConfig) msParameter;
// 历史数据清理
this.dataSource = null;
// 非导出操作且不是启用状态则跳过执行
if (!config.isOperating() && !this.isEnable()) {
return;

View File

@ -78,6 +78,8 @@ public class MsJDBCPreProcessor extends MsTestElement {
@Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
ParameterConfig config = (ParameterConfig) msParameter;
// 历史数据清理
this.dataSource = null;
// 非导出操作且不是启用状态则跳过执行
if (!config.isOperating() && !this.isEnable()) {
return;
@ -117,7 +119,7 @@ public class MsJDBCPreProcessor extends MsTestElement {
if (config.isEffective(this.getProjectId()) && CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getDatabaseConfigs())
&& isDataSource(config.getConfig().get(this.getProjectId()).getDatabaseConfigs())) {
EnvironmentConfig environmentConfig = config.getConfig().get(this.getProjectId());
if(environmentConfig.getDatabaseConfigs() != null && StringUtils.isNotEmpty(environmentConfig.getApiEnvironmentid())){
if (environmentConfig.getDatabaseConfigs() != null && StringUtils.isNotEmpty(environmentConfig.getApiEnvironmentid())) {
this.environmentId = environmentConfig.getApiEnvironmentid();
}
this.initDataSource();
@ -247,7 +249,7 @@ public class MsJDBCPreProcessor extends MsTestElement {
private JDBCPreProcessor jdbcPreProcessor(ParameterConfig config) {
JDBCPreProcessor jdbcPreProcessor = new JDBCPreProcessor();
jdbcPreProcessor.setEnabled(this.isEnable());
jdbcPreProcessor.setName(this.getName() == null? "JDBCPreProcessor" : this.getName());
jdbcPreProcessor.setName(this.getName() == null ? "JDBCPreProcessor" : this.getName());
jdbcPreProcessor.setProperty(TestElement.TEST_CLASS, JDBCPreProcessor.class.getName());
jdbcPreProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));

View File

@ -84,6 +84,8 @@ public class MsJDBCSampler extends MsTestElement {
@Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
ParameterConfig config = (ParameterConfig) msParameter;
// 清理掉历史遗留数据
this.dataSource = null;
// 非导出操作且不是启用状态则跳过执行
if (config != null && !config.isOperating() && !this.isEnable()) {
return;