fix: 修复mock期望按钮提示错误、自定义脚本不支持更改环境变量的问题、性能测试找不到附件的问题
修复mock期望按钮提示错误、自定义脚本不支持更改环境变量的问题、性能测试找不到附件的问题
This commit is contained in:
parent
56cf866494
commit
31df6e4d23
|
@ -3,11 +3,14 @@ package io.metersphere.api.dto.automation;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiScenrioExportJmx {
|
||||
private String name;
|
||||
private String jmx;
|
||||
List<String> files;
|
||||
|
||||
public ApiScenrioExportJmx(String name, String jmx) {
|
||||
this.name = name;
|
||||
|
|
|
@ -3,8 +3,10 @@ package io.metersphere.api.dto.definition.request.processors;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.RunningParamKeys;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.commons.constants.DelimiterConstants;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -15,6 +17,7 @@ import org.apache.jmeter.save.SaveService;
|
|||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,6 +35,27 @@ public class MsJSR223Processor extends MsTestElement {
|
|||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
//替换Metersphere环境变量
|
||||
if(StringUtils.isEmpty(this.getUseEnviroment())){
|
||||
if(config.getConfig() != null){
|
||||
if(config.getProjectId() != null){
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid();
|
||||
this.setUseEnviroment(evnId);
|
||||
}else {
|
||||
Collection<EnvironmentConfig> evnConfigList = config.getConfig().values();
|
||||
if(evnConfigList!=null && !evnConfigList.isEmpty()){
|
||||
for (EnvironmentConfig configItem : evnConfigList) {
|
||||
String evnId = configItem.getApiEnvironmentid();
|
||||
this.setUseEnviroment(evnId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
script = StringUtils.replace(script, RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getUseEnviroment()+".\"");
|
||||
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
return;
|
||||
|
|
|
@ -47,6 +47,7 @@ import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
|||
import io.metersphere.track.request.testplan.FileOperationRequest;
|
||||
import io.metersphere.track.service.TestPlanScenarioCaseService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
|
@ -1657,6 +1658,19 @@ public class ApiAutomationService {
|
|||
String jmx = generateJmx(item);
|
||||
if (StringUtils.isNotEmpty(jmx)) {
|
||||
ApiScenrioExportJmx scenrioExportJmx = new ApiScenrioExportJmx(item.getName(), apiTestService.updateJmxString(jmx, null, true).getXml());
|
||||
//扫描需要哪些文件
|
||||
JmxInfoDTO dto = apiTestService.updateJmxString(jmx, item.getName(), true);
|
||||
if(MapUtils.isNotEmpty(dto.getAttachFiles())){
|
||||
List<String> fileList = new ArrayList<>();
|
||||
for (String fileName: dto.getAttachFiles().values()) {
|
||||
if(!fileList.contains(fileName)){
|
||||
fileList.add(fileName);
|
||||
}
|
||||
}
|
||||
if(!fileList.isEmpty()){
|
||||
scenrioExportJmx.setFiles(fileList);
|
||||
}
|
||||
}
|
||||
resList.add(scenrioExportJmx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<ms-table-operator-button :tip="$t('commons.copy')" icon="el-icon-copy-document"
|
||||
@exec="copyExpect(scope.row)"
|
||||
/>
|
||||
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-delete"
|
||||
<ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete"
|
||||
@exec="removeExpect(scope.row)"
|
||||
/>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue