fix(场景自动化): 修复添加自定义请求问题,场景变量查看问题
This commit is contained in:
parent
02558f6d66
commit
2d8423556c
|
@ -32,6 +32,7 @@ import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
|||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.constants.LoopConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.FileUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
@ -48,6 +49,7 @@ import org.apache.jorphan.collections.HashTree;
|
|||
import org.apache.jorphan.collections.ListedHashTree;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -211,6 +213,9 @@ public abstract class MsTestElement {
|
|||
csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName());
|
||||
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding());
|
||||
if (CollectionUtils.isNotEmpty(item.getFiles())) {
|
||||
if (new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) {
|
||||
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ CSV文件不存在 ]");
|
||||
}
|
||||
csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
|
||||
}
|
||||
csvDataSet.setIgnoreFirstLine(false);
|
||||
|
|
|
@ -3,11 +3,14 @@ package io.metersphere.api.dto.definition.request.unknown;
|
|||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.FileUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.CSVDataSet;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jmeter.testelement.TestPlan;
|
||||
|
@ -15,6 +18,7 @@ import org.apache.jmeter.threads.ThreadGroup;
|
|||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -53,6 +57,13 @@ public class MsJmeterElement extends MsTestElement {
|
|||
if (!config.isOperating() && scriptWrapper instanceof ThreadGroup && !((ThreadGroup) scriptWrapper).isEnabled()) {
|
||||
LogUtil.info(((ThreadGroup) scriptWrapper).getName() + "是被禁用线程组不加入执行");
|
||||
} else {
|
||||
// CSV数据检查文件路径是否还存在
|
||||
if (scriptWrapper instanceof CSVDataSet) {
|
||||
String path = ((CSVDataSet) scriptWrapper).getPropertyAsString("filename");
|
||||
if (!new File(path).exists()) {
|
||||
MSException.throwException(StringUtils.isEmpty(((CSVDataSet) scriptWrapper).getName()) ? "CSVDataSet" : ((CSVDataSet) scriptWrapper).getName() + ":[ CSV文件不存在 ]");
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
for (MsTestElement el : hashTree) {
|
||||
el.toHashTree(elementTree, el.getHashTree(), config);
|
||||
|
@ -62,6 +73,7 @@ public class MsJmeterElement extends MsTestElement {
|
|||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
MSException.throwException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -535,8 +535,12 @@ public class ApiAutomationService {
|
|||
}
|
||||
|
||||
// 生成报告和HashTree
|
||||
HashTree hashTree = generateHashTree(item, reportId, planEnvMap);
|
||||
|
||||
HashTree hashTree = null;
|
||||
try {
|
||||
hashTree = generateHashTree(item, reportId, planEnvMap);
|
||||
} catch (Exception ex) {
|
||||
MSException.throwException(ex.getMessage());
|
||||
}
|
||||
//存储报告
|
||||
batchMapper.insert(report);
|
||||
|
||||
|
@ -602,7 +606,12 @@ public class ApiAutomationService {
|
|||
}
|
||||
ParameterConfig config = new ParameterConfig();
|
||||
config.setConfig(envConfig);
|
||||
HashTree hashTree = request.getTestElement().generateHashTree(config);
|
||||
HashTree hashTree = null;
|
||||
try {
|
||||
hashTree = request.getTestElement().generateHashTree(config);
|
||||
} catch (Exception e) {
|
||||
MSException.throwException(e.getMessage());
|
||||
}
|
||||
// 调用执行方法
|
||||
APIScenarioReportResult reportResult = createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
||||
SessionUtils.getUserId());
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<el-table-column v-if="item.id == 'tags'" prop="tags" min-width="120px"
|
||||
:label="$t('api_test.automation.tag')" :key="index">
|
||||
<template v-slot:default="scope">
|
||||
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 5px"/>
|
||||
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" :show-tooltip="true" tooltip style="margin-left: 5px"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="item.id == 'userId'" prop="userId" min-width="120px"
|
||||
|
@ -758,7 +758,6 @@
|
|||
z-index: auto !important;
|
||||
}
|
||||
|
||||
|
||||
/deep/ .el-table__fixed-right {
|
||||
height: 100% !important;
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
<div class="header-right" @click.stop>
|
||||
<slot name="message"></slot>
|
||||
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn">
|
||||
<el-switch v-model="data.enable" class="enable-switch" size="mini"/>
|
||||
<el-switch v-model="data.enable" class="enable-switch" size="mini" :disabled="data.disabled"/>
|
||||
</el-tooltip>
|
||||
<slot name="button"></slot>
|
||||
<step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn"/>
|
||||
<step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && !data.disabled"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -219,8 +219,12 @@
|
|||
return this.selection.includes(row.id)
|
||||
},
|
||||
open: function (variables, headers, disabled) {
|
||||
if(variables){
|
||||
this.variables = variables;
|
||||
}
|
||||
if(headers){
|
||||
this.headers = headers;
|
||||
}
|
||||
this.visible = true;
|
||||
this.editData = {type: "CONSTANT"};
|
||||
this.addParameters(this.editData);
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
min-width="120px"
|
||||
:key="index">
|
||||
<template v-slot:default="scope">
|
||||
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 5px"/>
|
||||
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :show-tooltip="true" :content="itemName" style="margin-left: 5px"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<template>
|
||||
<el-tooltip placement="top" v-if="showTooltip">
|
||||
<div slot="content">{{content}}</div>
|
||||
<el-tag :type="type" :effect="effect" :color="color" size="mini">{{content}}</el-tag>
|
||||
</el-tooltip>
|
||||
<el-tag :type="type" :effect="effect" :color="color" size="mini" v-else>{{content}}</el-tag>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -20,6 +24,10 @@
|
|||
effect: {
|
||||
type: String,
|
||||
default: 'dark',
|
||||
},
|
||||
showTooltip: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue