refactor(性能测试): 性能测试报告列表显示时间信息

This commit is contained in:
Captain.B 2021-05-18 18:30:38 +08:00 committed by 刘瑞斌
parent 16b227edbe
commit b7a5282bb1
14 changed files with 382 additions and 60 deletions

View File

@ -33,5 +33,11 @@ public class LoadTestReport implements Serializable {
private String testName; private String testName;
private Long testStartTime;
private Long testEndTime;
private Long testDuration;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -1063,6 +1063,186 @@ public class LoadTestReportExample {
addCriterion("test_name not between", value1, value2, "testName"); addCriterion("test_name not between", value1, value2, "testName");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestStartTimeIsNull() {
addCriterion("test_start_time is null");
return (Criteria) this;
}
public Criteria andTestStartTimeIsNotNull() {
addCriterion("test_start_time is not null");
return (Criteria) this;
}
public Criteria andTestStartTimeEqualTo(Long value) {
addCriterion("test_start_time =", value, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeNotEqualTo(Long value) {
addCriterion("test_start_time <>", value, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeGreaterThan(Long value) {
addCriterion("test_start_time >", value, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeGreaterThanOrEqualTo(Long value) {
addCriterion("test_start_time >=", value, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeLessThan(Long value) {
addCriterion("test_start_time <", value, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeLessThanOrEqualTo(Long value) {
addCriterion("test_start_time <=", value, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeIn(List<Long> values) {
addCriterion("test_start_time in", values, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeNotIn(List<Long> values) {
addCriterion("test_start_time not in", values, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeBetween(Long value1, Long value2) {
addCriterion("test_start_time between", value1, value2, "testStartTime");
return (Criteria) this;
}
public Criteria andTestStartTimeNotBetween(Long value1, Long value2) {
addCriterion("test_start_time not between", value1, value2, "testStartTime");
return (Criteria) this;
}
public Criteria andTestEndTimeIsNull() {
addCriterion("test_end_time is null");
return (Criteria) this;
}
public Criteria andTestEndTimeIsNotNull() {
addCriterion("test_end_time is not null");
return (Criteria) this;
}
public Criteria andTestEndTimeEqualTo(Long value) {
addCriterion("test_end_time =", value, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeNotEqualTo(Long value) {
addCriterion("test_end_time <>", value, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeGreaterThan(Long value) {
addCriterion("test_end_time >", value, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeGreaterThanOrEqualTo(Long value) {
addCriterion("test_end_time >=", value, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeLessThan(Long value) {
addCriterion("test_end_time <", value, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeLessThanOrEqualTo(Long value) {
addCriterion("test_end_time <=", value, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeIn(List<Long> values) {
addCriterion("test_end_time in", values, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeNotIn(List<Long> values) {
addCriterion("test_end_time not in", values, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeBetween(Long value1, Long value2) {
addCriterion("test_end_time between", value1, value2, "testEndTime");
return (Criteria) this;
}
public Criteria andTestEndTimeNotBetween(Long value1, Long value2) {
addCriterion("test_end_time not between", value1, value2, "testEndTime");
return (Criteria) this;
}
public Criteria andTestDurationIsNull() {
addCriterion("test_duration is null");
return (Criteria) this;
}
public Criteria andTestDurationIsNotNull() {
addCriterion("test_duration is not null");
return (Criteria) this;
}
public Criteria andTestDurationEqualTo(Long value) {
addCriterion("test_duration =", value, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationNotEqualTo(Long value) {
addCriterion("test_duration <>", value, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationGreaterThan(Long value) {
addCriterion("test_duration >", value, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationGreaterThanOrEqualTo(Long value) {
addCriterion("test_duration >=", value, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationLessThan(Long value) {
addCriterion("test_duration <", value, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationLessThanOrEqualTo(Long value) {
addCriterion("test_duration <=", value, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationIn(List<Long> values) {
addCriterion("test_duration in", values, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationNotIn(List<Long> values) {
addCriterion("test_duration not in", values, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationBetween(Long value1, Long value2) {
addCriterion("test_duration between", value1, value2, "testDuration");
return (Criteria) this;
}
public Criteria andTestDurationNotBetween(Long value1, Long value2) {
addCriterion("test_duration not between", value1, value2, "testDuration");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -16,6 +16,9 @@
<result column="tps" jdbcType="VARCHAR" property="tps" /> <result column="tps" jdbcType="VARCHAR" property="tps" />
<result column="project_id" jdbcType="VARCHAR" property="projectId" /> <result column="project_id" jdbcType="VARCHAR" property="projectId" />
<result column="test_name" jdbcType="VARCHAR" property="testName" /> <result column="test_name" jdbcType="VARCHAR" property="testName" />
<result column="test_start_time" jdbcType="BIGINT" property="testStartTime" />
<result column="test_end_time" jdbcType="BIGINT" property="testEndTime" />
<result column="test_duration" jdbcType="BIGINT" property="testDuration" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestReportWithBLOBs"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestReportWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" /> <result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -82,7 +85,8 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, test_id, `name`, create_time, update_time, `status`, user_id, trigger_mode, file_id, id, test_id, `name`, create_time, update_time, `status`, user_id, trigger_mode, file_id,
max_users, avg_response_time, tps, project_id, test_name max_users, avg_response_time, tps, project_id, test_name, test_start_time, test_end_time,
test_duration
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
description, load_configuration, jmx_content description, load_configuration, jmx_content
@ -140,13 +144,15 @@
create_time, update_time, `status`, create_time, update_time, `status`,
user_id, trigger_mode, file_id, user_id, trigger_mode, file_id,
max_users, avg_response_time, tps, max_users, avg_response_time, tps,
project_id, test_name, description, project_id, test_name, test_start_time,
test_end_time, test_duration, description,
load_configuration, jmx_content) load_configuration, jmx_content)
values (#{id,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR},
#{maxUsers,jdbcType=VARCHAR}, #{avgResponseTime,jdbcType=VARCHAR}, #{tps,jdbcType=VARCHAR}, #{maxUsers,jdbcType=VARCHAR}, #{avgResponseTime,jdbcType=VARCHAR}, #{tps,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{testName,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, #{projectId,jdbcType=VARCHAR}, #{testName,jdbcType=VARCHAR}, #{testStartTime,jdbcType=BIGINT},
#{testEndTime,jdbcType=BIGINT}, #{testDuration,jdbcType=BIGINT}, #{description,jdbcType=LONGVARCHAR},
#{loadConfiguration,jdbcType=LONGVARCHAR}, #{jmxContent,jdbcType=LONGVARCHAR}) #{loadConfiguration,jdbcType=LONGVARCHAR}, #{jmxContent,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestReportWithBLOBs"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestReportWithBLOBs">
@ -194,6 +200,15 @@
<if test="testName != null"> <if test="testName != null">
test_name, test_name,
</if> </if>
<if test="testStartTime != null">
test_start_time,
</if>
<if test="testEndTime != null">
test_end_time,
</if>
<if test="testDuration != null">
test_duration,
</if>
<if test="description != null"> <if test="description != null">
description, description,
</if> </if>
@ -247,6 +262,15 @@
<if test="testName != null"> <if test="testName != null">
#{testName,jdbcType=VARCHAR}, #{testName,jdbcType=VARCHAR},
</if> </if>
<if test="testStartTime != null">
#{testStartTime,jdbcType=BIGINT},
</if>
<if test="testEndTime != null">
#{testEndTime,jdbcType=BIGINT},
</if>
<if test="testDuration != null">
#{testDuration,jdbcType=BIGINT},
</if>
<if test="description != null"> <if test="description != null">
#{description,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR},
</if> </if>
@ -309,6 +333,15 @@
<if test="record.testName != null"> <if test="record.testName != null">
test_name = #{record.testName,jdbcType=VARCHAR}, test_name = #{record.testName,jdbcType=VARCHAR},
</if> </if>
<if test="record.testStartTime != null">
test_start_time = #{record.testStartTime,jdbcType=BIGINT},
</if>
<if test="record.testEndTime != null">
test_end_time = #{record.testEndTime,jdbcType=BIGINT},
</if>
<if test="record.testDuration != null">
test_duration = #{record.testDuration,jdbcType=BIGINT},
</if>
<if test="record.description != null"> <if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR},
</if> </if>
@ -339,6 +372,9 @@
tps = #{record.tps,jdbcType=VARCHAR}, tps = #{record.tps,jdbcType=VARCHAR},
project_id = #{record.projectId,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR},
test_name = #{record.testName,jdbcType=VARCHAR}, test_name = #{record.testName,jdbcType=VARCHAR},
test_start_time = #{record.testStartTime,jdbcType=BIGINT},
test_end_time = #{record.testEndTime,jdbcType=BIGINT},
test_duration = #{record.testDuration,jdbcType=BIGINT},
description = #{record.description,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR},
load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR}, load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR},
jmx_content = #{record.jmxContent,jdbcType=LONGVARCHAR} jmx_content = #{record.jmxContent,jdbcType=LONGVARCHAR}
@ -361,7 +397,10 @@
avg_response_time = #{record.avgResponseTime,jdbcType=VARCHAR}, avg_response_time = #{record.avgResponseTime,jdbcType=VARCHAR},
tps = #{record.tps,jdbcType=VARCHAR}, tps = #{record.tps,jdbcType=VARCHAR},
project_id = #{record.projectId,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR},
test_name = #{record.testName,jdbcType=VARCHAR} test_name = #{record.testName,jdbcType=VARCHAR},
test_start_time = #{record.testStartTime,jdbcType=BIGINT},
test_end_time = #{record.testEndTime,jdbcType=BIGINT},
test_duration = #{record.testDuration,jdbcType=BIGINT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -408,6 +447,15 @@
<if test="testName != null"> <if test="testName != null">
test_name = #{testName,jdbcType=VARCHAR}, test_name = #{testName,jdbcType=VARCHAR},
</if> </if>
<if test="testStartTime != null">
test_start_time = #{testStartTime,jdbcType=BIGINT},
</if>
<if test="testEndTime != null">
test_end_time = #{testEndTime,jdbcType=BIGINT},
</if>
<if test="testDuration != null">
test_duration = #{testDuration,jdbcType=BIGINT},
</if>
<if test="description != null"> <if test="description != null">
description = #{description,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR},
</if> </if>
@ -435,6 +483,9 @@
tps = #{tps,jdbcType=VARCHAR}, tps = #{tps,jdbcType=VARCHAR},
project_id = #{projectId,jdbcType=VARCHAR}, project_id = #{projectId,jdbcType=VARCHAR},
test_name = #{testName,jdbcType=VARCHAR}, test_name = #{testName,jdbcType=VARCHAR},
test_start_time = #{testStartTime,jdbcType=BIGINT},
test_end_time = #{testEndTime,jdbcType=BIGINT},
test_duration = #{testDuration,jdbcType=BIGINT},
description = #{description,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR},
load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR}, load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR},
jmx_content = #{jmxContent,jdbcType=LONGVARCHAR} jmx_content = #{jmxContent,jdbcType=LONGVARCHAR}
@ -454,7 +505,10 @@
avg_response_time = #{avgResponseTime,jdbcType=VARCHAR}, avg_response_time = #{avgResponseTime,jdbcType=VARCHAR},
tps = #{tps,jdbcType=VARCHAR}, tps = #{tps,jdbcType=VARCHAR},
project_id = #{projectId,jdbcType=VARCHAR}, project_id = #{projectId,jdbcType=VARCHAR},
test_name = #{testName,jdbcType=VARCHAR} test_name = #{testName,jdbcType=VARCHAR},
test_start_time = #{testStartTime,jdbcType=BIGINT},
test_end_time = #{testEndTime,jdbcType=BIGINT},
test_duration = #{testDuration,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -66,7 +66,8 @@
<select id="getReportList" resultType="io.metersphere.dto.ReportDTO"> <select id="getReportList" resultType="io.metersphere.dto.ReportDTO">
select ltr.id, ltr.name, ltr.test_id as testId, ltr.max_users maxUsers, ltr.avg_response_time avgResponseTime, select ltr.id, ltr.name, ltr.test_id as testId, ltr.max_users maxUsers, ltr.avg_response_time avgResponseTime,
ltr.tps, ltr.description, user.name as userName, project.name as ltr.tps, ltr.test_start_time as testStartTime, ltr.test_end_time as testEndTime, ltr.test_duration as testDuration,
ltr.description, user.name as userName, project.name as
projectName, ltr.trigger_mode, projectName, ltr.trigger_mode,
ltr.create_time as createTime, ltr.update_time as updateTime, ltr.status as status, ltr.test_name as testName, ltr.create_time as createTime, ltr.update_time as updateTime, ltr.status as status, ltr.test_name as testName,
project.id as projectId project.id as projectId

View File

@ -23,4 +23,7 @@ public class ReportDTO {
private String maxUsers; private String maxUsers;
private String avgResponseTime; private String avgResponseTime;
private String tps; private String tps;
private long testStartTime;
private long testEndTime;
private long testDuration;
} }

View File

@ -4,9 +4,7 @@ import lombok.Data;
@Data @Data
public class ReportTimeInfo { public class ReportTimeInfo {
private long duration;
private String duration; private long startTime;
private String startTime; private long endTime;
private String endTime;
} }

View File

@ -201,11 +201,8 @@ public class MetricQueryService {
MetricRequest metricRequest = new MetricRequest(); MetricRequest metricRequest = new MetricRequest();
metricRequest.setMetricDataQueries(list); metricRequest.setMetricDataQueries(list);
try { try {
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); metricRequest.setStartTime(reportTimeInfo.getStartTime());
Date startTime = df.parse(reportTimeInfo.getStartTime()); metricRequest.setEndTime(reportTimeInfo.getEndTime());
Date endTime = df.parse(reportTimeInfo.getEndTime());
metricRequest.setStartTime(startTime.getTime());
metricRequest.setEndTime(endTime.getTime());
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
e.printStackTrace(); e.printStackTrace();

View File

@ -35,6 +35,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -169,7 +170,25 @@ public class PerformanceReportService {
public ReportTimeInfo getReportTimeInfo(String id) { public ReportTimeInfo getReportTimeInfo(String id) {
checkReportStatus(id); checkReportStatus(id);
String content = getContent(id, ReportKeys.TimeInfo); String content = getContent(id, ReportKeys.TimeInfo);
try {
return JSON.parseObject(content, ReportTimeInfo.class); return JSON.parseObject(content, ReportTimeInfo.class);
} catch (Exception e) {
// 兼容字符串和数字
ReportTimeInfo reportTimeInfo = new ReportTimeInfo();
JSONObject jsonObject = JSONObject.parseObject(content);
String startTime = jsonObject.getString("startTime");
String endTime = jsonObject.getString("endTime");
String duration = jsonObject.getString("duration");
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
try {
reportTimeInfo.setStartTime(df.parse(startTime).getTime());
reportTimeInfo.setEndTime(df.parse(endTime).getTime());
reportTimeInfo.setDuration(Long.parseLong(duration));
} catch (Exception parseException) {
}
return reportTimeInfo;
}
} }
public List<ChartsData> getLoadChartData(String id) { public List<ChartsData> getLoadChartData(String id) {

View File

@ -59,3 +59,13 @@ ALTER TABLE test_case
UPDATE system_parameter UPDATE system_parameter
SET param_key = 'base.prometheus.host' SET param_key = 'base.prometheus.host'
WHERE param_key = 'prometheus.host'; WHERE param_key = 'prometheus.host';
-- load_test_report
alter table load_test_report
add test_start_time BIGINT(13) null;
alter table load_test_report
add test_end_time BIGINT(13) null;
alter table load_test_report
add test_duration BIGINT(13) null;

View File

@ -44,13 +44,13 @@
{{ $t('report.test_duration', [this.minutes, this.seconds]) }} {{ $t('report.test_duration', [this.minutes, this.seconds]) }}
</span> </span>
<span class="ms-report-time-desc" v-if="startTime !== '0'"> <span class="ms-report-time-desc" v-if="startTime !== '0'">
{{ $t('report.test_start_time') }}{{ startTime }} {{ $t('report.test_start_time') }}{{ startTime | timestampFormatDate }}
</span> </span>
<span class="ms-report-time-desc" v-else> <span class="ms-report-time-desc" v-else>
{{ $t('report.test_start_time') }}- {{ $t('report.test_start_time') }}-
</span> </span>
<span class="ms-report-time-desc" v-if="report.status === 'Completed' && endTime !== '0'"> <span class="ms-report-time-desc" v-if="report.status === 'Completed' && endTime !== '0'">
{{ $t('report.test_end_time') }}{{ endTime }} {{ $t('report.test_end_time') }}{{ endTime | timestampFormatDate }}
</span> </span>
<span class="ms-report-time-desc" v-else> <span class="ms-report-time-desc" v-else>
{{ $t('report.test_end_time') }}- {{ $t('report.test_end_time') }}-

View File

@ -1,18 +1,20 @@
<template> <template>
<ms-container> <ms-container>
<ms-main-container> <ms-main-container>
<el-card class="table-card" v-loading="result.loading"> <el-card class="table-card">
<template v-slot:header> <template v-slot:header>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search" <ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search"
:title="$t('commons.report')" :title="$t('commons.report')"
:show-create="false"/> :show-create="false"/>
</template> </template>
<el-table border :data="tableData" class="adjust-table test-content" <el-table v-loading="result.loading"
border :data="tableData" class="adjust-table test-content"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@select="handleSelect" @select="handleSelect"
@sort-change="sort" @sort-change="sort"
@filter-change="filter" @filter-change="filter"
:height="screenHeight"
> >
<el-table-column <el-table-column
type="selection"/> type="selection"/>
@ -41,10 +43,11 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="maxUsers" prop="maxUsers"
width="65"
:label="$t('report.max_users')"> :label="$t('report.max_users')">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
width="150" width="100"
prop="avgResponseTime" prop="avgResponseTime"
:label="$t('report.response_time')"> :label="$t('report.response_time')">
</el-table-column> </el-table-column>
@ -53,12 +56,30 @@
label="TPS"> label="TPS">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
width="200" width="100"
prop="createTime" prop="testStartTime"
sortable :label="$t('report.test_start_time') ">
:label="$t('commons.create_time')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span> <span v-if="scope.row.testStartTime > 0">{{ scope.row.testStartTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column
width="100"
prop="testEndTime"
:label="$t('report.test_end_time')">
<template v-slot:default="scope">
<span v-if="scope.row.status === 'Completed'">{{ scope.row.testEndTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column
width="90"
prop="testDuration"
:label="$t('report.test_execute_time')">
<template v-slot:default="scope">
<span v-if="scope.row.status === 'Completed'">
{{ scope.row.minutes }}{{ $t('schedule.cron.minutes') }}
{{ scope.row.seconds }}{{ $t('schedule.cron.seconds') }}
</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="triggerMode" :label="$t('test_track.report.list.trigger_mode')" <el-table-column prop="triggerMode" :label="$t('test_track.report.list.trigger_mode')"
@ -149,6 +170,7 @@ export default {
total: 0, total: 0,
loading: false, loading: false,
testId: null, testId: null,
screenHeight: 'calc(100vh - 295px)',
statusFilters: [ statusFilters: [
{text: 'Starting', value: 'Starting'}, {text: 'Starting', value: 'Starting'},
{text: 'Running', value: 'Running'}, {text: 'Running', value: 'Running'},
@ -181,6 +203,44 @@ export default {
} }
}, },
methods: { methods: {
handleTimeInfo(report) {
if (report.testStartTime) {
let duration = report.testDuration;
let minutes = Math.floor(duration / 60);
let seconds = duration % 60;
this.$set(report, 'minutes', minutes);
this.$set(report, 'seconds', seconds);
}
if (report.status === 'Completed' && !report.testStartTime) {
this.result = this.$get("/performance/report/content/report_time/" + report.id)
.then(res => {
let data = res.data.data;
if (data) {
let duration = data.duration;
let minutes = Math.floor(duration / 60);
let seconds = duration % 60;
this.$set(report, 'testStartTime', data.startTime);
this.$set(report, 'testEndTime', data.endTime);
this.$set(report, 'minutes', minutes);
this.$set(report, 'seconds', seconds);
}
}).catch(() => {
});
}
},
handleOverview(report) {
if (report.status === 'Completed' && !report.maxUsers) {
this.result = this.$get('/performance/report/content/testoverview/' + report.id)
.then(response => {
let data = response.data.data;
this.$set(report, 'maxUsers', data.maxUsers);
this.$set(report, 'avgResponseTime', data.avgResponseTime);
this.$set(report, 'tps', data.avgTransactions);
})
.catch(() => {
});
}
},
initTableData() { initTableData() {
if (this.testId !== 'all') { if (this.testId !== 'all') {
this.condition.testId = this.testId; this.condition.testId = this.testId;
@ -199,17 +259,8 @@ export default {
this.selectRows = new Set(); this.selectRows = new Set();
this.tableData.forEach(report => { this.tableData.forEach(report => {
if (report.status === 'Completed' && !report.maxUsers) { this.handleOverview(report);
this.result = this.$get('/performance/report/content/testoverview/' + report.id) this.handleTimeInfo(report);
.then(response => {
let data = response.data.data;
this.$set(report, 'maxUsers', data.maxUsers);
this.$set(report, 'avgResponseTime', data.avgResponseTime);
this.$set(report, 'tps', data.avgTransactions);
})
.catch(() => {
});
}
}); });
}); });
}, },

View File

@ -488,6 +488,7 @@ export default {
test_monitor_details: 'Test Monitor Details', test_monitor_details: 'Test Monitor Details',
test_details: 'Test Details', test_details: 'Test Details',
test_duration: 'Execution Time{0} minutes {1} seconds', test_duration: 'Execution Time{0} minutes {1} seconds',
test_execute_time: 'Execution Time',
test_start_time: 'Start Time', test_start_time: 'Start Time',
test_end_time: 'End Time', test_end_time: 'End Time',
test_stop_now: 'Test Stop Now', test_stop_now: 'Test Stop Now',

View File

@ -486,6 +486,7 @@ export default {
test_monitor_details: '监控详情', test_monitor_details: '监控详情',
test_details: '测试详情', test_details: '测试详情',
test_duration: '执行时长:{0} 分钟 {1} 秒', test_duration: '执行时长:{0} 分钟 {1} 秒',
test_execute_time: '执行时长',
test_start_time: '开始时间', test_start_time: '开始时间',
test_end_time: '结束时间', test_end_time: '结束时间',
test_stop_now: '立即停止', test_stop_now: '立即停止',

View File

@ -486,6 +486,7 @@ export default {
test_monitor_details: '監控詳情', test_monitor_details: '監控詳情',
test_details: '測試詳情', test_details: '測試詳情',
test_duration: '執行時長:{0} 分鐘 {1} 秒', test_duration: '執行時長:{0} 分鐘 {1} 秒',
test_execute_time: '執行時長',
test_start_time: '開始時間', test_start_time: '開始時間',
test_end_time: '結束時間', test_end_time: '結束時間',
test_stop_now: '立即停止', test_stop_now: '立即停止',