Merge branch 'v1.6'
This commit is contained in:
commit
1f611e3f5c
|
@ -101,7 +101,6 @@ public abstract class MsTestElement {
|
|||
public String getJmx(HashTree hashTree) {
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
SaveService.saveTree(hashTree, baos);
|
||||
System.out.print(baos.toString());
|
||||
return baos.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -13,6 +13,7 @@ import io.metersphere.api.service.ApiTestEnvironmentService;
|
|||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.ScriptEngineUtils;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -158,12 +159,13 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
||||
sampler.setPort(urlObject.getPort());
|
||||
sampler.setProtocol(urlObject.getProtocol());
|
||||
|
||||
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
|
||||
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
||||
sampler.setPath(getRestParameters(URLDecoder.decode(urlObject.getPath(), "UTF-8")));
|
||||
envPath = getRestParameters(URLDecoder.decode(envPath, "UTF-8"));
|
||||
sampler.setPath(envPath);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getArguments())) {
|
||||
sampler.setPath(getPostQueryParameters(URLDecoder.decode(urlObject.getPath(), "UTF-8")));
|
||||
sampler.setPath(getPostQueryParameters(URLDecoder.decode(envPath, "UTF-8")));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -221,7 +223,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
stringBuffer.append("/");
|
||||
Map<String, String> keyValueMap = new HashMap<>();
|
||||
this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue ->
|
||||
keyValueMap.put(keyValue.getName(), keyValue.getValue())
|
||||
keyValueMap.put(keyValue.getName(), keyValue.getValue() != null && keyValue.getValue().startsWith("@") ?
|
||||
ScriptEngineUtils.calculate(keyValue.getValue()) : keyValue.getValue())
|
||||
);
|
||||
try {
|
||||
Pattern p = Pattern.compile("(\\{)([\\w]+)(\\})");
|
||||
|
@ -243,7 +246,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
stringBuffer.append(path);
|
||||
stringBuffer.append("?");
|
||||
this.getArguments().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue ->
|
||||
stringBuffer.append(keyValue.getName()).append("=").append(keyValue.getValue()).append("&")
|
||||
stringBuffer.append(keyValue.getName()).append("=").append(keyValue.getValue() != null && keyValue.getValue().startsWith("@") ?
|
||||
ScriptEngineUtils.calculate(keyValue.getValue()) : keyValue.getValue()).append("&")
|
||||
);
|
||||
return stringBuffer.substring(0, stringBuffer.length() - 1);
|
||||
}
|
||||
|
@ -251,7 +255,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
private Arguments httpArguments(List<KeyValue> list) {
|
||||
Arguments arguments = new Arguments();
|
||||
list.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), keyValue.getValue());
|
||||
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), keyValue.getValue() != null && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.calculate(keyValue.getValue()) : keyValue.getValue());
|
||||
httpArgument.setAlwaysEncoded(keyValue.isEncode());
|
||||
if (StringUtils.isNotBlank(keyValue.getContentType())) {
|
||||
httpArgument.setContentType(keyValue.getContentType());
|
||||
|
|
|
@ -66,7 +66,7 @@ public class JMeterService {
|
|||
}
|
||||
}
|
||||
|
||||
private HashTree getHashTree(Object scriptWrapper) throws Exception {
|
||||
public static HashTree getHashTree(Object scriptWrapper) throws Exception {
|
||||
Field field = scriptWrapper.getClass().getDeclaredField("testPlan");
|
||||
field.setAccessible(true);
|
||||
return (HashTree) field.get(scriptWrapper);
|
||||
|
|
|
@ -166,6 +166,16 @@ public class JmeterDocumentParser {
|
|||
u += k + "=" + v;
|
||||
return u;
|
||||
});
|
||||
//rest参数处理
|
||||
if (url.contains("@")) {
|
||||
String vars[] = url.split("@");
|
||||
for (String item : vars) {
|
||||
if (item.endsWith("/")) {
|
||||
item = item.substring(0, item.length() - 1);
|
||||
}
|
||||
url = url.replace("@" + item, ScriptEngineUtils.calculate("@" + item));
|
||||
}
|
||||
}
|
||||
ele.setTextContent(url + ((params != null && !params.equals("?")) ? params : ""));
|
||||
break;
|
||||
case "Argument.value":
|
||||
|
|
|
@ -349,8 +349,8 @@ public class ApiAutomationService {
|
|||
} catch (Exception ex) {
|
||||
LogUtil.error(ex.getMessage());
|
||||
}
|
||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
||||
|
||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
||||
String runMode = ApiRunMode.SCENARIO.name();
|
||||
if (StringUtils.isNotBlank(request.getRunMode()) && StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {
|
||||
runMode = ApiRunMode.SCENARIO_PLAN.name();
|
||||
|
@ -380,9 +380,10 @@ public class ApiAutomationService {
|
|||
config.setConfig(envConfig);
|
||||
HashTree hashTree = request.getTestElement().generateHashTree(config);
|
||||
// 调用执行方法
|
||||
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.SCENARIO.name());
|
||||
createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
||||
SessionUtils.getUserId());
|
||||
// 调用执行方法
|
||||
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.SCENARIO.name());
|
||||
return request.getId();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,6 @@ public class Translator {
|
|||
* 单Key翻译
|
||||
*/
|
||||
public static String get(String key) {
|
||||
return messageSource.getMessage(key, null, "Not Support Key", LocaleContextHolder.getLocale());
|
||||
return messageSource.getMessage(key, null, "Not Support Key: " + key, LocaleContextHolder.getLocale());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f27d1609d77f7d6c988d37d709466e844d350e17
|
||||
Subproject commit c10b11f224e4186306e6ae3a3976e29a42af96a5
|
|
@ -60,6 +60,7 @@ test_resource_pool_name_is_null=Test Resource Pool name cannot be null
|
|||
test_resource_pool_name_already_exists=The test resource pool name already exists
|
||||
load_test=Load Test
|
||||
test_resource_pool_is_use=This resource pool is in use and cannot be deleted
|
||||
only_one_k8s=Only one K8S can be added
|
||||
#project
|
||||
project_name_is_null=Project name cannot be null
|
||||
project_name_already_exists=The project name already exists
|
||||
|
|
|
@ -60,6 +60,7 @@ test_resource_pool_name_is_null=资源池名称不能为空
|
|||
test_resource_pool_name_already_exists=资源池名称已存在
|
||||
load_test=性能测试
|
||||
test_resource_pool_is_use=正在使用此资源池,无法删除
|
||||
only_one_k8s=只能添加一个 K8S
|
||||
#project
|
||||
project_name_is_null=项目名称不能为空
|
||||
project_name_already_exists=项目名称已存在
|
||||
|
|
|
@ -60,6 +60,7 @@ test_resource_pool_name_is_null=資源池名稱不能為空
|
|||
test_resource_pool_name_already_exists=資源池名稱已存在
|
||||
load_test=性能測試
|
||||
test_resource_pool_is_use=正在使用此資源池,無法刪除
|
||||
only_one_k8s=只能添加一個 K8S
|
||||
#project
|
||||
project_name_is_null=項目名稱不能為空
|
||||
project_name_already_exists=項目名稱已存在
|
||||
|
|
|
@ -0,0 +1,211 @@
|
|||
<template>
|
||||
<div v-loading="loading">
|
||||
<el-table
|
||||
:data="tableData"
|
||||
style="width: 100%;margin-bottom: 20px;"
|
||||
row-key="id"
|
||||
default-expand-all
|
||||
@cell-click="editor"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
||||
<el-table-column
|
||||
prop="name"
|
||||
label="名称">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-if="scope.row.id === tabClickIndex && tabClickProperty === 'name'" v-model="scope.row.name" size="mini" style="padding-left: 20px" @blur="inputBlur(scope.row)"></el-input>
|
||||
<span v-else>{{scope.row.name}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="required"
|
||||
label="必输项"
|
||||
align="center"
|
||||
width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.required"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="type"
|
||||
width="120px"
|
||||
label="类型">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.type" slot="prepend" size="small">
|
||||
<el-option v-for="item in typeData" :key="item.id" :label="item.label" :value="item.id"/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="value"
|
||||
label="内容">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-if="scope.row.id === tabClickIndex && tabClickProperty === 'value'" v-model="scope.row.value" size="mini"></el-input>
|
||||
<span v-else>{{scope.row.value}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="describe"
|
||||
label="描述">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-if="scope.row.id === tabClickIndex && tabClickProperty === 'describe'" v-model="scope.row.describe" size="mini"></el-input>
|
||||
<span v-else>{{scope.row.describe}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="opt"
|
||||
label="操作"
|
||||
width="100">
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<i class="el-icon-setting" style="margin-left: 5px;cursor: pointer" @click="setting(scope.row)"/>
|
||||
<i class="el-icon-plus" style="margin-left: 5px;cursor: pointer" @click="add(scope.row)"/>
|
||||
<i class="el-icon-close" style="margin-left: 5px;cursor: pointer" @click="deleteRow(scope.row)"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
</el-table>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsJsonTable",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
tableData: [{
|
||||
id: "root",
|
||||
parent: null,
|
||||
name: 'root',
|
||||
required: true,
|
||||
type: 'object',
|
||||
value: 'object',
|
||||
describe: 'describe',
|
||||
editor: false,
|
||||
children: [],
|
||||
}]
|
||||
,
|
||||
tabClickProperty: "",
|
||||
tabClickIndex: "",
|
||||
typeData: [
|
||||
{id: 'string', label: 'string'},
|
||||
{id: 'number', label: 'number'},
|
||||
{id: 'array', label: 'array'},
|
||||
{id: 'object', label: 'object'},
|
||||
{id: 'boolean', label: 'boolean'},
|
||||
{id: 'integer', label: 'integer'}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
editor(row, column) {
|
||||
switch (column.property) {
|
||||
case 'name':
|
||||
this.tabClickIndex = row.id
|
||||
this.tabClickProperty = column.property
|
||||
break
|
||||
case 'value':
|
||||
this.tabClickIndex = row.id
|
||||
this.tabClickProperty = column.property
|
||||
break;
|
||||
case 'describe':
|
||||
this.tabClickIndex = row.id
|
||||
this.tabClickProperty = column.property
|
||||
break;
|
||||
default:
|
||||
return
|
||||
}
|
||||
},
|
||||
inputBlur() {
|
||||
this.tabClickIndex = null;
|
||||
this.tabClickProperty = '';
|
||||
this.reload();
|
||||
},
|
||||
reload() {
|
||||
this.loading = true;
|
||||
this.$nextTick(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
setting() {
|
||||
|
||||
},
|
||||
add(row) {
|
||||
let obj = {
|
||||
id: getUUID(),
|
||||
name: 'field',
|
||||
required: true,
|
||||
type: 'string',
|
||||
value: 'test',
|
||||
parent: null,
|
||||
describe: 'describe',
|
||||
children: [],
|
||||
}
|
||||
console.log("all", this.tableData)
|
||||
console.log("row", row)
|
||||
|
||||
if (row.type === "object") {
|
||||
obj.parent = row.id;
|
||||
row.children.push(obj);
|
||||
return;
|
||||
}
|
||||
let parentRow = {};
|
||||
const index = this.tableData.findIndex(d => d.id != undefined && row.parent != undefined && d.id === row.parent);
|
||||
if (index != -1) {
|
||||
parentRow = this.tableData[index];
|
||||
} else {
|
||||
for (let i in this.tableData) {
|
||||
if (this.tableData[i].children) {
|
||||
parentRow = this.recursiveRemove(this.tableData[i].children, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(parentRow)
|
||||
if (parentRow) {
|
||||
obj.parent = parentRow.id;
|
||||
parentRow.children.push(obj);
|
||||
return;
|
||||
}
|
||||
this.tableData.push(obj);
|
||||
},
|
||||
recursiveRemove(arr, row) {
|
||||
for (let i in arr) {
|
||||
const index = arr.findIndex(d => d.id != undefined && row.id != undefined && d.id === row.id)
|
||||
if (index != -1) {
|
||||
arr.splice(index, 1);
|
||||
return arr[i];
|
||||
}
|
||||
if (arr[i].children != undefined && arr[i].children.length > 0) {
|
||||
this.recursiveRemove(arr[i].children, row);
|
||||
}
|
||||
}
|
||||
},
|
||||
deleteRow(row) {
|
||||
const index = this.tableData.findIndex(d => d.id != undefined && row.id != undefined && d.id === row.id)
|
||||
if (index == -1) {
|
||||
this.tableData.forEach(item => {
|
||||
if (item.children) {
|
||||
this.recursiveRemove(item.children, row);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.tableData.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.name-input >>> .el-input__inner {
|
||||
height: 25px;
|
||||
line-height: 25px;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue