Merge remote-tracking branch 'origin/master'

This commit is contained in:
song.tianyang 2020-12-17 18:48:26 +08:00
commit 62d1522dc6
15 changed files with 123 additions and 43 deletions

View File

@ -11,5 +11,6 @@ public class ApiTestCaseResult extends ApiTestCaseWithBLOBs {
private String createUser;
private String updateUser;
private String execResult;
private Long execTime;
private boolean active = false;
}

View File

@ -29,6 +29,7 @@ public class ApiDefinitionExecResultService {
extApiDefinitionExecResultMapper.deleteByResourceId(item.getName());
ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult();
saveResult.setId(UUID.randomUUID().toString());
saveResult.setCreateTime(System.currentTimeMillis());
saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
saveResult.setName(item.getName());
saveResult.setResourceId(item.getName());

View File

@ -283,6 +283,7 @@ public class ApiDefinitionService {
createBodyFiles(bodyUploadIds, bodyFiles);
HashTree hashTree = request.getTestElement().generateHashTree();
request.getTestElement().getJmx(hashTree);
// 调用执行方法
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.DELIMIT.name());
return request.getId();

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class ApiDefinitionExecResult implements Serializable {
@ -20,6 +19,8 @@ public class ApiDefinitionExecResult implements Serializable {
private Long endTime;
private Long createTime;
private String content;
private static final long serialVersionUID = 1L;

View File

@ -573,6 +573,66 @@ public class ApiDefinitionExecResultExample {
addCriterion("end_time not between", value1, value2, "endTime");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ApiDefinitionExecResultMapper {
long countByExample(ApiDefinitionExecResultExample example);

View File

@ -9,6 +9,7 @@
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="start_time" jdbcType="BIGINT" property="startTime" />
<result column="end_time" jdbcType="BIGINT" property="endTime" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDefinitionExecResult">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
@ -72,7 +73,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, resource_id, `status`, user_id, start_time, end_time
id, `name`, resource_id, `status`, user_id, start_time, end_time, create_time
</sql>
<sql id="Blob_Column_List">
content
@ -128,10 +129,12 @@
<insert id="insert" parameterType="io.metersphere.base.domain.ApiDefinitionExecResult">
insert into api_definition_exec_result (id, `name`, resource_id,
`status`, user_id, start_time,
end_time, content)
end_time, create_time, content
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT},
#{endTime,jdbcType=BIGINT}, #{content,jdbcType=LONGVARCHAR})
#{endTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT}, #{content,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDefinitionExecResult">
insert into api_definition_exec_result
@ -157,6 +160,9 @@
<if test="endTime != null">
end_time,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="content != null">
content,
</if>
@ -183,6 +189,9 @@
<if test="endTime != null">
#{endTime,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
@ -218,6 +227,9 @@
<if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=BIGINT},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
@ -235,6 +247,7 @@
user_id = #{record.userId,jdbcType=VARCHAR},
start_time = #{record.startTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -248,7 +261,8 @@
`status` = #{record.status,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
start_time = #{record.startTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT}
end_time = #{record.endTime,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -274,6 +288,9 @@
<if test="endTime != null">
end_time = #{endTime,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
@ -288,6 +305,7 @@
user_id = #{userId,jdbcType=VARCHAR},
start_time = #{startTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
@ -298,7 +316,8 @@
`status` = #{status,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
start_time = #{startTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT}
end_time = #{endTime,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -7,6 +7,6 @@
<select id="selectMaxResultByResourceId" parameterType="java.lang.String" resultType="io.metersphere.base.domain.ApiDefinitionExecResult">
select * from api_definition_exec_result
where resource_id = #{resourceId,jdbcType=VARCHAR} ORDER BY start_time DESC LIMIT 1
where resource_id = #{resourceId,jdbcType=VARCHAR} ORDER BY create_time DESC LIMIT 1
</select>
</mapper>

View File

@ -94,20 +94,16 @@
when 'error' then '未通过'
ELSE '未执行' end as status ,
CONCAT(FORMAT(SUM(IF(t2.`status` = 'success', 1, 0))/ COUNT(t1.id)*100, 2), '%') passRate
from api_test_case t1 left join (
select
a.status, a.id, a.resource_id
from
api_definition_exec_result a
from api_test_case t1
left join (
select
max(start_time) start_time , id, resource_id
from
api_definition_exec_result
group by
resource_id ) as b on a.id = b.id
where
a.start_time = b.start_time)as t2 on t1.id = t2.resource_id
select
max(create_time) create_time ,status ,id, resource_id
from
api_definition_exec_result
group by
resource_id
)as t2
on t1.id = t2.resource_id
group by t1.api_definition_id having t1.api_definition_id in
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}

View File

@ -161,7 +161,8 @@
atc.create_time,
atc.update_user_id,
atc.update_time,
ader.status execResult
ader.status execResult,
ader.create_time execTime
from
api_test_case atc
left join user u1 on
@ -170,18 +171,11 @@
atc.update_user_id = u2.id
left join (
select
a.status, a.id, a.resource_id
max(create_time) create_time ,status ,id, resource_id
from
api_definition_exec_result a
left join (
select
max(start_time) start_time , id, resource_id
from
api_definition_exec_result
group by
resource_id ) as b on a.id = b.id
where
a.start_time = b.start_time) as ader
api_definition_exec_result
group by
resource_id) as ader
on atc.id = ader.resource_id
<where>
<if test="request.name != null and request.name!=''">

@ -1 +1 @@
Subproject commit 2f4f76c93afa7b62b1d73fa90e73eec948a6ef3f
Subproject commit 61397c16728a63493507679f7e0940d9099f337f

View File

@ -0,0 +1 @@
ALTER TABLE api_definition_exec_result ADD create_time BIGINT(13) NULL;

View File

@ -49,7 +49,7 @@
<div v-else> {{getResult(apiCase.execResult)}}</div>
<div v-if="apiCase.id" style="color: #999999;font-size: 12px">
<span> {{apiCase.updateTime | timestampFormatDate }}</span>
<span> {{apiCase.execTime | timestampFormatDate }}</span>
{{apiCase.updateUser}}
</div>
</el-col>

View File

@ -13,14 +13,14 @@
ref="nodeTree">
<template v-slot:header>
<api-module-header
:condition="condition"
:current-module="currentModule"
:is-read-only="isReadOnly"
@exportAPI="exportAPI"
@saveAsEdit="saveAsEdit"
@refresh="refresh"
@debug="debug"/>
<api-module-header
:condition="condition"
:current-module="currentModule"
:is-read-only="isReadOnly"
@exportAPI="exportAPI"
@saveAsEdit="saveAsEdit"
@refresh="refresh"
@debug="debug"/>
</template>
</ms-node-tree>
@ -157,6 +157,7 @@
this.$emit('saveAsEdit', data);
},
refresh() {
this.list();
this.$emit("refreshTable");
},
}

View File

@ -173,6 +173,10 @@ export default {
this.$warning(this.$t('test_track.case.input_name'));
return;
}
if (data.name.trim().length > 50) {
this.$warning(this.$t('test_track.length_less_than') + '50');
return;
}
let param = {};
this.buildSaveParam(param, node.parent.data, data);
if (param.type === 'edit') {