Merge remote-tracking branch 'origin/master'

This commit is contained in:
q4speed 2020-10-09 18:09:02 +08:00
commit af046d0f91
5 changed files with 71 additions and 49 deletions

View File

@ -1,10 +1,12 @@
package io.metersphere.api.jmeter;
import io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample;
import org.apache.jmeter.extractor.JSR223PostProcessor;
import org.apache.jmeter.extractor.RegexExtractor;
import org.apache.jmeter.extractor.XPath2Extractor;
import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
import org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler;
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jorphan.collections.HashTree;
import org.springframework.util.StringUtils;
@ -22,6 +24,7 @@ public class JMeterVars {
// 线程执行过程调用提取变量值
public static void addVars(Integer testId, JMeterVariables vars, String extract) {
JMeterVariables vs = new JMeterVariables();
if (!StringUtils.isEmpty(extract) && vars != null) {
List<String> extracts = Arrays.asList(extract.split(";"));
Optional.ofNullable(extracts).orElse(new ArrayList<>()).forEach(item -> {
@ -29,14 +32,15 @@ public class JMeterVars {
});
vs.remove("TESTSTART.MS"); // 标示变量移除
}
variables.put(testId, vs);
}
// 递归处理所有请求有提取变量的增加后置脚本
// 处理所有请求有提取变量的请求增加后置脚本提取变量值
public static void addJSR223PostProcessor(HashTree tree) {
for (Object key : tree.keySet()) {
HashTree node = tree.get(key);
if (key instanceof HTTPSamplerProxy) {
if (key instanceof HTTPSamplerProxy || key instanceof DubboSample || key instanceof JDBCSampler) {
StringJoiner extract = new StringJoiner(";");
for (Object child : node.keySet()) {
if (child instanceof RegexExtractor) {
@ -50,6 +54,7 @@ public class JMeterVars {
extract.add(regexExtractor.getRefNames());
}
}
if (Optional.ofNullable(extract).orElse(extract).length() > 0) {
JSR223PostProcessor shell = new JSR223PostProcessor();
shell.setEnabled(true);
@ -57,6 +62,7 @@ public class JMeterVars {
node.add(shell);
}
}
if (node != null) {
addJSR223PostProcessor(node);
}

View File

@ -4,7 +4,8 @@
<resultMap id="BaseResultMap" type="io.metersphere.track.dto.TestPlanDTO"
extends="io.metersphere.base.mapper.TestPlanMapper.BaseResultMap">
<result column="project_name" property="projectName"/>
<result column="project_name" property="projectName" jdbcType="VARCHAR"/>
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
</resultMap>
<sql id="condition">
<choose>
@ -97,7 +98,8 @@
<select id="list" resultMap="BaseResultMap"
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
select test_plan.* from test_plan
select test_plan.*, user.name as user_name from test_plan
JOIN user ON user.id = test_plan.principal
<where>
<if test="request.combine != null">
<include refid="combine">

View File

@ -10,5 +10,6 @@ import java.util.List;
@Setter
public class TestPlanDTO extends TestPlan {
private String projectName;
private String userName;
private List<String> projectIds;
}

View File

@ -1,60 +1,73 @@
<template>
<el-row type="flex" align="middle" class="current-user">
<el-avatar shape="square" size="small" :src="squareUrl"/>
<span class="username">{{currentUser.name}}</span>
<div class="icon-title">
{{ currentUser.name.substring(0, 1) }}
</div>
<span class="username">{{ currentUser.name }}</span>
</el-row>
</template>
<script>
import {getCurrentUser} from "../../../common/js/utils";
import {getCurrentUser} from "@/common/js/utils";
export default {
name: "MsCurrentUser",
export default {
name: "MsCurrentUser",
data() {
return {
editVisible: false,
id: "123456",
squareUrl: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png",
form: {}
}
data() {
return {
editVisible: false,
id: "123456",
form: {}
}
},
methods: {
edit() {
this.editVisible = true;
this.form = Object.assign({}, this.currentUser);
},
methods: {
edit() {
this.editVisible = true;
this.form = Object.assign({}, this.currentUser);
},
submit() {
this.editVisible = false;
}
},
computed: {
currentUser: () => {
return getCurrentUser();
}
submit() {
this.editVisible = false;
}
},
computed: {
currentUser: () => {
return getCurrentUser();
}
}
}
</script>
<style scoped>
.current-user .username {
display: inline-block;
font-size: 16px;
font-weight: 500;
margin: 0 5px;
overflow-x: hidden;
padding-bottom: 0;
text-overflow: ellipsis;
vertical-align: middle;
white-space: nowrap;
width: 180px;
}
.current-user .username {
display: inline-block;
font-size: 16px;
font-weight: 500;
margin: 0 5px;
overflow-x: hidden;
padding-bottom: 0;
text-overflow: ellipsis;
vertical-align: middle;
white-space: nowrap;
width: 180px;
}
.current-user .edit {
opacity: 0;
}
.current-user .edit {
opacity: 0;
}
.current-user:hover .edit {
opacity: 1;
}
.icon-title {
color: #fff;
width: 30px;
background-color: #72dc91;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 30px;
font-size: 14px;
}
.current-user:hover .edit {
opacity: 1;
}
</style>

View File

@ -20,7 +20,7 @@
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="principal"
prop="userName"
:label="$t('test_track.plan.plan_principal')"
show-overflow-tooltip>
</el-table-column>
@ -141,7 +141,7 @@ import MsTableOperatorButton from "../../../common/components/MsTableOperatorBut
import MsTableOperator from "../../../common/components/MsTableOperator";
import PlanStatusTableItem from "../../common/tableItems/plan/PlanStatusTableItem";
import PlanStageTableItem from "../../common/tableItems/plan/PlanStageTableItem";
import {_filter, _sort, checkoutTestManagerOrTestUser} from "../../../../../common/js/utils";
import {_filter, _sort, checkoutTestManagerOrTestUser} from "@/common/js/utils";
import TestReportTemplateList from "../view/comonents/TestReportTemplateList";
import TestCaseReportView from "../view/comonents/report/TestCaseReportView";
import MsDeleteConfirm from "../../../common/components/MsDeleteConfirm";