This commit is contained in:
chenjianxing 2020-05-26 14:58:05 +08:00
commit da32ae5a84
29 changed files with 930 additions and 253 deletions

View File

@ -61,7 +61,7 @@ public class APITestController {
@PostMapping("/delete")
public void delete(@RequestBody DeleteAPITestRequest request) {
apiTestService.delete(request);
apiTestService.delete(request.getId());
}
@PostMapping(value = "/run")

View File

@ -13,4 +13,6 @@ public class APIReportResult extends ApiTestReport {
private String projectName;
private String userName;
private String content;
}

View File

@ -12,6 +12,7 @@ import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
import org.apache.jmeter.visualizers.backend.BackendListenerContext;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.*;
/**
@ -120,9 +121,12 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
requestResult.setTotalAssertions(result.getAssertionResults().length);
requestResult.setSuccess(result.isSuccessful());
requestResult.setError(result.getErrorCount());
for (SampleResult subResult : result.getSubResults()) {
requestResult.getSubRequestResults().add(getRequestResult(subResult));
}
ResponseResult responseResult = requestResult.getResponseResult();
responseResult.setBody(result.getResponseDataAsString());
responseResult.setBody(new String(result.getResponseData(), StandardCharsets.UTF_8));
responseResult.setHeaders(result.getResponseHeaders());
responseResult.setLatency(result.getLatency());
responseResult.setResponseCode(result.getResponseCode());

View File

@ -2,6 +2,9 @@ package io.metersphere.api.jmeter;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class RequestResult {
@ -27,6 +30,8 @@ public class RequestResult {
private int passAssertions = 0;
private final List<RequestResult> subRequestResults = new ArrayList<>();
private final ResponseResult responseResult = new ResponseResult();
public void addPassAssertions() {

View File

@ -5,9 +5,8 @@ import io.metersphere.api.dto.APIReportResult;
import io.metersphere.api.dto.DeleteAPIReportRequest;
import io.metersphere.api.dto.QueryAPIReportRequest;
import io.metersphere.api.jmeter.TestResult;
import io.metersphere.base.domain.ApiTest;
import io.metersphere.base.domain.ApiTestReport;
import io.metersphere.base.domain.ApiTestReportExample;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiTestReportDetailMapper;
import io.metersphere.base.mapper.ApiTestReportMapper;
import io.metersphere.base.mapper.ext.ExtApiTestReportMapper;
import io.metersphere.commons.constants.APITestStatus;
@ -18,6 +17,7 @@ import io.metersphere.i18n.Translator;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;
@ -33,6 +33,8 @@ public class APIReportService {
@Resource
private ApiTestReportMapper apiTestReportMapper;
@Resource
private ApiTestReportDetailMapper apiTestReportDetailMapper;
@Resource
private ExtApiTestReportMapper extApiTestReportMapper;
public List<APIReportResult> list(QueryAPIReportRequest request) {
@ -44,7 +46,12 @@ public class APIReportService {
}
public APIReportResult get(String reportId) {
return extApiTestReportMapper.get(reportId);
APIReportResult result = extApiTestReportMapper.get(reportId);
ApiTestReportDetail detail = apiTestReportDetailMapper.selectByPrimaryKey(reportId);
if (detail != null) {
result.setContent(new String(detail.getContent(), StandardCharsets.UTF_8));
}
return result;
}
public List<APIReportResult> listByTestId(String testId) {
@ -52,6 +59,7 @@ public class APIReportService {
}
public void delete(DeleteAPIReportRequest request) {
apiTestReportDetailMapper.deleteByPrimaryKey(request.getId());
apiTestReportMapper.deleteByPrimaryKey(request.getId());
}
@ -59,6 +67,10 @@ public class APIReportService {
ApiTestReportExample example = new ApiTestReportExample();
example.createCriteria().andTestIdEqualTo(testId);
apiTestReportMapper.deleteByExample(example);
ApiTestReportDetailExample detailExample = new ApiTestReportDetailExample();
detailExample.createCriteria().andTestIdEqualTo(testId);
apiTestReportDetailMapper.deleteByExample(detailExample);
}
public void complete(TestResult result) {
@ -66,7 +78,14 @@ public class APIReportService {
if (report == null) {
MSException.throwException(Translator.get("api_report_is_null"));
}
report.setContent(JSONObject.toJSONString(result));
// report detail
ApiTestReportDetail detail = new ApiTestReportDetail();
detail.setReportId(report.getId());
detail.setTestId(report.getTestId());
detail.setContent(JSONObject.toJSONString(result).getBytes(StandardCharsets.UTF_8));
apiTestReportDetailMapper.insert(detail);
// report
report.setUpdateTime(System.currentTimeMillis());
report.setStatus(APITestStatus.Completed.name());
apiTestReportMapper.updateByPrimaryKeySelective(report);

View File

@ -73,10 +73,10 @@ public class APITestService {
return apiTestMapper.selectByPrimaryKey(id);
}
public void delete(DeleteAPITestRequest request) {
deleteFileByTestId(request.getId());
apiReportService.deleteByTestId(request.getId());
apiTestMapper.deleteByPrimaryKey(request.getId());
public void delete(String testId) {
deleteFileByTestId(testId);
apiReportService.deleteByTestId(testId);
apiTestMapper.deleteByPrimaryKey(testId);
}
public String run(SaveAPITestRequest request) {

View File

@ -21,7 +21,5 @@ public class ApiTestReport implements Serializable {
private String userId;
private String content;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,15 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class ApiTestReportDetail implements Serializable {
private String reportId;
private String testId;
private byte[] content;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,340 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class ApiTestReportDetailExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public ApiTestReportDetailExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andReportIdIsNull() {
addCriterion("report_id is null");
return (Criteria) this;
}
public Criteria andReportIdIsNotNull() {
addCriterion("report_id is not null");
return (Criteria) this;
}
public Criteria andReportIdEqualTo(String value) {
addCriterion("report_id =", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotEqualTo(String value) {
addCriterion("report_id <>", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThan(String value) {
addCriterion("report_id >", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThanOrEqualTo(String value) {
addCriterion("report_id >=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThan(String value) {
addCriterion("report_id <", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThanOrEqualTo(String value) {
addCriterion("report_id <=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLike(String value) {
addCriterion("report_id like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotLike(String value) {
addCriterion("report_id not like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdIn(List<String> values) {
addCriterion("report_id in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotIn(List<String> values) {
addCriterion("report_id not in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdBetween(String value1, String value2) {
addCriterion("report_id between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotBetween(String value1, String value2) {
addCriterion("report_id not between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andTestIdIsNull() {
addCriterion("test_id is null");
return (Criteria) this;
}
public Criteria andTestIdIsNotNull() {
addCriterion("test_id is not null");
return (Criteria) this;
}
public Criteria andTestIdEqualTo(String value) {
addCriterion("test_id =", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotEqualTo(String value) {
addCriterion("test_id <>", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdGreaterThan(String value) {
addCriterion("test_id >", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdGreaterThanOrEqualTo(String value) {
addCriterion("test_id >=", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLessThan(String value) {
addCriterion("test_id <", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLessThanOrEqualTo(String value) {
addCriterion("test_id <=", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLike(String value) {
addCriterion("test_id like", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotLike(String value) {
addCriterion("test_id not like", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdIn(List<String> values) {
addCriterion("test_id in", values, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotIn(List<String> values) {
addCriterion("test_id not in", values, "testId");
return (Criteria) this;
}
public Criteria andTestIdBetween(String value1, String value2) {
addCriterion("test_id between", value1, value2, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotBetween(String value1, String value2) {
addCriterion("test_id not between", value1, value2, "testId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,36 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.ApiTestReportDetail;
import io.metersphere.base.domain.ApiTestReportDetailExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ApiTestReportDetailMapper {
long countByExample(ApiTestReportDetailExample example);
int deleteByExample(ApiTestReportDetailExample example);
int deleteByPrimaryKey(String reportId);
int insert(ApiTestReportDetail record);
int insertSelective(ApiTestReportDetail record);
List<ApiTestReportDetail> selectByExampleWithBLOBs(ApiTestReportDetailExample example);
List<ApiTestReportDetail> selectByExample(ApiTestReportDetailExample example);
ApiTestReportDetail selectByPrimaryKey(String reportId);
int updateByExampleSelective(@Param("record") ApiTestReportDetail record, @Param("example") ApiTestReportDetailExample example);
int updateByExampleWithBLOBs(@Param("record") ApiTestReportDetail record, @Param("example") ApiTestReportDetailExample example);
int updateByExample(@Param("record") ApiTestReportDetail record, @Param("example") ApiTestReportDetailExample example);
int updateByPrimaryKeySelective(ApiTestReportDetail record);
int updateByPrimaryKeyWithBLOBs(ApiTestReportDetail record);
int updateByPrimaryKey(ApiTestReportDetail record);
}

View File

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.ApiTestReportDetailMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.ApiTestReportDetail">
<id column="report_id" jdbcType="VARCHAR" property="reportId" />
<result column="test_id" jdbcType="VARCHAR" property="testId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestReportDetail">
<result column="content" jdbcType="LONGVARBINARY" property="content" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
report_id, test_id
</sql>
<sql id="Blob_Column_List">
content
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestReportDetailExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from api_test_report_detail
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiTestReportDetailExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from api_test_report_detail
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from api_test_report_detail
where report_id = #{reportId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from api_test_report_detail
where report_id = #{reportId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.ApiTestReportDetailExample">
delete from api_test_report_detail
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.ApiTestReportDetail">
insert into api_test_report_detail (report_id, test_id, content
)
values (#{reportId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARBINARY}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestReportDetail">
insert into api_test_report_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="reportId != null">
report_id,
</if>
<if test="testId != null">
test_id,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
<if test="testId != null">
#{testId,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARBINARY},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiTestReportDetailExample" resultType="java.lang.Long">
select count(*) from api_test_report_detail
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update api_test_report_detail
<set>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
<if test="record.testId != null">
test_id = #{record.testId,jdbcType=VARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARBINARY},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update api_test_report_detail
set report_id = #{record.reportId,jdbcType=VARCHAR},
test_id = #{record.testId,jdbcType=VARCHAR},
content = #{record.content,jdbcType=LONGVARBINARY}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update api_test_report_detail
set report_id = #{record.reportId,jdbcType=VARCHAR},
test_id = #{record.testId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiTestReportDetail">
update api_test_report_detail
<set>
<if test="testId != null">
test_id = #{testId,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARBINARY},
</if>
</set>
where report_id = #{reportId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestReportDetail">
update api_test_report_detail
set test_id = #{testId,jdbcType=VARCHAR},
content = #{content,jdbcType=LONGVARBINARY}
where report_id = #{reportId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiTestReportDetail">
update api_test_report_detail
set test_id = #{testId,jdbcType=VARCHAR}
where report_id = #{reportId,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -16,21 +16,15 @@ public interface ApiTestReportMapper {
int insertSelective(ApiTestReport record);
List<ApiTestReport> selectByExampleWithBLOBs(ApiTestReportExample example);
List<ApiTestReport> selectByExample(ApiTestReportExample example);
ApiTestReport selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") ApiTestReport record, @Param("example") ApiTestReportExample example);
int updateByExampleWithBLOBs(@Param("record") ApiTestReport record, @Param("example") ApiTestReportExample example);
int updateByExample(@Param("record") ApiTestReport record, @Param("example") ApiTestReportExample example);
int updateByPrimaryKeySelective(ApiTestReport record);
int updateByPrimaryKeyWithBLOBs(ApiTestReport record);
int updateByPrimaryKey(ApiTestReport record);
}

View File

@ -11,9 +11,6 @@
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestReport">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
@ -75,25 +72,6 @@
<sql id="Base_Column_List">
id, test_id, name, description, create_time, update_time, status, user_id
</sql>
<sql id="Blob_Column_List">
content
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestReportExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from api_test_report
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiTestReportExample" resultMap="BaseResultMap">
select
<if test="distinct">
@ -108,11 +86,9 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from api_test_report
where id = #{id,jdbcType=VARCHAR}
</select>
@ -129,12 +105,10 @@
<insert id="insert" parameterType="io.metersphere.base.domain.ApiTestReport">
insert into api_test_report (id, test_id, name,
description, create_time, update_time,
status, user_id, content
)
status, user_id)
values (#{id,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR}
)
#{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestReport">
insert into api_test_report
@ -163,9 +137,6 @@
<if test="userId != null">
user_id,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -192,9 +163,6 @@
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiTestReportExample" resultType="java.lang.Long">
@ -230,29 +198,11 @@
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update api_test_report
set id = #{record.id,jdbcType=VARCHAR},
test_id = #{record.testId,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
status = #{record.status,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update api_test_report
set id = #{record.id,jdbcType=VARCHAR},
@ -291,24 +241,9 @@
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestReport">
update api_test_report
set test_id = #{testId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
status = #{status,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiTestReport">
update api_test_report
set test_id = #{testId,jdbcType=VARCHAR},

View File

@ -46,7 +46,7 @@
<select id="get" resultMap="BaseResultMap">
SELECT r.*, t.name AS test_name, project.name AS project_name, user.name AS user_name
FROM api_test_report r JOIN api_test t ON r.test_id = t.id
JOIN project ON project.id = t.project_id
LEFT JOIN project ON project.id = t.project_id
LEFT JOIN user ON user.id = r.user_id
<where>
r.id = #{id}

View File

@ -2,17 +2,15 @@ package io.metersphere.commons.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import java.util.zip.*;
public class CompressUtils {
/***
* 压缩Zip
* Zip压缩
*
* @param data
* @return
* @param data 待压缩数据
* @return 压缩后数据
*/
public static Object zip(Object data) {
if (!(data instanceof byte[])) {
@ -40,10 +38,10 @@ public class CompressUtils {
}
/***
* 解压Zip
* Zip解压
*
* @param data
* @return
* @param data 待解压数据
* @return 解压后数据
*/
public static Object unzip(Object data) {
if (!(data instanceof byte[])) {
@ -72,4 +70,54 @@ public class CompressUtils {
}
return b;
}
/**
* GZip压缩
*
* @param data 待压缩数据
* @return 压缩后数
*/
public static Object compress(Object data) {
if (!(data instanceof byte[])) {
return data;
}
byte[] bytes = (byte[]) data;
try (ByteArrayOutputStream obj = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(obj)) {
gzip.write(bytes);
gzip.flush();
gzip.finish();
return obj.toByteArray();
} catch (Exception e) {
LogUtil.error(e);
return data;
}
}
/**
* GZip解压
*
* @param data 待解压数据
* @return 解压后数据
*/
public static Object decompress(Object data) {
if (!(data instanceof byte[])) {
return data;
}
byte[] bytes = (byte[]) data;
if (bytes.length == 0) {
return bytes;
}
try (GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes)); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
byte[] buffer = new byte[8192];
int len;
while ((len = gis.read(buffer)) > 0) {
baos.write(buffer, 0, len);
}
baos.flush();
return baos.toByteArray();
} catch (Exception e) {
LogUtil.error(e);
return data;
}
}
}

View File

@ -1,6 +1,7 @@
package io.metersphere.config;
import com.github.pagehelper.PageInterceptor;
import io.metersphere.base.domain.ApiTestReportDetail;
import io.metersphere.base.domain.FileContent;
import io.metersphere.base.domain.TestResource;
import io.metersphere.commons.utils.CompressUtils;
@ -41,6 +42,7 @@ public class MybatisConfig {
MybatisInterceptor interceptor = new MybatisInterceptor();
List<MybatisInterceptorConfig> configList = new ArrayList<>();
configList.add(new MybatisInterceptorConfig(FileContent.class, "file", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(ApiTestReportDetail.class, "content", CompressUtils.class, "compress", "decompress"));
configList.add(new MybatisInterceptorConfig(TestResource.class, "configuration"));
interceptor.setInterceptorConfigList(configList);
return interceptor;

View File

@ -1,5 +1,7 @@
package io.metersphere.service;
import io.metersphere.api.dto.QueryAPITestRequest;
import io.metersphere.api.service.APITestService;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.base.domain.LoadTestExample;
import io.metersphere.base.domain.Project;
@ -14,8 +16,6 @@ import io.metersphere.dto.ProjectDTO;
import io.metersphere.dto.ProjectRelatedResourceDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.performance.service.PerformanceTestService;
import io.metersphere.track.dto.TestPlanDTO;
import io.metersphere.track.request.testcase.QueryTestCaseRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.DeleteTestPlanRequest;
import io.metersphere.track.service.TestCaseService;
@ -24,12 +24,12 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.annotation.Resource;
@Service
@Transactional(rollbackFor = Exception.class)
public class ProjectService {
@ -53,6 +53,8 @@ public class ProjectService {
private TestPlanService testPlanService;
@Resource
private TestCaseService testCaseService;
@Resource
private APITestService apiTestService;
public Project addProject(Project project) {
if (StringUtils.isBlank(project.getName())) {
@ -98,7 +100,7 @@ public class ProjectService {
deleteTrackResourceByProjectId(projectId);
// TODO 删除项目下 接口测试 相关
deleteAPIResourceByProjectId(projectId);
// delete project
projectMapper.deleteByPrimaryKey(projectId);
}
@ -112,6 +114,14 @@ public class ProjectService {
testCaseService.deleteTestCaseByProjectId(projectId);
}
private void deleteAPIResourceByProjectId(String projectId) {
QueryAPITestRequest request = new QueryAPITestRequest();
request.setProjectId(projectId);
apiTestService.list(request).forEach(test -> {
apiTestService.delete(test.getId());
});
}
public void updateProject(Project project) {
project.setCreateTime(null);
project.setUpdateTime(System.currentTimeMillis());

View File

@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `file_content` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `file_metadata` (
`id` varchar(64) NOT NULL COMMENT 'File ID',
@ -15,10 +15,7 @@ CREATE TABLE IF NOT EXISTS `file_metadata` (
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin;
CREATE TABLE `load_test` (
`id` varchar(50) NOT NULL COMMENT 'Test ID',
@ -34,15 +31,13 @@ CREATE TABLE `load_test` (
`test_resource_pool_id` varchar(50) DEFAULT NULL,
`user_id` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `load_test_file` (
`test_id` varchar(64) DEFAULT NULL,
`file_id` varchar(64) DEFAULT NULL,
UNIQUE KEY `load_test_file_unique_key` (`test_id`, `file_id`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='测试和文件的关联表';
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT ='测试和文件的关联表';
CREATE TABLE `load_test_report` (
`id` varchar(50) NOT NULL COMMENT 'Test report ID',
@ -54,14 +49,14 @@ CREATE TABLE `load_test_report` (
`status` varchar(64) NOT NULL COMMENT 'Status of this test run',
`user_id` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `load_test_report_detail` (
`report_id` varchar(50) NOT NULL,
`content` longtext,
`part` bigint(11) NOT NULL,
PRIMARY KEY (`report_id`,`part`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `load_test_report_log` (
`id` varchar(50) NOT NULL,
@ -71,7 +66,7 @@ CREATE TABLE IF NOT EXISTS `load_test_report_log` (
`part` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `load_test_report_log_report_id_resource_name_index` (`report_id`,`resource_id`,`part`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `load_test_report_result` (
`id` varchar(50) NOT NULL,
@ -80,7 +75,7 @@ CREATE TABLE IF NOT EXISTS `load_test_report_result` (
`report_value` text ,
PRIMARY KEY (`id`),
KEY `load_test_report_result_report_id_report_key_index` (`report_id`,`report_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `organization` (
@ -93,7 +88,7 @@ CREATE TABLE IF NOT EXISTS `organization` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `project` (
`id` varchar(50) NOT NULL COMMENT 'Project ID',
@ -106,7 +101,7 @@ CREATE TABLE IF NOT EXISTS `project` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `role` (
`id` varchar(50) NOT NULL COMMENT 'Role ID',
@ -119,7 +114,7 @@ CREATE TABLE IF NOT EXISTS `role` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `system_parameter` (
`param_key` varchar(64) CHARACTER SET utf8mb4 NOT NULL COMMENT 'Parameter name',
@ -130,7 +125,7 @@ CREATE TABLE IF NOT EXISTS `system_parameter` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `test_resource` (
`id` varchar(50) NOT NULL COMMENT 'Test resource ID',
@ -143,7 +138,7 @@ CREATE TABLE IF NOT EXISTS `test_resource` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `test_resource_pool` (
`id` varchar(50) NOT NULL COMMENT 'Test resource pool ID',
@ -157,7 +152,7 @@ CREATE TABLE IF NOT EXISTS `test_resource_pool` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `user` (
`id` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT 'User ID',
@ -175,7 +170,7 @@ CREATE TABLE IF NOT EXISTS `user` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `user_role` (
`id` varchar(50) NOT NULL COMMENT 'ID of user''s role info',
@ -188,7 +183,7 @@ CREATE TABLE IF NOT EXISTS `user_role` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `workspace` (
`id` varchar(50) NOT NULL COMMENT 'Workspace ID ',
@ -201,7 +196,7 @@ CREATE TABLE IF NOT EXISTS `workspace` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
-- api start
@ -217,22 +212,19 @@ CREATE TABLE IF NOT EXISTS `api_test` (
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `api_test_file` (
`test_id` varchar(64) DEFAULT NULL,
`file_id` varchar(64) DEFAULT NULL,
UNIQUE KEY `api_test_file_unique_key` (`test_id`, `file_id`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='Api test test file relevance table';
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT ='Api test test file relevance table';
CREATE TABLE IF NOT EXISTS `api_test_report` (
`id` varchar(50) NOT NULL COMMENT 'Test report ID',
`test_id` varchar(50) NOT NULL COMMENT 'Test ID this test report belongs to',
`name` varchar(64) NOT NULL COMMENT 'Test report name',
`description` varchar(255) DEFAULT NULL COMMENT 'Test report name',
`content` longtext,
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
`status` varchar(64) NOT NULL COMMENT 'Status of this test run',
@ -241,7 +233,14 @@ CREATE TABLE IF NOT EXISTS `api_test_report` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `api_test_report_detail` (
`report_id` varchar(64) NOT NULL COMMENT 'API Test Report ID',
`test_id` varchar(64) NOT NULL COMMENT 'Test ID',
`content` longblob COMMENT 'Report content',
PRIMARY KEY (`report_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin;
-- api end
@ -266,7 +265,7 @@ CREATE TABLE IF NOT EXISTS `test_plan` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `test_case_node` (
@ -281,7 +280,7 @@ CREATE TABLE IF NOT EXISTS `test_case_node` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `test_case` (
@ -303,7 +302,7 @@ CREATE TABLE IF NOT EXISTS `test_case` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `test_plan_test_case` (
@ -321,7 +320,7 @@ CREATE TABLE IF NOT EXISTS `test_plan_test_case` (
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci;
COLLATE = utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `test_case_report_template` (
`id` varchar(50) NOT NULL,
@ -332,7 +331,7 @@ CREATE TABLE IF NOT EXISTS `test_case_report_template` (
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci;
COLLATE=utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `test_case_report` (
`id` varchar(50) NOT NULL,
@ -344,7 +343,7 @@ CREATE TABLE IF NOT EXISTS `test_case_report` (
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci;
COLLATE=utf8mb4_bin;
-- track end

View File

@ -9,7 +9,9 @@
</el-col>
<el-col :span="12">
<div class="name">{{request.name}}</div>
<div class="url">{{request.url}}</div>
<el-tooltip effect="dark" :content="request.url" placement="bottom" :open-delay="800">
<div class="url">{{request.url}}</div>
</el-tooltip>
</el-col>
<el-col :span="2">
<div class="time">
@ -34,10 +36,24 @@
</div>
<el-collapse-transition>
<div v-show="isActive">
<ms-request-metric :request="request"/>
<ms-request-text :request="request"/>
<br>
<ms-response-text :response="request.responseResult"/>
<el-tabs v-model="activeName" v-show="isActive" v-if="hasSub">
<el-tab-pane :label="$t('api_report.sub_result')" name="sub">
<ms-request-result class="sub-result" v-for="(sub, index) in request.subRequestResults"
:key="index" :request="sub"/>
</el-tab-pane>
<el-tab-pane :label="$t('api_report.request_result')" name="result">
<ms-request-metric :request="request"/>
<ms-request-text :request="request"/>
<br>
<ms-response-text :response="request.responseResult"/>
</el-tab-pane>
</el-tabs>
<div v-else>
<ms-request-metric :request="request"/>
<ms-request-text :request="request"/>
<br>
<ms-response-text :response="request.responseResult"/>
</div>
</div>
</el-collapse-transition>
</div>
@ -59,9 +75,7 @@
data() {
return {
isActive: false,
activeName: "request",
activeName2: "body",
activeName3: "body",
activeName: "sub",
}
},
@ -75,6 +89,9 @@
assertion() {
return this.request.passAssertions + " / " + this.request.totalAssertions;
},
hasSub() {
return this.request.subRequestResults.length > 0;
}
}
}
</script>
@ -93,7 +110,6 @@
}
.request-result .method {
/*border-left: 5px solid #1E90FF;*/
color: #1E90FF;
font-size: 14px;
font-weight: 500;
@ -106,9 +122,10 @@
font-size: 12px;
font-weight: 400;
margin-top: 4px;
overflow: auto;
white-space: normal;
word-wrap: break-word;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
}
.request-result .tab .el-tabs__header {
@ -119,4 +136,18 @@
height: 300px;
overflow-y: auto;
}
.sub-result .info {
background-color: #FFF;
}
.sub-result .method {
border-left: 5px solid #1E90FF;
padding-left: 20px;
}
.sub-result:last-child {
border-bottom: 1px solid #EBEEF5;
}
</style>

View File

@ -28,24 +28,29 @@ export class Element {
}
}
commonValue(tag, name, value) {
return this.add(new Element(tag, {name: name}, value));
getDefault(value, defaultValue) {
return value === undefined ? defaultValue : value;
}
boolProp(name, value) {
return this.commonValue('boolProp', name, value);
commonValue(tag, name, value, defaultValue) {
let v = this.getDefault(value, defaultValue)
return this.add(new Element(tag, {name: name}, v));
}
intProp(name, value) {
return this.commonValue('intProp', name, value);
boolProp(name, value, defaultValue) {
return this.commonValue('boolProp', name, value, defaultValue);
}
longProp(name, value) {
return this.commonValue('longProp', name, value);
intProp(name, value, defaultValue) {
return this.commonValue('intProp', name, value, defaultValue);
}
stringProp(name, value) {
return this.commonValue('stringProp', name, value);
longProp(name, value, defaultValue) {
return this.commonValue('longProp', name, value, defaultValue);
}
stringProp(name, value, defaultValue) {
return this.commonValue('stringProp', name, value, defaultValue);
}
collectionProp(name) {
@ -174,9 +179,9 @@ export class TestPlan extends DefaultTestElement {
super('TestPlan', 'TestPlanGui', 'TestPlan', testName);
props = props || {};
this.boolProp("TestPlan.functional_mode", props.mode || false);
this.boolProp("TestPlan.serialize_threadgroups", props.stg || false);
this.boolProp("TestPlan.tearDown_on_shutdown", props.tos || true);
this.boolProp("TestPlan.functional_mode", props.mode, false);
this.boolProp("TestPlan.serialize_threadgroups", props.stg, false);
this.boolProp("TestPlan.tearDown_on_shutdown", props.tos, true);
this.stringProp("TestPlan.comments", props.comments);
this.stringProp("TestPlan.user_define_classpath", props.classpath);
this.add(new ElementArguments(props.args, "TestPlan.user_defined_variables", "User Defined Variables"));
@ -188,12 +193,12 @@ export class ThreadGroup extends DefaultTestElement {
super('ThreadGroup', 'ThreadGroupGui', 'ThreadGroup', testName);
props = props || {};
this.intProp("ThreadGroup.num_threads", props.threads || 1);
this.intProp("ThreadGroup.ramp_time", props.ramp || 1);
this.longProp("ThreadGroup.delay", props.delay || 0);
this.longProp("ThreadGroup.duration", props.delay || 0);
this.stringProp("ThreadGroup.on_sample_error", props.error || "continue");
this.boolProp("ThreadGroup.scheduler", props.scheduler || false);
this.intProp("ThreadGroup.num_threads", props.threads, 1);
this.intProp("ThreadGroup.ramp_time", props.ramp, 1);
this.longProp("ThreadGroup.delay", props.delay, 0);
this.longProp("ThreadGroup.duration", props.delay, 0);
this.stringProp("ThreadGroup.on_sample_error", props.error, "continue");
this.boolProp("ThreadGroup.scheduler", props.scheduler, false);
let loopAttrs = {
name: "ThreadGroup.main_controller",
@ -205,44 +210,8 @@ export class ThreadGroup extends DefaultTestElement {
};
let loopProps = props.loopProps || {};
let loopController = this.add(new Element('elementProp', loopAttrs));
loopController.boolProp('LoopController.continue_forever', loopProps.continue || false);
loopController.stringProp('LoopController.loops', loopProps.loops || 1);
}
}
export class PostThreadGroup extends DefaultTestElement {
constructor(testName, props) {
super('PostThreadGroup', 'PostThreadGroupGui', 'PostThreadGroup', testName);
props = props || {};
this.intProp("ThreadGroup.num_threads", props.threads || 1);
this.intProp("ThreadGroup.ramp_time", props.ramp || 1);
this.boolProp("ThreadGroup.scheduler", props.scheduler || false);
this.stringProp("ThreadGroup.on_sample_error", props.error || "continue");
let loopAttrs = {
name: "ThreadGroup.main_controller",
elementType: "LoopController",
guiclass: "LoopControlPanel",
testclass: "LoopController",
testname: "Loop Controller",
enabled: "true"
};
let loopProps = props.loopProps || {};
let loopController = this.add(new Element('elementProp', loopAttrs));
loopController.boolProp('LoopController.continue_forever', loopProps.continue || false);
loopController.stringProp('LoopController.loops', loopProps.loops || 1);
}
}
export class DebugSampler extends DefaultTestElement {
constructor(testName) {
super('DebugSampler', 'TestBeanGUI', 'DebugSampler', testName);
this.boolProp("displayJMeterProperties", false);
this.boolProp("displayJMeterVariables", true);
this.boolProp("displaySystemProperties", false);
loopController.boolProp('LoopController.continue_forever', loopProps.continue, false);
loopController.stringProp('LoopController.loops', loopProps.loops, 1);
}
}
@ -260,6 +229,8 @@ export class HTTPSamplerProxy extends DefaultTestElement {
} else {
this.stringProp("HTTPSampler.port", this.request.port);
}
this.boolProp("HTTPSampler.follow_redirects", this.request.follow, true);
}
}
@ -279,8 +250,8 @@ export class HTTPSamplerArguments extends Element {
let collectionProp = this.collectionProp('Arguments.arguments');
this.args.forEach(arg => {
let elementProp = collectionProp.elementProp(arg.name, 'HTTPArgument');
elementProp.boolProp('HTTPArgument.always_encode', arg.encode || true);
elementProp.boolProp('HTTPArgument.use_equals', arg.equals || true);
elementProp.boolProp('HTTPArgument.always_encode', arg.encode, true);
elementProp.boolProp('HTTPArgument.use_equals', arg.equals, true);
if (arg.name) {
elementProp.stringProp('Argument.name', arg.name);
}
@ -375,21 +346,11 @@ export class Arguments extends DefaultTestElement {
elementProp.stringProp('Argument.name', arg.name);
elementProp.stringProp('Argument.value', arg.value);
elementProp.stringProp('Argument.desc', arg.desc);
elementProp.stringProp('Argument.metadata', arg.metadata || "=");
elementProp.stringProp('Argument.metadata', arg.metadata, "=");
});
}
}
export class BackendListener extends DefaultTestElement {
constructor(testName, className, args) {
super('BackendListener', 'BackendListenerGui', 'BackendListener', testName);
this.stringProp('classname', className);
if (args && args.length > 0) {
this.add(new ElementArguments(args));
}
}
}
export class ElementArguments extends Element {
constructor(args, name, testName) {
super('elementProp', {
@ -407,7 +368,7 @@ export class ElementArguments extends Element {
let elementProp = collectionProp.elementProp(arg.name, 'Argument');
elementProp.stringProp('Argument.name', arg.name);
elementProp.stringProp('Argument.value', arg.value);
elementProp.stringProp('Argument.metadata', arg.metadata || "=");
elementProp.stringProp('Argument.metadata', arg.metadata, "=");
});
}
}

View File

@ -1,16 +1,18 @@
import {
Element,
HTTPSamplerProxy,
HashTree,
TestElement,
HashTree,
TestPlan,
ThreadGroup,
HeaderManager,
HTTPSamplerProxy,
HTTPSamplerArguments,
Arguments,
DurationAssertion,
ResponseCodeAssertion,
ResponseDataAssertion,
ResponseHeadersAssertion,
BackendListener, RegexExtractor, JSONPostProcessor, XPath2Extractor, Arguments
RegexExtractor, JSONPostProcessor, XPath2Extractor,
} from "./JMX";
export const uuid = function () {
@ -460,7 +462,7 @@ class JMXGenerator {
body = request.body.kvs.filter(this.filter);
} else {
httpSamplerProxy.boolProp('HTTPSampler.postBodyRaw', true);
body.push({name: '', value: request.body.raw});
body.push({name: '', value: request.body.raw, encode: false});
}
httpSamplerProxy.add(new HTTPSamplerArguments(body));
@ -475,7 +477,8 @@ class JMXGenerator {
}
if (assertions.duration.isValid()) {
httpSamplerProxy.put(assertions.duration.type, assertions.duration.value);
let name = "Response In Time :" + assertions.duration.value
httpSamplerProxy.put(new DurationAssertion(name, assertions.duration.value));
}
}

View File

@ -5,6 +5,9 @@
<slot name="middle"></slot>
<ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" type="danger" @exec="deleteClick" @click.stop="deleteClickStop"/>
<slot name="behind"></slot>
<!--
<ms-table-operator-button :tip="$t('commons.remove')" icon="el-icon-s-fold" type="danger" @exec="removeClick" @click.stop="removeClickStop"/>
-->
</span>
</template>
@ -26,7 +29,13 @@
},
deleteClickStop() {
this.$emit('deleteClickStop');
}
},
/* removeClick(){
this.$emit('removeClick');
},
removeClickStop(){
this.$emit('removeClickStop')
}*/
}
}
</script>

View File

@ -56,7 +56,11 @@
</el-table-column>
<el-table-column :label="$t('commons.operating')">
<template v-slot:default="scope">
<ms-table-operator @editClick="editMember(scope.row)" @deleteClick="delMember(scope.row)"/>
<!--<ms-table-operator @editClick="editMember(scope.row)" @deleteClick="delMember(scope.row)"/>-->
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" @exec="editMember(scope.row)"/>
<ms-table-operator-button :tip="$t('commons.remove')" icon="el-icon-delete" type="danger"
@exec="delMember(scope.row)"/>
</template>
</el-table-column>
</el-table>
@ -150,12 +154,21 @@
import MsTableHeader from "../../common/components/MsTableHeader";
import MsRolesTag from "../../common/components/MsRolesTag";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {getCurrentUser, getCurrentWorkspaceId, refreshSessionAndCookies} from "../../../../common/js/utils";
export default {
name: "MsOrganizationWorkspace",
components: {MsCreateBox, MsTablePagination, MsTableHeader, MsRolesTag, MsTableOperator, MsDialogFooter},
components: {
MsCreateBox,
MsTablePagination,
MsTableHeader,
MsRolesTag,
MsTableOperator,
MsDialogFooter,
MsTableOperatorButton
},
activated() {
this.list();
},
@ -327,17 +340,17 @@
this.$set(this.memberForm, 'roleIds', roleIds);
},
delMember(row) {
this.$confirm(this.$t('member.delete_confirm'), '', {
this.$confirm(this.$t('member.remove_member'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.result = this.$get('/user/ws/member/delete/' + this.currentWorkspaceRow.id + '/' + row.id, () => {
this.$success(this.$t('commons.delete_success'));
this.$success(this.$t('commons.remove_success'));
this.cellClick(this.currentWorkspaceRow);
});
}).catch(() => {
this.$info(this.$t('commons.delete_cancel'));
this.$info(this.$t('commons.remove_cancel'));
});
},
updateOrgMember() {

View File

@ -42,7 +42,15 @@
</el-table-column>
<el-table-column :label="$t('commons.operating')">
<template v-slot:default="scope">
<ms-table-operator @editClick="editMember(scope.row)" @deleteClick="delMember(scope.row)"/>
<!--<ms-table-operator @editClick="editMember(scope.row)" @deleteClick="delMember(scope.row)"/>-->
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" @exec="editMember(scope.row)"/>
<ms-table-operator-button :tip="$t('commons.remove')" icon="el-icon-delete" type="danger"
@exec="delMember(scope.row)"/>
<!--<el-tooltip class="item" effect="dark" :content="$t('commons.remove')" placement="bottom">
<el-button :icon="el-icon-remove-outline">下边</el-button>
</el-tooltip>-->
</template>
</el-table-column>
</el-table>
@ -173,13 +181,22 @@
import MsTableHeader from "../../common/components/MsTableHeader";
import MsRolesTag from "../../common/components/MsRolesTag";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {getCurrentOrganizationId, getCurrentUser, refreshSessionAndCookies} from "../../../../common/js/utils";
import {DEFAULT, ORGANIZATION} from "../../../../common/js/constants";
export default {
name: "MsOrganization",
components: {MsCreateBox, MsTablePagination, MsTableHeader, MsRolesTag, MsTableOperator, MsDialogFooter},
components: {
MsCreateBox,
MsTablePagination,
MsTableHeader,
MsRolesTag,
MsTableOperator,
MsDialogFooter,
MsTableOperatorButton
},
data() {
return {
queryPath: '/organization/list',
@ -324,7 +341,7 @@
});
},
delMember(row) {
this.$confirm(this.$t('member.delete_confirm'), '', {
this.$confirm(this.$t('member.remove_member'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
@ -337,11 +354,11 @@
let sign = ORGANIZATION;
refreshSessionAndCookies(sign, sourceId);
}
this.$success(this.$t('commons.delete_success'))
this.$success(this.$t('commons.remove_success'))
this.cellClick(this.currentRow);
});
}).catch(() => {
this.$info(this.$t('commons.delete_cancel'));
this.$info(this.$t('commons.remove_cancel'));
});
},
createOrganization(createOrganizationForm) {

View File

@ -76,7 +76,7 @@
formInline: {
host: 'smtp.163.com',
port: '465',
account: 'xjj0608@153.com',
account: 'xjj0608@163.com',
password: '2345678',
},
result: {},
@ -136,15 +136,8 @@
this.$refs[formInline].validate((valid) => {
if (valid) {
this.result = this.$post("/system/testConnection", param, response => {
let flag = response.success;
if (flag) {
this.$success(this.$t('commons.connection_successful'));
} else {
this.$error(this.$t('commons.connection_failed'));
}
}).catch(() => {
this.$info(this.$t('commons.connection_failed'));
});
this.$success(this.$t('commons.connection_successful'));
})
} else {
return false;
}

View File

@ -100,7 +100,10 @@
</el-table-column>
<el-table-column :label="$t('commons.operating')">
<template v-slot:default="scope">
<ms-table-operator @editClick="editMember(scope.row)" @deleteClick="delMember(scope.row)"/>
<!--<ms-table-operator @editClick="editMember(scope.row)" @deleteClick="delMember(scope.row)"/>-->
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" @exec="editMember(scope.row)"/>
<ms-table-operator-button :tip="$t('commons.remove')" icon="el-icon-delete" type="danger"
@exec="delMember(scope.row)"/>
</template>
</el-table-column>
</el-table>
@ -194,13 +197,22 @@
import MsTableHeader from "../../common/components/MsTableHeader";
import MsRolesTag from "../../common/components/MsRolesTag";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {getCurrentUser, getCurrentWorkspaceId, refreshSessionAndCookies} from "../../../../common/js/utils";
import {DEFAULT, WORKSPACE} from "../../../../common/js/constants";
export default {
name: "MsSystemWorkspace",
components: {MsCreateBox, MsTablePagination, MsTableHeader, MsRolesTag, MsTableOperator, MsDialogFooter},
components: {
MsCreateBox,
MsTablePagination,
MsTableHeader,
MsRolesTag,
MsTableOperator,
MsDialogFooter,
MsTableOperatorButton
},
activated() {
this.list();
},
@ -376,7 +388,7 @@
this.$set(this.memberForm, 'roleIds', roleIds);
},
delMember(row) {
this.$confirm(this.$t('member.delete_confirm'), '', {
this.$confirm(this.$t('member.remove_member'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
@ -389,11 +401,11 @@
let sign = WORKSPACE;
refreshSessionAndCookies(sign, sourceId);
}
this.$success(this.$t('commons.delete_success'));
this.$success(this.$t('commons.remove_success'));
this.cellClick(this.currentWorkspaceRow);
});
}).catch(() => {
this.$info(this.$t('commons.delete_cancel'));
this.$info(this.$t('commons.remove_cancel'));
});
},
updateWorkspaceMember() {

View File

@ -88,6 +88,9 @@ export default {
'weeks_5': 'Fri',
'weeks_6': 'Sat',
'test_unit': 'tests',
'remove': 'Remove',
'remove_cancel': 'Remove Failed',
'remove_success': 'Remove Success'
},
workspace: {
'create': 'Create Workspace',
@ -143,6 +146,7 @@ export default {
'password_format_is_incorrect': 'Password format is incorrect (At least 8-16 characters, at least 1 uppercase letter, 1 lowercase letter and 1 number)',
'old_password': 'Old Password',
'new_password': 'New Password',
'remove_member': 'Are you sure you want to remove this member'
},
user: {
'create': 'Create',
@ -334,7 +338,9 @@ export default {
success: "Success",
fail: "Fail",
total: "Total",
test_name: "Test"
test_name: "Test",
request_result: "Result",
sub_result: "Sub Result"
},
test_track: {
test_track: "Track",

View File

@ -87,6 +87,9 @@ export default {
'host_cannot_be_empty': '主机不能为空',
'port_cannot_be_empty': '端口号不能为空',
'account_cannot_be_empty': '帐户不能为空',
'remove': '移除',
'remove_cancel': '移除失败',
'remove_success': '移除成功'
},
workspace: {
'create': '创建工作空间',
@ -141,6 +144,7 @@ export default {
'password_format_is_incorrect': '密码格式不正确(至少8-16个字符至少1个大写字母1个小写字母和1个数字)',
'old_password': '旧密码',
'new_password': '新密码',
'remove_member': '确定要移除该成员吗'
},
user: {
'create': '创建用户',
@ -331,7 +335,9 @@ export default {
success: "成功",
fail: "失败",
total: "全部",
test_name: "所属测试"
test_name: "所属测试",
request_result: "请求结果",
sub_result: "子请求"
},
test_track: {
test_track: "测试跟踪",

View File

@ -326,7 +326,9 @@ export default {
success: "成功",
fail: "失敗",
total: "全部",
test_name: "所屬測試"
test_name: "所屬測試",
request_result: "請求結果",
sub_result: "子請求"
},
test_track: {
test_track: "測試跟踪",