refactor: --story=1003996 --user=刘瑞斌 测试计划添加性能测试,支持重新配置高级配置 https://www.tapd.cn/55049933/s/1069343

This commit is contained in:
CaptainB 2021-11-17 17:46:32 +08:00 committed by 刘瑞斌
parent 9f361469f1
commit 362f31af83
17 changed files with 992 additions and 250 deletions

View File

@ -11,10 +11,10 @@ public class TestPlanLoadCase implements Serializable {
private String loadCaseId;
private String status;
private String loadReportId;
private String status;
private Long createTime;
private Long updateTime;
@ -25,7 +25,5 @@ public class TestPlanLoadCase implements Serializable {
private Long order;
private String loadConfiguration;
private static final long serialVersionUID = 1L;
}

View File

@ -314,76 +314,6 @@ public class TestPlanLoadCaseExample {
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andLoadReportIdIsNull() {
addCriterion("load_report_id is null");
return (Criteria) this;
@ -454,6 +384,76 @@ public class TestPlanLoadCaseExample {
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;

View File

@ -0,0 +1,17 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class TestPlanLoadCaseWithBLOBs extends TestPlanLoadCase implements Serializable {
private String loadConfiguration;
private String advancedConfiguration;
private static final long serialVersionUID = 1L;
}

View File

@ -2,6 +2,7 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.TestPlanLoadCase;
import io.metersphere.base.domain.TestPlanLoadCaseExample;
import io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs;
import java.util.List;
import org.apache.ibatis.annotations.Param;
@ -12,25 +13,25 @@ public interface TestPlanLoadCaseMapper {
int deleteByPrimaryKey(String id);
int insert(TestPlanLoadCase record);
int insert(TestPlanLoadCaseWithBLOBs record);
int insertSelective(TestPlanLoadCase record);
int insertSelective(TestPlanLoadCaseWithBLOBs record);
List<TestPlanLoadCase> selectByExampleWithBLOBs(TestPlanLoadCaseExample example);
List<TestPlanLoadCaseWithBLOBs> selectByExampleWithBLOBs(TestPlanLoadCaseExample example);
List<TestPlanLoadCase> selectByExample(TestPlanLoadCaseExample example);
TestPlanLoadCase selectByPrimaryKey(String id);
TestPlanLoadCaseWithBLOBs selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") TestPlanLoadCase record, @Param("example") TestPlanLoadCaseExample example);
int updateByExampleSelective(@Param("record") TestPlanLoadCaseWithBLOBs record, @Param("example") TestPlanLoadCaseExample example);
int updateByExampleWithBLOBs(@Param("record") TestPlanLoadCase record, @Param("example") TestPlanLoadCaseExample example);
int updateByExampleWithBLOBs(@Param("record") TestPlanLoadCaseWithBLOBs record, @Param("example") TestPlanLoadCaseExample example);
int updateByExample(@Param("record") TestPlanLoadCase record, @Param("example") TestPlanLoadCaseExample example);
int updateByPrimaryKeySelective(TestPlanLoadCase record);
int updateByPrimaryKeySelective(TestPlanLoadCaseWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(TestPlanLoadCase record);
int updateByPrimaryKeyWithBLOBs(TestPlanLoadCaseWithBLOBs record);
int updateByPrimaryKey(TestPlanLoadCase record);
}

View File

@ -5,16 +5,17 @@
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
<result column="load_case_id" jdbcType="VARCHAR" property="loadCaseId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="load_report_id" jdbcType="VARCHAR" property="loadReportId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="test_resource_pool_id" jdbcType="VARCHAR" property="testResourcePoolId" />
<result column="order" jdbcType="BIGINT" property="order" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlanLoadCase">
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs">
<result column="load_configuration" jdbcType="LONGVARCHAR" property="loadConfiguration" />
<result column="advanced_configuration" jdbcType="LONGVARCHAR" property="advancedConfiguration" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -75,11 +76,11 @@
</where>
</sql>
<sql id="Base_Column_List">
id, test_plan_id, load_case_id, `status`, load_report_id, create_time, update_time,
id, test_plan_id, load_case_id, load_report_id, `status`, create_time, update_time,
create_user, test_resource_pool_id, `order`
</sql>
<sql id="Blob_Column_List">
load_configuration
load_configuration, advanced_configuration
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanLoadCaseExample" resultMap="ResultMapWithBLOBs">
select
@ -129,17 +130,19 @@
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanLoadCase">
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs">
insert into test_plan_load_case (id, test_plan_id, load_case_id,
`status`, load_report_id, create_time,
load_report_id, `status`, create_time,
update_time, create_user, test_resource_pool_id,
`order`, load_configuration)
`order`, load_configuration, advanced_configuration
)
values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{loadCaseId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{loadReportId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{loadReportId,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{testResourcePoolId,jdbcType=VARCHAR},
#{order,jdbcType=BIGINT}, #{loadConfiguration,jdbcType=LONGVARCHAR})
#{order,jdbcType=BIGINT}, #{loadConfiguration,jdbcType=LONGVARCHAR}, #{advancedConfiguration,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanLoadCase">
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs">
insert into test_plan_load_case
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -151,12 +154,12 @@
<if test="loadCaseId != null">
load_case_id,
</if>
<if test="status != null">
`status`,
</if>
<if test="loadReportId != null">
load_report_id,
</if>
<if test="status != null">
`status`,
</if>
<if test="createTime != null">
create_time,
</if>
@ -175,6 +178,9 @@
<if test="loadConfiguration != null">
load_configuration,
</if>
<if test="advancedConfiguration != null">
advanced_configuration,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -186,12 +192,12 @@
<if test="loadCaseId != null">
#{loadCaseId,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="loadReportId != null">
#{loadReportId,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
@ -210,6 +216,9 @@
<if test="loadConfiguration != null">
#{loadConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="advancedConfiguration != null">
#{advancedConfiguration,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanLoadCaseExample" resultType="java.lang.Long">
@ -230,12 +239,12 @@
<if test="record.loadCaseId != null">
load_case_id = #{record.loadCaseId,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.loadReportId != null">
load_report_id = #{record.loadReportId,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
@ -254,6 +263,9 @@
<if test="record.loadConfiguration != null">
load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="record.advancedConfiguration != null">
advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -264,14 +276,15 @@
set id = #{record.id,jdbcType=VARCHAR},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
load_case_id = #{record.loadCaseId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
load_report_id = #{record.loadReportId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user = #{record.createUser,jdbcType=VARCHAR},
test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR},
`order` = #{record.order,jdbcType=BIGINT},
load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR}
load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR},
advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -281,8 +294,8 @@
set id = #{record.id,jdbcType=VARCHAR},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
load_case_id = #{record.loadCaseId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
load_report_id = #{record.loadReportId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user = #{record.createUser,jdbcType=VARCHAR},
@ -292,7 +305,7 @@
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestPlanLoadCase">
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs">
update test_plan_load_case
<set>
<if test="testPlanId != null">
@ -301,12 +314,12 @@
<if test="loadCaseId != null">
load_case_id = #{loadCaseId,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="loadReportId != null">
load_report_id = #{loadReportId,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
@ -325,29 +338,33 @@
<if test="loadConfiguration != null">
load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="advancedConfiguration != null">
advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanLoadCase">
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs">
update test_plan_load_case
set test_plan_id = #{testPlanId,jdbcType=VARCHAR},
load_case_id = #{loadCaseId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
load_report_id = #{loadReportId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user = #{createUser,jdbcType=VARCHAR},
test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR},
`order` = #{order,jdbcType=BIGINT},
load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR}
load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR},
advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanLoadCase">
update test_plan_load_case
set test_plan_id = #{testPlanId,jdbcType=VARCHAR},
load_case_id = #{loadCaseId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
load_report_id = #{loadReportId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user = #{createUser,jdbcType=VARCHAR},

View File

@ -402,10 +402,13 @@ public class PerformanceTestService {
String testPlanLoadId = request.getTestPlanLoadId();
if (StringUtils.isNotBlank(testPlanLoadId)) {
// 设置本次报告中的压力配置信息
TestPlanLoadCase testPlanLoadCase = testPlanLoadCaseMapper.selectByPrimaryKey(testPlanLoadId);
TestPlanLoadCaseWithBLOBs testPlanLoadCase = testPlanLoadCaseMapper.selectByPrimaryKey(testPlanLoadId);
if (testPlanLoadCase != null && StringUtils.isNotBlank(testPlanLoadCase.getLoadConfiguration())) {
testReport.setLoadConfiguration(testPlanLoadCase.getLoadConfiguration());
}
if (testPlanLoadCase != null && StringUtils.isNotBlank(testPlanLoadCase.getAdvancedConfiguration())) {
testReport.setAdvancedConfiguration(testPlanLoadCase.getAdvancedConfiguration());
}
if (testPlanLoadCase != null && StringUtils.isNotBlank(testPlanLoadCase.getTestResourcePoolId())) {
testReport.setTestResourcePoolId(testPlanLoadCase.getTestResourcePoolId());
}

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.base.domain.TestPlanLoadCase;
import io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.TriggerMode;
import io.metersphere.commons.utils.PageUtils;
@ -87,7 +88,7 @@ public class TestPlanLoadCaseController {
@PostMapping("/update")
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#testPlanLoadCase.id)", msClass = TestPlanLoadCaseService.class)
public void update(@RequestBody TestPlanLoadCase testPlanLoadCase) {
public void update(@RequestBody TestPlanLoadCaseWithBLOBs testPlanLoadCase) {
testPlanLoadCaseService.update(testPlanLoadCase);
}
@ -112,6 +113,11 @@ public class TestPlanLoadCaseController {
return testPlanLoadCaseService.getPlanLoadCaseConfig(loadCaseId);
}
@GetMapping("/get-advanced-config/{loadCaseId}")
public String getAdvancedConfiguration(@PathVariable String loadCaseId) {
return testPlanLoadCaseService.getAdvancedConfiguration(loadCaseId);
}
@GetMapping("/get/{loadCaseId}")
public TestPlanLoadCase getTestPlanLoadCase(@PathVariable String loadCaseId) {
return testPlanLoadCaseService.getTestPlanLoadCase(loadCaseId);

View File

@ -2,6 +2,7 @@ package io.metersphere.track.dto;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import io.metersphere.base.domain.TestPlanLoadCase;
import io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs;
import io.metersphere.dto.LogDetailDTO;
import io.metersphere.performance.base.*;
import io.metersphere.performance.dto.LoadTestExportJmx;
@ -15,7 +16,7 @@ import java.util.Map;
@Getter
@Setter
public class TestPlanLoadCaseDTO extends TestPlanLoadCase {
public class TestPlanLoadCaseDTO extends TestPlanLoadCaseWithBLOBs {
private String userName;
private String caseName;
private String projectName;

View File

@ -100,7 +100,7 @@ public class TestPlanLoadCaseService {
Collections.reverse(caseIds);
for (String id : caseIds) {
TestPlanLoadCase t = new TestPlanLoadCase();
TestPlanLoadCaseWithBLOBs t = new TestPlanLoadCaseWithBLOBs();
t.setId(UUID.randomUUID().toString());
t.setCreateUser(SessionUtils.getUserId());
t.setTestPlanId(planId);
@ -112,6 +112,7 @@ public class TestPlanLoadCaseService {
if (loadTest != null) {
t.setTestResourcePoolId(loadTest.getTestResourcePoolId());
t.setLoadConfiguration(loadTest.getLoadConfiguration());
t.setAdvancedConfiguration(loadTest.getAdvancedConfiguration());
}
nextOrder += 5000;
testPlanLoadCaseMapper.insert(t);
@ -142,7 +143,7 @@ public class TestPlanLoadCaseService {
public String run(RunTestPlanRequest request) {
String reportId = performanceTestService.run(request);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs();
testPlanLoadCase.setId(request.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase);
@ -192,7 +193,7 @@ public class TestPlanLoadCaseService {
example.createCriteria().andIdEqualTo(reportId);
List<LoadTestReport> loadTestReports = loadTestReportMapper.selectByExample(example);
if (CollectionUtils.isEmpty(loadTestReports)) {
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs();
testPlanLoadCase.setId(testPlanLoadCaseId);
testPlanLoadCase.setLoadReportId("");
testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase);
@ -240,7 +241,7 @@ public class TestPlanLoadCaseService {
testPlanLoadCaseMapper.deleteByExample(example);
}
public void update(TestPlanLoadCase testPlanLoadCase) {
public void update(TestPlanLoadCaseWithBLOBs testPlanLoadCase) {
if (!StringUtils.isEmpty(testPlanLoadCase.getId())) {
testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase);
}
@ -403,13 +404,25 @@ public class TestPlanLoadCaseService {
if (StringUtils.isBlank(loadCaseId)) {
return "";
}
TestPlanLoadCase testPlanLoadCase = testPlanLoadCaseMapper.selectByPrimaryKey(loadCaseId);
TestPlanLoadCaseWithBLOBs testPlanLoadCase = testPlanLoadCaseMapper.selectByPrimaryKey(loadCaseId);
if (testPlanLoadCase != null) {
return testPlanLoadCase.getLoadConfiguration();
}
return "";
}
public String getAdvancedConfiguration(String loadCaseId) {
if (StringUtils.isBlank(loadCaseId)) {
return "";
}
TestPlanLoadCaseWithBLOBs testPlanLoadCase = testPlanLoadCaseMapper.selectByPrimaryKey(loadCaseId);
if (testPlanLoadCase != null) {
return testPlanLoadCase.getAdvancedConfiguration();
}
return "";
}
public TestPlanLoadCase getTestPlanLoadCase(String loadCaseId) {
if (StringUtils.isBlank(loadCaseId)) {
return new TestPlanLoadCase();
@ -428,7 +441,7 @@ public class TestPlanLoadCaseService {
* @param request
*/
public void updateOrder(ResetOrderRequest request) {
ServiceUtils.updateOrderField(request, TestPlanLoadCase.class,
ServiceUtils.updateOrderField(request, TestPlanLoadCaseWithBLOBs.class,
testPlanLoadCaseMapper::selectByPrimaryKey,
extTestPlanLoadCaseMapper::getPreOrder,
extTestPlanLoadCaseMapper::getLastOrder,

View File

@ -580,7 +580,7 @@ public class TestPlanService {
for (TestCaseTest l : list) {
if (StringUtils.equals(l.getTestType(), TestCaseStatus.performance.name())) {
TestPlanLoadCase t = new TestPlanLoadCase();
TestPlanLoadCaseWithBLOBs t = new TestPlanLoadCaseWithBLOBs();
t.setId(UUID.randomUUID().toString());
t.setTestPlanId(request.getPlanId());
t.setLoadCaseId(l.getTestId());
@ -1138,13 +1138,13 @@ public class TestPlanService {
reportId = performanceTestService.run(performanceRequest);
if (reportId != null) {
performaneReportIDMap.put(reportId, caseID);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs();
testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCaseService.update(testPlanLoadCase);
//更新关联处的报告
TestPlanLoadCase loadCase = new TestPlanLoadCaseDTO();
TestPlanLoadCaseWithBLOBs loadCase = new TestPlanLoadCaseDTO();
loadCase.setId(id);
loadCase.setLoadReportId(reportId);
loadCase.setStatus("run");
@ -1398,7 +1398,7 @@ public class TestPlanService {
if (!CollectionUtils.isEmpty(loadCases)) {
Long nextLoadOrder = ServiceUtils.getNextOrder(targetPlanId, extTestPlanLoadCaseMapper::getLastOrder);
for (TestPlanLoadCase loadCase : loadCases) {
TestPlanLoadCase load = new TestPlanLoadCase();
TestPlanLoadCaseWithBLOBs load = new TestPlanLoadCaseWithBLOBs();
load.setId(UUID.randomUUID().toString());
load.setTestPlanId(targetPlanId);
load.setLoadCaseId(loadCase.getLoadCaseId());

View File

@ -3,7 +3,7 @@
*/
package io.metersphere.track.service.utils;
import io.metersphere.base.domain.TestPlanLoadCase;
import io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs;
import io.metersphere.base.mapper.TestPlanLoadCaseMapper;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
@ -27,7 +27,7 @@ public class ParallelExecTask<T> implements Callable<T> {
public T call() {
try {
String reportId = performanceTestService.run(request);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs();
testPlanLoadCase.setId(request.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCase.setStatus("run");

View File

@ -6,6 +6,7 @@ package io.metersphere.track.service.utils;
import io.metersphere.api.dto.automation.RunModeConfig;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import io.metersphere.base.domain.TestPlanLoadCase;
import io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs;
import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.TestPlanLoadCaseMapper;
import io.metersphere.commons.exception.MSException;
@ -35,7 +36,7 @@ public class SerialExecTask<T> implements Callable<T> {
try {
// 串行开启轮询等待
String reportId = performanceTestService.run(request);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs();
testPlanLoadCase.setId(request.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCase.setStatus("run");

View File

@ -20,4 +20,6 @@ VALUES (UUID(), 'project_group', 'PROJECT_GROUP:READ+DELETE', 'PROJECT_GROUP');
INSERT INTO user_group_permission (id, group_id, permission_id, module_id)
VALUES (UUID(), 'project_group', 'PROJECT_GROUP:READ+SETTING_PERMISSION', 'PROJECT_GROUP');
alter table test_plan_load_case
add advanced_configuration TEXT null;

View File

@ -9,8 +9,9 @@
</el-form-item>
<el-form-item>
<el-input-number
:disabled="readOnly" size="mini" v-model="timeout"
:min="0"/>
:disabled="readOnly" size="mini" v-model="timeout"
controls-position="right"
:min="0"/>
</el-form-item>
<el-form-item>
ms
@ -24,8 +25,9 @@
</el-form-item>
<el-form-item>
<el-input-number
:disabled="readOnly" size="mini" :min="0"
v-model="responseTimeout"/>
:disabled="readOnly" size="mini" :min="0"
controls-position="right"
v-model="responseTimeout"/>
</el-form-item>
<el-form-item>
ms
@ -38,9 +40,9 @@
<div>
{{ $t('load_test.granularity') }}
<el-popover
placement="left"
width="300"
trigger="hover">
placement="left"
width="300"
trigger="hover">
<el-table :data="granularityData">
<el-table-column property="start" :label="$t('load_test.duration')">
<template v-slot:default="scope">
@ -69,9 +71,9 @@
</el-form-item>
<el-form-item>
<el-input
:disabled="readOnly" size="mini" v-model="statusCodeStr"
:placeholder="$t('load_test.separated_by_commas')"
@input="checkStatusCode"></el-input>
:disabled="readOnly" size="mini" v-model="statusCodeStr"
:placeholder="$t('load_test.separated_by_commas')"
@input="checkStatusCode"></el-input>
</el-form-item>
</el-form>
</el-col>
@ -90,50 +92,50 @@
<el-col :span="24">
<el-table :data="domains" size="mini" class="tb-edit" align="center" border highlight-current-row>
<el-table-column
align="center"
:label="$t('load_test.domain')"
show-overflow-tooltip>
align="center"
:label="$t('load_test.domain')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.domain"
:placeholder="$t('load_test.domain')"
clearable>
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.domain"
:placeholder="$t('load_test.domain')"
clearable>
</el-input>
<span>{{ row.domain }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
:label="$t('load_test.ip')"
show-overflow-tooltip>
align="center"
:label="$t('load_test.ip')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.ip"
:placeholder="$t('load_test.ip')"
clearable></el-input>
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.ip"
:placeholder="$t('load_test.ip')"
clearable></el-input>
<span>{{ row.ip }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-switch
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6"
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6"
>
</el-switch>
</template>
@ -159,9 +161,9 @@
<el-col :span="24">
<el-table :data="csvFiles" size="mini" class="tb-edit" align="center" border highlight-current-row>
<el-table-column
align="center"
prop="name"
:label="$t('commons.name')">
align="center"
prop="name"
:label="$t('commons.name')">
</el-table-column>
<el-table-column align="center" prop="csvSplit" :label="$t('load_test.csv_split')">
<template v-slot:default="{row}">
@ -190,53 +192,53 @@
<el-col :span="24">
<el-table :data="params" size="mini" class="tb-edit" align="center" border highlight-current-row>
<el-table-column
align="center"
:label="$t('load_test.param_name')"
show-overflow-tooltip>
align="center"
:label="$t('load_test.param_name')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.name"
:placeholder="$t('load_test.param_name')"
clearable>
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.name"
:placeholder="$t('load_test.param_name')"
clearable>
</el-input>
<span>{{ row.name }}</span>
</template>
</el-table-column>
<el-table-column
:label="$t('load_test.param_value')"
show-overflow-tooltip align="center">
:label="$t('load_test.param_value')"
show-overflow-tooltip align="center">
<template v-slot:default="{row}">
<!-- <template v-if="row.edit">
<el-input v-model="row.value" class="edit-input" size="mini"/>
</template>
<span v-else>{{ row.value }}</span>-->
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.value"
:placeholder="$t('load_test.param_value')"
clearable></el-input>
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.value"
:placeholder="$t('load_test.param_value')"
clearable></el-input>
<span>{{ row.value }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-switch
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6">
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6">
</el-switch>
</template>
</el-table-column>
@ -264,53 +266,53 @@
<el-col :span="24">
<el-table :data="properties" size="mini" class="tb-edit" align="center" border highlight-current-row>
<el-table-column
align="center"
:label="$t('load_test.param_name')"
show-overflow-tooltip>
align="center"
:label="$t('load_test.param_name')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.name"
:placeholder="$t('load_test.param_name')"
clearable>
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.name"
:placeholder="$t('load_test.param_name')"
clearable>
</el-input>
<span>{{ row.name }}</span>
</template>
</el-table-column>
<el-table-column
:label="$t('load_test.param_value')"
show-overflow-tooltip align="center">
:label="$t('load_test.param_value')"
show-overflow-tooltip align="center">
<template v-slot:default="{row}">
<!-- <template v-if="row.edit">
<el-input v-model="row.value" class="edit-input" size="mini"/>
</template>
<span v-else>{{ row.value }}</span>-->
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.value"
:placeholder="$t('load_test.param_value')"
clearable></el-input>
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.value"
:placeholder="$t('load_test.param_value')"
clearable></el-input>
<span>{{ row.value }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-switch
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6">
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6">
</el-switch>
</template>
</el-table-column>
@ -342,9 +344,9 @@
<el-col :span="24">
<el-table :data="monitorParams" size="mini" class="tb-edit" border highlight-current-row>
<el-table-column
align="center"
prop="name"
:label="$t('commons.name')">
align="center"
prop="name"
:label="$t('commons.name')">
</el-table-column>
<!-- <el-table-column-->
<!-- align="center"-->
@ -361,19 +363,19 @@
<!-- prop="monitorStatus"-->
<!-- label="监控状态">-->
<el-table-column
align="center"
prop="ip"
label="IP">
align="center"
prop="ip"
label="IP">
</el-table-column>
<el-table-column
align="center"
prop="port"
label="Port">
align="center"
prop="port"
label="Port">
</el-table-column>
<el-table-column
align="center"
prop="description"
:label="$t('commons.description')">
align="center"
prop="description"
:label="$t('commons.description')">
</el-table-column>
<el-table-column align="center" :label="$t('load_test.operating')">
<template v-slot:default="{row, $index}">
@ -395,7 +397,7 @@
</template>
<script>
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton.vue";
import EditMonitor from "@/business/components/performance/test/components/EditMonitor";
import {hasPermission} from "@/common/js/utils";
import BatchAddMonitor from "@/business/components/performance/test/components/BatchAddMonitor";
@ -654,4 +656,12 @@ export default {
cursor: pointer;
}
.duration-input .el-input-number--mini {
width: 100px;
}
.el-select--mini {
width: 130px;
}
</style>

View File

@ -1,8 +1,15 @@
<template>
<el-dialog :close-on-click-modal="false" :visible.sync="visible" :title="$t('load_test.pressure_config')"
width="85%" top="8vh" @close="close" v-loading="result.loading" :destroy-on-close="true">
<performance-load-config :test-id="loadTestId" :load-case-id="loadCaseId" :resource-pool="poolId"
@fileChange="fileChange" ref="pressureConfig" style="height: 50vh; overflow-y: auto;"/>
<el-dialog :close-on-click-modal="false" :visible.sync="visible"
width="85%" top="8vh" @close="close" v-loading="result.loading">
<el-tabs v-model="active">
<el-tab-pane :label="$t('load_test.pressure_config')" class="advanced-config">
<performance-load-config :test-id="loadTestId" :load-case-id="loadCaseId" :resource-pool="poolId"
@fileChange="fileChange" ref="pressureConfig"/>
</el-tab-pane>
<el-tab-pane :label="$t('load_test.advanced_config')" class="advanced-config">
<performance-advanced-config :test-id="loadTestId" :load-case-id="loadCaseId" ref="advancedConfig"/>
</el-tab-pane>
</el-tabs>
<template v-slot:footer>
<el-button @click="close" size="medium">{{ $t('commons.cancel') }}</el-button>
<el-button type="primary" @click="onSubmit" size="medium" style="margin-left: 10px;">
@ -15,20 +22,23 @@
<script>
import PerformanceLoadConfig from "@/business/components/track/plan/view/comonents/load/PerformanceLoadConfig";
import PerformanceAdvancedConfig from "@/business/components/track/plan/view/comonents/load/PerformanceAdvancedConfig";
export default {
name: "LoadCaseConfig",
components: {
PerformanceAdvancedConfig,
PerformanceLoadConfig
},
data() {
return {
active: '0',
visible: false,
loadTestId: "",
result: {},
loadCaseId: "",
poolId: ""
}
};
},
methods: {
open(loadTestId, loadCaseId) {
@ -37,7 +47,7 @@ export default {
this.loadCaseId = loadCaseId;
this.result = this.$get("/test/plan/load/case/get/" + loadCaseId, res => {
this.poolId = res.data ? res.data.testResourcePoolId : "";
})
});
},
close() {
this.visible = false;
@ -73,23 +83,35 @@ export default {
if (!this.$refs.pressureConfig.validConfig()) {
return false;
}
if (!this.$refs.advancedConfig.validConfig()) {
return false;
}
//
let loadConfiguration = JSON.stringify(this.$refs.pressureConfig.convertProperty());
//
let advancedConfiguration = JSON.stringify(this.$refs.advancedConfig.configurations());
let testResourcePoolId = this.$refs.pressureConfig.resourcePool;
let params = {
id: this.loadCaseId,
loadConfiguration,
advancedConfiguration,
testResourcePoolId
}
};
this.result = this.$post("/test/plan/load/case/update", params, () => {
this.visible = false;
this.$success(this.$t("commons.modify_success"));
})
});
},
}
}
};
</script>
<style scoped>
.advanced-config {
height: calc(100vh - 380px);
overflow: auto;
}
</style>

View File

@ -0,0 +1,651 @@
<template>
<div>
<!-- 基本配置 -->
<el-row>
<el-col :span="6">
<el-form :inline="true">
<el-form-item>
<div>{{ $t('load_test.connect_timeout') }}</div>
</el-form-item>
<el-form-item>
<el-input-number
:disabled="readOnly" size="mini" v-model="timeout"
controls-position="right"
:min="0"/>
</el-form-item>
<el-form-item>
ms
</el-form-item>
</el-form>
</el-col>
<el-col :span="6">
<el-form :inline="true">
<el-form-item>
<div>{{ $t('load_test.response_timeout') }}</div>
</el-form-item>
<el-form-item>
<el-input-number
:disabled="readOnly" size="mini" :min="0"
controls-position="right"
v-model="responseTimeout"/>
</el-form-item>
<el-form-item>
ms
</el-form-item>
</el-form>
</el-col>
<el-col :span="6">
<el-form :inline="true">
<el-form-item>
<div>
{{ $t('load_test.granularity') }}
<el-popover
placement="left"
width="300"
trigger="hover">
<el-table :data="granularityData">
<el-table-column property="start" :label="$t('load_test.duration')">
<template v-slot:default="scope">
<span>{{ scope.row.start }}S - {{ scope.row.end }}S</span>
</template>
</el-table-column>
<el-table-column property="granularity" :label="$t('load_test.granularity')"/>
</el-table>
<i slot="reference" class="el-icon-info pointer"/>
</el-popover>
</div>
</el-form-item>
<el-form-item>
<el-select v-model="granularity" :placeholder="$t('commons.please_select')" size="mini"
clearable>
<el-option v-for="op in granularityData" :key="op.granularity" :label="op.granularity"
:value="op.granularity"></el-option>
</el-select>
</el-form-item>
</el-form>
</el-col>
<el-col :span="6">
<el-form :inline="true">
<el-form-item>
<div>{{ $t('load_test.custom_http_code') }}</div>
</el-form-item>
<el-form-item>
<el-input
:disabled="readOnly" size="mini" v-model="statusCodeStr"
:placeholder="$t('load_test.separated_by_commas')"
@input="checkStatusCode"></el-input>
</el-form-item>
</el-form>
</el-col>
</el-row>
<!-- DNS -->
<el-row type="flex" justify="start">
<el-col :span="8">
<h3>{{ $t('load_test.domain_bind') }}</h3>
<el-button :disabled="readOnly" icon="el-icon-circle-plus-outline" plain size="mini" @click="add('domains')">
{{ $t('commons.add') }}
</el-button>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-table :data="domains" size="mini" class="tb-edit" align="center" border highlight-current-row>
<el-table-column
align="center"
:label="$t('load_test.domain')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.domain"
:placeholder="$t('load_test.domain')"
clearable>
</el-input>
<span>{{ row.domain }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
:label="$t('load_test.ip')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.ip"
:placeholder="$t('load_test.ip')"
clearable></el-input>
<span>{{ row.ip }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-switch
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6"
>
</el-switch>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('load_test.operating')">
<template v-slot:default="{row, $index}">
<ms-table-operator-button :disabled="readOnly" :tip="$t('commons.delete')" icon="el-icon-delete"
type="danger"
@exec="del(row, 'domains', $index)"/>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<!-- csv 配置 -->
<el-row>
<el-col :span="8">
<h3>CSVDataSet</h3>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-table :data="csvFiles" size="mini" class="tb-edit" align="center" border highlight-current-row>
<el-table-column
align="center"
prop="name"
:label="$t('commons.name')">
</el-table-column>
<el-table-column align="center" prop="csvSplit" :label="$t('load_test.csv_split')">
<template v-slot:default="{row}">
<el-switch :disabled="readOnly" v-model="row.csvSplit"/>
</template>
</el-table-column>
<el-table-column align="center" prop="csvHasHeader" :label="$t('load_test.csv_has_header')">
<template v-slot:default="{row}">
<el-switch :disabled="readOnly || !row.csvSplit" v-model="row.csvHasHeader"/>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<!-- 参数列表 -->
<el-row>
<el-col :span="8">
<h3>{{ $t('load_test.params') }}</h3>
<el-button :disabled="readOnly" icon="el-icon-circle-plus-outline" plain size="mini" @click="add('params')">
{{ $t('commons.add') }}
</el-button>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-table :data="params" size="mini" class="tb-edit" align="center" border highlight-current-row>
<el-table-column
align="center"
:label="$t('load_test.param_name')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.name"
:placeholder="$t('load_test.param_name')"
clearable>
</el-input>
<span>{{ row.name }}</span>
</template>
</el-table-column>
<el-table-column
:label="$t('load_test.param_value')"
show-overflow-tooltip align="center">
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.value"
:placeholder="$t('load_test.param_value')"
clearable></el-input>
<span>{{ row.value }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-switch
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6">
</el-switch>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('load_test.operating')">
<template v-slot:default="{row, $index}">
<ms-table-operator-button :disabled="readOnly" :tip="$t('commons.delete')" icon="el-icon-delete"
type="danger"
@exec="del(row, 'params', $index)"/>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<!-- JMeter Properties -->
<el-row>
<el-col :span="8">
<h3>JMeter Properties</h3>
<el-button :disabled="readOnly" icon="el-icon-circle-plus-outline" plain size="mini" @click="add('properties')">
{{ $t('commons.add') }}
</el-button>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-table :data="properties" size="mini" class="tb-edit" align="center" border highlight-current-row>
<el-table-column
align="center"
:label="$t('load_test.param_name')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
:rows="1"
class="edit-input"
v-model="row.name"
:placeholder="$t('load_test.param_name')"
clearable>
</el-input>
<span>{{ row.name }}</span>
</template>
</el-table-column>
<el-table-column
:label="$t('load_test.param_value')"
show-overflow-tooltip align="center">
<template v-slot:default="{row}">
<!-- <template v-if="row.edit">
<el-input v-model="row.value" class="edit-input" size="mini"/>
</template>
<span v-else>{{ row.value }}</span>-->
<el-input
size="mini"
v-if="!readOnly"
type="textarea"
class="edit-input"
:rows="1"
v-model="row.value"
:placeholder="$t('load_test.param_value')"
clearable></el-input>
<span>{{ row.value }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
:label="$t('load_test.enable')"
show-overflow-tooltip>
<template v-slot:default="{row}">
<el-switch
:disabled="readOnly"
size="mini"
v-model="row.enable"
inactive-color="#DCDFE6">
</el-switch>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('load_test.operating')">
<template v-slot:default="{row, $index}">
<ms-table-operator-button :disabled="readOnly" :tip="$t('commons.delete')" icon="el-icon-delete"
type="danger"
@exec="del(row, 'properties', $index)"/>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<!-- 监控配置 -->
<el-row>
<el-col :span="8">
<h3>{{ $t('commons.monitor') }}</h3>
<el-button :disabled="readOnly" icon="el-icon-circle-plus-outline" plain size="mini" @click="addMonitor">
{{ $t('commons.add') }}
</el-button>
<el-button :disabled="readOnly" icon="el-icon-circle-plus-outline" plain size="mini"
@click="batchAddMonitor">
{{ $t('commons.batch_add') }}
</el-button>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-table :data="monitorParams" size="mini" class="tb-edit" border highlight-current-row>
<el-table-column
align="center"
prop="name"
:label="$t('commons.name')">
</el-table-column>
<el-table-column
align="center"
prop="ip"
label="IP">
</el-table-column>
<el-table-column
align="center"
prop="port"
label="Port">
</el-table-column>
<el-table-column
align="center"
prop="description"
:label="$t('commons.description')">
</el-table-column>
<el-table-column align="center" :label="$t('load_test.operating')">
<template v-slot:default="{row, $index}">
<ms-table-operator-button :disabled="readOnly" tip="编辑" icon="el-icon-edit"
type="primary"
@exec="modifyMonitor(row, $index)"/>
<ms-table-operator-button :disabled="readOnly" :tip="$t('commons.delete')" icon="el-icon-delete"
type="danger"
@exec="delMonitor(row, $index)"/>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<edit-monitor ref="monitorDialog" :testId="testId" :list.sync="monitorParams"/>
<batch-add-monitor ref="batchMonitorDialog" @batchSave="batchSave"/>
</div>
</template>
<script>
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton.vue";
import EditMonitor from "@/business/components/performance/test/components/EditMonitor";
import {hasPermission} from "@/common/js/utils";
import BatchAddMonitor from "@/business/components/performance/test/components/BatchAddMonitor";
export default {
name: "PerformanceAdvancedConfig",
components: {BatchAddMonitor, EditMonitor, MsTableOperatorButton},
data() {
return {
timeout: undefined,
responseTimeout: undefined,
statusCode: [],
domains: [],
params: [],
properties: [],
monitorParams: [],
csvFiles: [],
csvConfig: [],
statusCodeStr: '',
granularity: undefined,
granularityData: [
{start: 0, end: 100, granularity: 1},
{start: 101, end: 500, granularity: 5},
{start: 501, end: 1000, granularity: 10},
{start: 1001, end: 3000, granularity: 30},
{start: 3001, end: 6000, granularity: 60},
{start: 6001, end: 30000, granularity: 300},
{start: 30001, end: 60000, granularity: 600},
{start: 60001, end: 180000, granularity: 1800},
{start: 180001, end: 360000, granularity: 3600},
],
readOnly: false,
};
},
props: {
testId: String,
loadCaseId: {
type: String
},
},
mounted() {
if (this.testId) {
this.getAdvancedConfig();
}
this.readOnly = !hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT');
},
watch: {
testId() {
if (this.testId) {
this.getAdvancedConfig();
}
},
csvFiles() {
if (this.csvConfig && this.csvFiles) {
this.csvFiles.forEach(f => {
f.csvSplit = this.csvConfig[f.name]?.csvSplit;
f.csvHasHeader = this.csvConfig[f.name]?.csvHasHeader;
});
}
}
},
methods: {
getAdvancedConfig() {
this.$get('/test/plan/load/case/get-advanced-config/' + this.loadCaseId, (response) => {
if (response.data) {
let data = JSON.parse(response.data);
this.timeout = data.timeout;
this.responseTimeout = data.responseTimeout;
this.statusCode = data.statusCode || [];
this.statusCodeStr = this.statusCode.join(',');
this.domains = data.domains || [];
this.params = data.params || [];
this.granularity = data.granularity;
this.monitorParams = data.monitorParams || [];
this.properties = data.properties || [];
this.csvConfig = data.csvConfig;
}
});
},
add(dataName) {
if (dataName === 'domains') {
this[dataName].push({
domain: 'fit2cloud.com',
enable: true,
ip: '127.0.0.1',
edit: true,
});
}
if (dataName === 'params') {
this[dataName].push({
name: 'param1',
enable: true,
value: '0',
edit: true,
});
}
if (dataName === 'properties') {
this[dataName].push({
name: 'prop1',
enable: true,
value: '0',
edit: true,
});
}
},
edit(row) {
row.edit = !row.edit;
},
del(row, dataName, index) {
this[dataName].splice(index, 1);
},
confirmEdit(row) {
row.edit = false;
row.enable = true;
},
groupBy(data, key) {
return data.reduce((p, c) => {
let name = c[key];
if (!p.hasOwnProperty(name)) {
p[name] = 0;
}
p[name]++;
return p;
}, {});
},
validConfig() {
let counts = this.groupBy(this.domains, 'domain');
for (let c in counts) {
if (counts[c] > 1) {
this.$error(this.$t('load_test.domain_is_duplicate'));
return false;
}
}
counts = this.groupBy(this.params, 'name');
for (let c in counts) {
if (counts[c] > 1) {
this.$error(this.$t('load_test.param_is_duplicate'));
return false;
}
}
counts = this.groupBy(this.properties, 'name');
for (let c in counts) {
if (counts[c] > 1) {
this.$error(this.$t('load_test.param_is_duplicate'));
return false;
}
}
if (this.domains.filter(d => !d.domain || !d.ip).length > 0) {
this.$error(this.$t('load_test.domain_ip_is_empty'));
return false;
}
if (this.params.filter(d => !d.name || !d.value).length > 0) {
this.$error(this.$t('load_test.param_name_value_is_empty'));
return false;
}
return true;
},
checkStatusCode() {
let license_num = this.statusCodeStr;
license_num = license_num.replace(/[^\d,]/g, ''); // .
this.statusCodeStr = license_num;
},
cancelAllEdit() {
this.domains.forEach(d => d.edit = false);
this.params.forEach(d => d.edit = false);
},
configurations() {
let statusCode = [];
if (this.statusCodeStr) {
statusCode = this.statusCodeStr.split(',');
}
return {
timeout: this.timeout,
responseTimeout: this.responseTimeout,
statusCode: statusCode,
params: this.params,
properties: this.properties,
csvConfig: this.csvFiles.reduce((result, curr) => {
result[curr.name] = {csvHasHeader: curr.csvHasHeader, csvSplit: curr.csvSplit};
return result;
}, {}),
domains: this.domains,
granularity: this.granularity,
monitorParams: this.monitorParams
};
},
addMonitor() {
this.$refs.monitorDialog.open();
},
batchAddMonitor() {
this.$refs.batchMonitorDialog.open();
},
batchSave(params) {
let targets = this._handleBatchVars(params);
targets.forEach(row => {
this.monitorParams.push(row);
});
},
_handleBatchVars(data) {
let params = data.split("\n");
let keyValues = [];
params.forEach(item => {
let line = item.split(/|,/);
if (line.length < 3) {
return;
}
keyValues.push({
name: line[0],
ip: line[1],
port: line[2],
description: line[3] || '',
});
});
return keyValues;
},
modifyMonitor(row, index) {
this.$refs.monitorDialog.open(row, index);
},
delMonitor(row, index) {
this.monitorParams.splice(index, 1);
},
refreshStatus() {
},
}
};
</script>
<style scoped>
.el-row {
margin-bottom: 10px;
}
.edit-input {
padding-right: 0px;
}
.tb-edit .el-textarea {
display: none;
}
.tb-edit .current-row .el-textarea {
display: block;
}
.tb-edit .current-row .el-textarea + span {
display: none;
}
.el-col {
text-align: left;
}
.el-col .el-table {
align: center;
}
.pointer {
cursor: pointer;
}
.duration-input .el-input-number--mini {
width: 100px;
}
.el-select--mini {
width: 130px;
}
</style>

View File

@ -179,7 +179,7 @@ export default {
permissions: ['PROJECT_TRACK_PLAN:READ+RUN']
},
{
tip: '修改压力配置',
tip: '修改配置',
icon: "el-icon-setting",
exec: this.changeLoadConfig,
type: 'success',