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

View File

@ -4,7 +4,8 @@
<resultMap id="BaseResultMap" type="io.metersphere.track.dto.TestPlanDTO" <resultMap id="BaseResultMap" type="io.metersphere.track.dto.TestPlanDTO"
extends="io.metersphere.base.mapper.TestPlanMapper.BaseResultMap"> 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> </resultMap>
<sql id="condition"> <sql id="condition">
<choose> <choose>
@ -97,7 +98,8 @@
<select id="list" resultMap="BaseResultMap" <select id="list" resultMap="BaseResultMap"
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest"> 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> <where>
<if test="request.combine != null"> <if test="request.combine != null">
<include refid="combine"> <include refid="combine">

View File

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

View File

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

View File

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