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.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||||
import io.metersphere.commons.constants.LoopConstants;
|
import io.metersphere.commons.constants.LoopConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
import io.metersphere.commons.utils.FileUtils;
|
import io.metersphere.commons.utils.FileUtils;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
|
@ -48,6 +49,7 @@ import org.apache.jorphan.collections.HashTree;
|
||||||
import org.apache.jorphan.collections.ListedHashTree;
|
import org.apache.jorphan.collections.ListedHashTree;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -211,6 +213,9 @@ public abstract class MsTestElement {
|
||||||
csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName());
|
csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName());
|
||||||
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding());
|
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding());
|
||||||
if (CollectionUtils.isNotEmpty(item.getFiles())) {
|
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.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
|
||||||
}
|
}
|
||||||
csvDataSet.setIgnoreFirstLine(false);
|
csvDataSet.setIgnoreFirstLine(false);
|
||||||
|
|
|
@ -3,11 +3,14 @@ package io.metersphere.api.dto.definition.request.unknown;
|
||||||
import com.alibaba.fastjson.annotation.JSONType;
|
import com.alibaba.fastjson.annotation.JSONType;
|
||||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
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 io.metersphere.commons.utils.LogUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.jmeter.config.CSVDataSet;
|
||||||
import org.apache.jmeter.save.SaveService;
|
import org.apache.jmeter.save.SaveService;
|
||||||
import org.apache.jmeter.testelement.TestElement;
|
import org.apache.jmeter.testelement.TestElement;
|
||||||
import org.apache.jmeter.testelement.TestPlan;
|
import org.apache.jmeter.testelement.TestPlan;
|
||||||
|
@ -15,6 +18,7 @@ import org.apache.jmeter.threads.ThreadGroup;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -53,6 +57,13 @@ public class MsJmeterElement extends MsTestElement {
|
||||||
if (!config.isOperating() && scriptWrapper instanceof ThreadGroup && !((ThreadGroup) scriptWrapper).isEnabled()) {
|
if (!config.isOperating() && scriptWrapper instanceof ThreadGroup && !((ThreadGroup) scriptWrapper).isEnabled()) {
|
||||||
LogUtil.info(((ThreadGroup) scriptWrapper).getName() + "是被禁用线程组不加入执行");
|
LogUtil.info(((ThreadGroup) scriptWrapper).getName() + "是被禁用线程组不加入执行");
|
||||||
} else {
|
} 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)) {
|
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||||
for (MsTestElement el : hashTree) {
|
for (MsTestElement el : hashTree) {
|
||||||
el.toHashTree(elementTree, el.getHashTree(), config);
|
el.toHashTree(elementTree, el.getHashTree(), config);
|
||||||
|
@ -62,6 +73,7 @@ public class MsJmeterElement extends MsTestElement {
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
MSException.throwException(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -535,8 +535,12 @@ public class ApiAutomationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成报告和HashTree
|
// 生成报告和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);
|
batchMapper.insert(report);
|
||||||
|
|
||||||
|
@ -602,7 +606,12 @@ public class ApiAutomationService {
|
||||||
}
|
}
|
||||||
ParameterConfig config = new ParameterConfig();
|
ParameterConfig config = new ParameterConfig();
|
||||||
config.setConfig(envConfig);
|
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(),
|
APIScenarioReportResult reportResult = createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
||||||
SessionUtils.getUserId());
|
SessionUtils.getUserId());
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
<el-table-column v-if="item.id == 'tags'" prop="tags" min-width="120px"
|
<el-table-column v-if="item.id == 'tags'" prop="tags" min-width="120px"
|
||||||
:label="$t('api_test.automation.tag')" :key="index">
|
:label="$t('api_test.automation.tag')" :key="index">
|
||||||
<template v-slot:default="scope">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column v-if="item.id == 'userId'" prop="userId" min-width="120px"
|
<el-table-column v-if="item.id == 'userId'" prop="userId" min-width="120px"
|
||||||
|
@ -758,7 +758,6 @@
|
||||||
z-index: auto !important;
|
z-index: auto !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/deep/ .el-table__fixed-right {
|
/deep/ .el-table__fixed-right {
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
<div class="header-right" @click.stop>
|
<div class="header-right" @click.stop>
|
||||||
<slot name="message"></slot>
|
<slot name="message"></slot>
|
||||||
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn">
|
<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>
|
</el-tooltip>
|
||||||
<slot name="button"></slot>
|
<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>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -219,8 +219,12 @@
|
||||||
return this.selection.includes(row.id)
|
return this.selection.includes(row.id)
|
||||||
},
|
},
|
||||||
open: function (variables, headers, disabled) {
|
open: function (variables, headers, disabled) {
|
||||||
this.variables = variables;
|
if(variables){
|
||||||
this.headers = headers;
|
this.variables = variables;
|
||||||
|
}
|
||||||
|
if(headers){
|
||||||
|
this.headers = headers;
|
||||||
|
}
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.editData = {type: "CONSTANT"};
|
this.editData = {type: "CONSTANT"};
|
||||||
this.addParameters(this.editData);
|
this.addParameters(this.editData);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,28 +1,36 @@
|
||||||
<template>
|
<template>
|
||||||
<el-tag :type="type" :effect="effect" :color="color" size="mini">{{content}}</el-tag>
|
<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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "MsTag",
|
name: "MsTag",
|
||||||
props: {
|
props: {
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'primary',
|
default: 'primary',
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
effect: {
|
effect: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'dark',
|
default: 'dark',
|
||||||
}
|
},
|
||||||
|
showTooltip: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
Loading…
Reference in New Issue