This commit is contained in:
chenjianxing 2020-10-28 17:28:48 +08:00
commit b28438be76
12 changed files with 763 additions and 547 deletions

View File

@ -6,11 +6,11 @@
parameterType="io.metersphere.track.request.testreview.QueryCaseReviewRequest">
select distinct test_case_review.id, test_case_review.name, test_case_review.creator, test_case_review.status,
test_case_review.create_time, test_case_review.update_time, test_case_review.end_time,
test_case_review.description
from test_case_review, project, test_case_review_project
test_case_review.description, user.name as creatorName
from test_case_review join test_case_review_project on test_case_review.id = test_case_review_project.review_id
join project on test_case_review_project.project_id = project.id
left join user on test_case_review.creator = user.id
<where>
test_case_review.id = test_case_review_project.review_id
and test_case_review_project.project_id = project.id
<if test="request.name != null">
and test_case_review.name like CONCAT('%', #{request.name},'%')
</if>

View File

@ -94,6 +94,12 @@
<property name="object" value="${condition}.creator"/>
</include>
</if>
<if test="${condition}.executor != null">
and test_plan_test_case.executor
<include refid="condition">
<property name="object" value="${condition}.executor"/>
</include>
</if>
</sql>
<select id="getReportMetric" parameterType="java.lang.String"

View File

@ -1,6 +1,6 @@
package io.metersphere.commons.constants;
public enum ReportKeys {
LoadChart, ResponseTimeChart, Errors, ErrorsTop5, RequestStatistics, Overview, TimeInfo, ResultStatus
LoadChart, ResponseTimeChart, ResponseCodeChart, Errors, ErrorsTop5, RequestStatistics, Overview, TimeInfo, ResultStatus, ErrorsChart
}

View File

@ -95,6 +95,16 @@ public class PerformanceReportController {
return reportService.getResponseTimeChartData(reportId);
}
@GetMapping("/content/error_chart/{reportId}")
public List<ChartsData> getErrorChartData(@PathVariable String reportId) {
return reportService.getErrorChartData(reportId);
}
@GetMapping("/content/response_code_chart/{reportId}")
public List<ChartsData> getResponseCodeChartData(@PathVariable String reportId) {
return reportService.getResponseCodeChartData(reportId);
}
@GetMapping("/{reportId}")
public LoadTestReportWithBLOBs getLoadTestReport(@PathVariable String reportId) {
return reportService.getLoadTestReport(reportId);

View File

@ -256,4 +256,16 @@ public class ReportService {
List<String> ids = reportRequest.getIds();
ids.forEach(this::deleteReport);
}
public List<ChartsData> getErrorChartData(String id) {
checkReportStatus(id);
String content = getContent(id, ReportKeys.ErrorsChart);
return JSON.parseArray(content, ChartsData.class);
}
public List<ChartsData> getResponseCodeChartData(String id) {
checkReportStatus(id);
String content = getContent(id, ReportKeys.ResponseCodeChart);
return JSON.parseArray(content, ChartsData.class);
}
}

View File

@ -1,8 +1,5 @@
package io.metersphere.service;
import static io.metersphere.commons.constants.ResourceStatusEnum.INVALID;
import static io.metersphere.commons.constants.ResourceStatusEnum.VALID;
import com.alibaba.fastjson.JSON;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.LoadTestMapper;
@ -25,6 +22,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@ -32,7 +30,8 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import static io.metersphere.commons.constants.ResourceStatusEnum.INVALID;
import static io.metersphere.commons.constants.ResourceStatusEnum.VALID;
/**
* @author dongbin
@ -210,7 +209,10 @@ public class TestResourcePoolService {
private void updateTestResource(TestResource testResource) {
testResource.setUpdateTime(System.currentTimeMillis());
testResource.setCreateTime(System.currentTimeMillis());
testResource.setId(UUID.randomUUID().toString());
if (StringUtils.isBlank(testResource.getId())) {
testResource.setId(UUID.randomUUID().toString());
}
// 如果是更新操作插入与原来的ID相同的数据
testResourceMapper.insertSelective(testResource);
}

View File

@ -10,4 +10,5 @@ public class TestCaseReviewDTO extends TestCaseReview {
private String projectName;
private String reviewerName;
private String creatorName;
}

View File

@ -143,6 +143,34 @@ export const CREATOR = {
}
}
export const EXECUTOR = {
key: "executor",
name: 'MsTableSearchSelect',
label: 'test_track.plan_view.executor',
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN, OPERATORS.CURRENT_USER],
change: function (component, value) { // 运算符change事件
if (value === OPERATORS.CURRENT_USER.value) {
component.value = value;
}
}
},
options: { // 异步获取候选项
url: "/user/list",
labelKey: "name",
valueKey: "id",
showLabel: option => {
return option.label + "(" + option.value + ")";
}
},
props: {
multiple: true
},
isShow: operator => {
return operator !== OPERATORS.CURRENT_USER.value;
}
}
export const TRIGGER_MODE = {
key: "triggerMode",
name: 'MsTableSearchSelect',
@ -287,6 +315,6 @@ export const TEST_CONFIGS = [NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, STATU
export const REPORT_CONFIGS = [NAME, TEST_NAME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE];
export const TEST_CASE_CONFIGS = [NAME, MODULE, PRIORITY, CREATE_TIME, TYPE, UPDATE_TIME, METHOD, CREATOR];
export const TEST_CASE_CONFIGS = [NAME, MODULE, PRIORITY, CREATE_TIME, TYPE, UPDATE_TIME, METHOD, CREATOR, EXECUTOR];
export const TEST_PLAN_CONFIGS = [NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, PRINCIPAL, TEST_PLAN_STATUS, STAGE];

View File

@ -4,7 +4,7 @@
<el-col :span="4">
<el-card shadow="always" class="ms-card-index-1">
<span class="ms-card-data">
<span class="ms-card-data-digital">{{maxUsers}}</span>
<span class="ms-card-data-digital">{{ maxUsers }}</span>
<span class="ms-card-data-unit"> VU</span>
</span>
<span class="ms-card-desc">Max Users</span>
@ -13,7 +13,7 @@
<el-col :span="4">
<el-card shadow="always" class="ms-card-index-2">
<span class="ms-card-data">
<span class="ms-card-data-digital">{{avgThroughput}}</span>
<span class="ms-card-data-digital">{{ avgThroughput }}</span>
<span class="ms-card-data-unit"> Hits/s</span>
</span>
<span class="ms-card-desc">Avg.Throughput</span>
@ -22,7 +22,7 @@
<el-col :span="4">
<el-card shadow="always" class="ms-card-index-3">
<span class="ms-card-data">
<span class="ms-card-data-digital">{{errors}}</span>
<span class="ms-card-data-digital">{{ errors }}</span>
<span class="ms-card-data-unit"> %</span>
</span>
<span class="ms-card-desc">Errors</span>
@ -31,7 +31,7 @@
<el-col :span="4">
<el-card shadow="always" class="ms-card-index-4">
<span class="ms-card-data">
<span class="ms-card-data-digital">{{avgResponseTime}}</span>
<span class="ms-card-data-digital">{{ avgResponseTime }}</span>
<span class="ms-card-data-unit"> s</span>
</span>
<span class="ms-card-desc">Avg.Response Time</span>
@ -40,7 +40,7 @@
<el-col :span="4">
<el-card shadow="always" class="ms-card-index-5">
<span class="ms-card-data">
<span class="ms-card-data-digital">{{responseTime90}}</span>
<span class="ms-card-data-digital">{{ responseTime90 }}</span>
<span class="ms-card-data-unit"> s</span>
</span>
<span class="ms-card-desc">90% Response Time</span>
@ -49,7 +49,7 @@
<el-col :span="4">
<el-card shadow="always" class="ms-card-index-6">
<span class="ms-card-data">
<span class="ms-card-data-digital">{{avgBandwidth}}</span>
<span class="ms-card-data-digital">{{ avgBandwidth }}</span>
<span class="ms-card-data-unit"> KiB/s</span>
</span>
<span class="ms-card-desc">Avg.Bandwidth</span>
@ -65,6 +65,14 @@
<ms-chart ref="chart2" :options="resOption" class="chart-config" :autoresize="true"></ms-chart>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<ms-chart ref="chart3" :options="errorOption" class="chart-config" :autoresize="true"></ms-chart>
</el-col>
<el-col :span="12">
<ms-chart ref="chart3" :options="resCodeOption" class="chart-config" :autoresize="true"></ms-chart>
</el-col>
</el-row>
</div>
</template>
@ -84,353 +92,505 @@ export default {
avgBandwidth: "0",
loadOption: {},
resOption: {},
id: ''
}
errorOption: {},
resCodeOption: {},
id: ''
}
},
methods: {
initTableData() {
this.$get("/performance/report/content/testoverview/" + this.id).then(res => {
let data = res.data.data;
this.maxUsers = data.maxUsers;
this.avgThroughput = data.avgThroughput;
this.errors = data.errors;
this.avgResponseTime = data.avgResponseTime;
this.responseTime90 = data.responseTime90;
this.avgBandwidth = data.avgBandwidth;
}).catch(() => {
this.maxUsers = '0';
this.avgThroughput = '0';
this.errors = '0';
this.avgResponseTime = '0';
this.responseTime90 = '0';
this.avgBandwidth = '0';
this.$warning(this.$t('report.generation_error'));
})
this.getLoadChart();
this.getResChart();
this.getErrorChart();
this.getResponseCodeChart();
},
methods: {
initTableData() {
this.$get("/performance/report/content/testoverview/" + this.id).then(res => {
let data = res.data.data;
this.maxUsers = data.maxUsers;
this.avgThroughput = data.avgThroughput;
this.errors = data.errors;
this.avgResponseTime = data.avgResponseTime;
this.responseTime90 = data.responseTime90;
this.avgBandwidth = data.avgBandwidth;
}).catch(() => {
getLoadChart() {
this.$get("/performance/report/content/load_chart/" + this.id).then(res => {
let data = res.data.data;
let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2);
let yAxisListMax = this._getChartMax(yAxisList);
let yAxis2ListMax = this._getChartMax(yAxis2List);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let yAxisIndex1List = data.filter(m => m.yAxis === -1).map(m => m.groupName);
yAxisIndex1List = this._unique(yAxisIndex1List);
let loadOption = {
title: {
text: 'Load',
left: 'center',
top: 20,
textStyle: {
color: '#65A2FF'
},
},
tooltip: {
show: true,
trigger: 'axis'
},
legend: {},
xAxis: {},
yAxis: [{
name: 'User',
type: 'value',
min: 0,
max: yAxisListMax,
splitNumber: 5,
interval: yAxisListMax / 5
},
{
name: 'Hits/s',
type: 'value',
splitNumber: 5,
min: 0,
max: yAxis2ListMax,
interval: yAxis2ListMax / 5
}
],
series: []
};
let setting = {
series: [
{
name: 'users',
color: '#0CA74A',
},
{
name: 'hits',
yAxisIndex: '1',
color: '#65A2FF',
},
{
name: 'errors',
yAxisIndex: '1',
color: '#E6113C',
}
]
}
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'})
})
this.loadOption = this.generateOption(loadOption, data, setting);
}).catch(() => {
this.loadOption = {};
})
},
getResChart() {
this.$get("/performance/report/content/res_chart/" + this.id).then(res => {
let data = res.data.data;
let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2);
let yAxisListMax = this._getChartMax(yAxisList);
let yAxis2ListMax = this._getChartMax(yAxis2List);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let yAxisIndex1List = data.filter(m => m.yAxis === -1).map(m => m.groupName);
yAxisIndex1List = this._unique(yAxisIndex1List);
let resOption = {
title: {
text: 'Response Time',
left: 'center',
top: 20,
textStyle: {
color: '#99743C'
},
},
tooltip: {
show: true,
trigger: 'axis',
extraCssText: 'z-index: 999;',
formatter: function (params, ticket, callback) {
let result = "";
let name = params[0].name;
result += name + "<br/>";
for (let i = 0; i < params.length; i++) {
let seriesName = params[i].seriesName;
if (seriesName.length > 100) {
seriesName = seriesName.substring(0, 100);
}
let value = params[i].value;
let marker = params[i].marker;
result += marker + seriesName + ": " + value[1] + "<br/>";
}
return result;
}
},
legend: {},
xAxis: {},
yAxis: [{
name: 'User',
type: 'value',
min: 0,
max: yAxisListMax,
interval: yAxisListMax / 5
},
{
name: 'Response Time',
type: 'value',
min: 0,
max: yAxis2ListMax,
interval: yAxis2ListMax / 5
}
],
series: []
}
let setting = {
series: [
{
name: 'users',
color: '#0CA74A',
}
]
}
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'})
})
this.resOption = this.generateOption(resOption, data, setting);
}).catch(() => {
this.resOption = {};
})
},
getErrorChart() {
this.$get("/performance/report/content/error_chart/" + this.id).then(res => {
let data = res.data.data;
let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let yAxisListMax = this._getChartMax(yAxisList);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let errorOption = {
title: {
text: 'Errors',
left: 'center',
top: 20,
textStyle: {
color: '#99743C'
},
},
tooltip: {
show: true,
trigger: 'axis',
extraCssText: 'z-index: 999;',
formatter: function (params, ticket, callback) {
let result = "";
let name = params[0].name;
result += name + "<br/>";
for (let i = 0; i < params.length; i++) {
let seriesName = params[i].seriesName;
if (seriesName.length > 100) {
seriesName = seriesName.substring(0, 100);
}
let value = params[i].value;
let marker = params[i].marker;
result += marker + seriesName + ": " + value[1] + "<br/>";
}
return result;
}
},
legend: {},
xAxis: {},
yAxis: [
{
name: 'No',
type: 'value',
min: 0,
max: yAxisListMax,
interval: yAxisListMax / 5
}
],
series: []
}
let setting = {
series: [
{
name: 'users',
color: '#0CA74A',
}
]
}
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
this.errorOption = this.generateOption(errorOption, data, setting);
}).catch(() => {
this.errorOption = {};
})
},
getResponseCodeChart() {
this.$get("/performance/report/content/response_code_chart/" + this.id).then(res => {
let data = res.data.data;
let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let yAxisListMax = this._getChartMax(yAxisList);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let resCodeOption = {
title: {
text: 'Response code',
left: 'center',
top: 20,
textStyle: {
color: '#99743C'
},
},
tooltip: {
show: true,
trigger: 'axis',
extraCssText: 'z-index: 999;',
formatter: function (params, ticket, callback) {
let result = "";
let name = params[0].name;
result += name + "<br/>";
for (let i = 0; i < params.length; i++) {
let seriesName = params[i].seriesName;
if (seriesName.length > 100) {
seriesName = seriesName.substring(0, 100);
}
let value = params[i].value;
let marker = params[i].marker;
result += marker + seriesName + ": " + value[1] + "<br/>";
}
return result;
}
},
legend: {},
xAxis: {},
yAxis: [
{
name: 'No',
type: 'value',
min: 0,
max: yAxisListMax,
interval: yAxisListMax / 5
}
],
series: []
}
let setting = {
series: [
{
name: 'users',
color: '#0CA74A',
}
]
}
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
this.resCodeOption = this.generateOption(resCodeOption, data, setting);
}).catch(() => {
this.resCodeOption = {};
})
},
generateOption(option, data, setting) {
let chartData = data;
let seriesArray = [];
for (let set in setting) {
if (set === "series") {
seriesArray = setting[set];
continue;
}
this.$set(option, set, setting[set]);
}
let legend = [], series = {}, xAxis = [], seriesData = [];
chartData.forEach(item => {
if (!xAxis.includes(item.xAxis)) {
xAxis.push(item.xAxis);
}
xAxis.sort()
let name = item.groupName
if (!legend.includes(name)) {
legend.push(name)
series[name] = []
}
if (item.yAxis === -1) {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis2.toFixed(2)]);
} else {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis.toFixed(2)]);
}
})
this.$set(option.legend, "data", legend);
this.$set(option.legend, "type", "scroll");
this.$set(option.legend, "bottom", "10px");
this.$set(option.xAxis, "data", xAxis);
for (let name in series) {
let d = series[name];
d.sort((a, b) => a[0].localeCompare(b[0]));
let items = {
name: name,
type: 'line',
data: d
};
let seriesArrayNames = seriesArray.map(m => m.name);
if (seriesArrayNames.includes(name)) {
for (let j = 0; j < seriesArray.length; j++) {
let seriesObj = seriesArray[j];
if (seriesObj['name'] === name) {
Object.assign(items, seriesObj);
}
}
}
seriesData.push(items);
}
this.$set(option, "series", seriesData);
return option;
},
_getChartMax(arr) {
const max = Math.max(...arr);
return Math.ceil(max / 4.5) * 5;
},
_unique(arr) {
return Array.from(new Set(arr));
}
},
watch: {
report: {
handler(val) {
if (!val.status || !val.id) {
return;
}
let status = val.status;
this.id = val.id;
if (status === "Completed" || status === "Running") {
this.initTableData();
} else {
this.maxUsers = '0';
this.avgThroughput = '0';
this.errors = '0';
this.avgResponseTime = '0';
this.responseTime90 = '0';
this.avgBandwidth = '0';
this.$warning(this.$t('report.generation_error'));
})
this.$get("/performance/report/content/load_chart/" + this.id).then(res => {
let data = res.data.data;
let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2);
let yAxisListMax = this._getChartMax(yAxisList);
let yAxis2ListMax = this._getChartMax(yAxis2List);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let yAxisIndex1List = data.filter(m => m.yAxis === -1).map(m => m.groupName);
yAxisIndex1List = this._unique(yAxisIndex1List);
let loadOption = {
title: {
text: 'Load',
left: 'center',
top: 20,
textStyle: {
color: '#65A2FF'
},
},
tooltip: {
show: true,
trigger: 'axis'
},
legend: {},
xAxis: {},
yAxis: [{
name: 'User',
type: 'value',
min: 0,
max: yAxisListMax,
splitNumber: 5,
interval: yAxisListMax / 5
},
{
name: 'Hits/s',
type: 'value',
splitNumber: 5,
min: 0,
max: yAxis2ListMax,
interval: yAxis2ListMax / 5
}
],
series: []
};
let setting = {
series: [
{
name: 'users',
color: '#0CA74A',
},
{
name: 'hits',
yAxisIndex: '1',
color: '#65A2FF',
},
{
name: 'errors',
yAxisIndex: '1',
color: '#E6113C',
}
]
}
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'})
})
this.loadOption = this.generateOption(loadOption, data, setting);
}).catch(() => {
this.loadOption = {};
})
this.$get("/performance/report/content/res_chart/" + this.id).then(res => {
let data = res.data.data;
let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2);
let yAxisListMax = this._getChartMax(yAxisList);
let yAxis2ListMax = this._getChartMax(yAxis2List);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let yAxisIndex1List = data.filter(m => m.yAxis === -1).map(m => m.groupName);
yAxisIndex1List = this._unique(yAxisIndex1List);
let resOption = {
title: {
text: 'Response Time',
left: 'center',
top: 20,
textStyle: {
color: '#99743C'
},
},
tooltip: {
show: true,
trigger: 'axis',
extraCssText: 'z-index: 999;',
formatter: function (params, ticket, callback) {
let result = "";
let name = params[0].name;
result += name + "<br/>";
for (let i = 0; i < params.length; i++) {
let seriesName = params[i].seriesName;
if (seriesName.length > 100) {
seriesName = seriesName.substring(0, 100);
}
let value = params[i].value;
let marker = params[i].marker;
result += marker + seriesName + ": " + value[1] + "<br/>";
}
return result;
}
},
legend: {},
xAxis: {},
yAxis: [{
name: 'User',
type: 'value',
min: 0,
max: yAxisListMax,
interval: yAxisListMax / 5
},
{
name: 'Response Time',
type: 'value',
min: 0,
max: yAxis2ListMax,
interval: yAxis2ListMax / 5
}
],
series: []
}
let setting = {
series: [
{
name: 'users',
color: '#0CA74A',
}
]
}
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'})
})
this.resOption = this.generateOption(resOption, data, setting);
}).catch(() => {
this.resOption = {};
})
},
generateOption(option, data, setting) {
let chartData = data;
let seriesArray = [];
for (let set in setting) {
if (set === "series") {
seriesArray = setting[set];
continue;
}
this.$set(option, set, setting[set]);
this.errorOption = {};
this.resCodeOption = {};
}
let legend = [], series = {}, xAxis = [], seriesData = [];
chartData.forEach(item => {
if (!xAxis.includes(item.xAxis)) {
xAxis.push(item.xAxis);
}
xAxis.sort()
let name = item.groupName
if (!legend.includes(name)) {
legend.push(name)
series[name] = []
}
if (item.yAxis === -1) {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis2.toFixed(2)]);
} else {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis.toFixed(2)]);
}
})
this.$set(option.legend, "data", legend);
this.$set(option.legend, "type", "scroll");
this.$set(option.legend, "bottom", "10px");
this.$set(option.xAxis, "data", xAxis);
for (let name in series) {
let d = series[name];
d.sort((a, b) => a[0].localeCompare(b[0]));
let items = {
name: name,
type: 'line',
data: d
};
let seriesArrayNames = seriesArray.map(m => m.name);
if (seriesArrayNames.includes(name)) {
for (let j = 0; j < seriesArray.length; j++) {
let seriesObj = seriesArray[j];
if (seriesObj['name'] === name) {
Object.assign(items, seriesObj);
}
}
}
seriesData.push(items);
}
this.$set(option, "series", seriesData);
return option;
},
_getChartMax(arr) {
const max = Math.max(...arr);
return Math.ceil(max / 4.5) * 5;
},
_unique(arr) {
return Array.from(new Set(arr));
}
},
watch: {
report: {
handler(val) {
if (!val.status || !val.id) {
return;
}
let status = val.status;
this.id = val.id;
if (status === "Completed" || status === "Running") {
this.initTableData();
} else {
this.maxUsers = '0';
this.avgThroughput = '0';
this.errors = '0';
this.avgResponseTime = '0';
this.responseTime90 = '0';
this.avgBandwidth = '0';
this.loadOption = {};
this.resOption = {};
}
},
deep: true
}
},
props: ['report']
}
deep: true
}
},
props: ['report']
}
</script>
<style scoped>
.ms-card-data {
text-align: left;
display: block;
margin-bottom: 5px;
}
.ms-card-data {
text-align: left;
display: block;
margin-bottom: 5px;
}
.ms-card-desc {
display: block;
text-align: left;
}
.ms-card-desc {
display: block;
text-align: left;
}
.ms-card-data-digital {
font-size: 21px;
}
.ms-card-data-digital {
font-size: 21px;
}
.ms-card-data-unit {
color: #8492a6;
font-size: 15px;
}
.ms-card-data-unit {
color: #8492a6;
font-size: 15px;
}
.ms-card-index-1 .ms-card-data-digital {
color: #44b349;
}
.ms-card-index-1 .ms-card-data-digital {
color: #44b349;
}
.ms-card-index-1 {
border-left-color: #44b349;
border-left-width: 3px;
}
.ms-card-index-1 {
border-left-color: #44b349;
border-left-width: 3px;
}
.ms-card-index-2 .ms-card-data-digital {
color: #65A2FF;
}
.ms-card-index-2 .ms-card-data-digital {
color: #65A2FF;
}
.ms-card-index-2 {
border-left-color: #65A2FF;
border-left-width: 3px;
}
.ms-card-index-2 {
border-left-color: #65A2FF;
border-left-width: 3px;
}
.ms-card-index-3 .ms-card-data-digital {
color: #E6113C;
}
.ms-card-index-3 .ms-card-data-digital {
color: #E6113C;
}
.ms-card-index-3 {
border-left-color: #E6113C;
border-left-width: 3px;
}
.ms-card-index-3 {
border-left-color: #E6113C;
border-left-width: 3px;
}
.ms-card-index-4 .ms-card-data-digital {
color: #99743C;
}
.ms-card-index-4 .ms-card-data-digital {
color: #99743C;
}
.ms-card-index-4 {
border-left-color: #99743C;
border-left-width: 3px;
}
.ms-card-index-4 {
border-left-color: #99743C;
border-left-width: 3px;
}
.ms-card-index-5 .ms-card-data-digital {
color: #99743C;
}
.ms-card-index-5 .ms-card-data-digital {
color: #99743C;
}
.ms-card-index-5 {
border-left-color: #99743C;
border-left-width: 3px;
}
.ms-card-index-5 {
border-left-color: #99743C;
border-left-width: 3px;
}
.ms-card-index-6 .ms-card-data-digital {
color: #3C9899;
}
.ms-card-index-6 .ms-card-data-digital {
color: #3C9899;
}
.ms-card-index-6 {
border-left-color: #3C9899;
border-left-width: 3px;
}
.ms-card-index-6 {
border-left-color: #3C9899;
border-left-width: 3px;
}
.chart-config {
width: 100%;
}
.chart-config {
width: 100%;
}
</style>

View File

@ -3,9 +3,10 @@
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<ms-table-header :condition.sync="condition" @search="search" @create="create"
:create-tip="$t('test_resource_pool.create_resource_pool')" :title="$t('commons.test_resource_pool')"/>
:create-tip="$t('test_resource_pool.create_resource_pool')"
:title="$t('commons.test_resource_pool')"/>
</template>
<el-table border class="adjust-table" :data="items" style="width: 100%">
<el-table border class="adjust-table" :data="items" style="width: 100%">
<el-table-column prop="name" :label="$t('commons.name')"/>
<el-table-column prop="description" :label="$t('commons.description')"/>
<el-table-column prop="type" :label="$t('test_resource_pool.type')">
@ -174,225 +175,228 @@
</template>
<script>
import MsCreateBox from "../CreateBox";
import MsTablePagination from "../../common/pagination/TablePagination";
import MsTableHeader from "../../common/components/MsTableHeader";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
import MsCreateBox from "../CreateBox";
import MsTablePagination from "../../common/pagination/TablePagination";
import MsTableHeader from "../../common/components/MsTableHeader";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "../../../../common/js/utils";
export default {
name: "MsTestResourcePool",
components: {MsCreateBox, MsTablePagination, MsTableHeader, MsTableOperator, MsDialogFooter},
data() {
return {
result: {},
createVisible: false,
infoList: [],
updateVisible: false,
queryPath: "testresourcepool/list",
condition: {},
items: [],
currentPage: 1,
pageSize: 5,
total: 0,
form: {},
rule: {
name: [
{required: true, message: this.$t('test_resource_pool.input_pool_name'), trigger: 'blur'},
{min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'},
{
required: true,
pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.·-]+$/,
message: this.$t('test_resource_pool.pool_name_valid'),
trigger: 'blur'
}
],
description: [
{max: 60, message: this.$t('commons.input_limit', [0, 60]), trigger: 'blur'}
],
type: [
{required: true, message: this.$t('test_resource_pool.select_pool_type'), trigger: 'blur'}
]
}
export default {
name: "MsTestResourcePool",
components: {MsCreateBox, MsTablePagination, MsTableHeader, MsTableOperator, MsDialogFooter},
data() {
return {
result: {},
createVisible: false,
infoList: [],
updateVisible: false,
queryPath: "testresourcepool/list",
condition: {},
items: [],
currentPage: 1,
pageSize: 5,
total: 0,
form: {},
rule: {
name: [
{required: true, message: this.$t('test_resource_pool.input_pool_name'), trigger: 'blur'},
{min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'},
{
required: true,
pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.·-]+$/,
message: this.$t('test_resource_pool.pool_name_valid'),
trigger: 'blur'
}
],
description: [
{max: 60, message: this.$t('commons.input_limit', [0, 60]), trigger: 'blur'}
],
type: [
{required: true, message: this.$t('test_resource_pool.select_pool_type'), trigger: 'blur'}
]
}
}
},
activated() {
this.initTableData();
},
methods: {
initTableData() {
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
let data = response.data;
this.items = data.listObject;
this.total = data.itemCount;
})
},
changeResourceType() {
this.infoList = [];
this.infoList.push({})
},
addResourceInfo() {
this.infoList.push({})
},
removeResourceInfo(index) {
if (this.infoList.length > 1) {
this.infoList.splice(index, 1)
} else {
this.$warning(this.$t('test_resource_pool.cannot_remove_all_node'))
}
},
activated() {
this.initTableData();
},
methods: {
initTableData() {
validateResourceInfo() {
if (this.infoList.length <= 0) {
return {validate: false, msg: this.$t('test_resource_pool.cannot_empty')}
}
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
let data = response.data;
this.items = data.listObject;
this.total = data.itemCount;
})
},
changeResourceType() {
this.infoList = [];
this.infoList.push({})
},
addResourceInfo() {
this.infoList.push({})
},
removeResourceInfo(index) {
if (this.infoList.length > 1) {
this.infoList.splice(index, 1)
} else {
this.$warning(this.$t('test_resource_pool.cannot_remove_all_node'))
}
},
validateResourceInfo() {
if (this.infoList.length <= 0) {
return {validate: false, msg: this.$t('test_resource_pool.cannot_empty')}
}
let resultValidate = {validate: true, msg: this.$t('test_resource_pool.fill_the_data')};
this.infoList.forEach(function (info) {
for (let key in info) {
if (info[key] != '0' && !info[key]) {
resultValidate.validate = false
return false;
}
}
if (!info.maxConcurrency) {
let resultValidate = {validate: true, msg: this.$t('test_resource_pool.fill_the_data')};
this.infoList.forEach(function (info) {
for (let key in info) {
if (info[key] != '0' && !info[key]) {
resultValidate.validate = false
return false;
}
});
return resultValidate;
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
search() {
this.initTableData();
},
create() {
this.createVisible = true;
listenGoBack(this.closeFunc);
},
edit(row) {
this.updateVisible = true;
this.form = JSON.parse(JSON.stringify(row));
this.convertResources();
listenGoBack(this.closeFunc);
},
convertResources() {
let resources = [];
if (this.form.resources) {
this.form.resources.forEach(function (resource) {
resources.push(JSON.parse(resource.configuration));
})
}
this.infoList = resources;
},
del(row) {
window.console.log(row);
this.$confirm(this.$t('test_resource_pool.delete_prompt'), this.$t('commons.prompt'), {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.result = this.$get(`/testresourcepool/delete/${row.id}`,() => {
this.initTableData();
this.$success(this.$t('commons.delete_success'));
});
}).catch(() => {
this.$info(this.$t('commons.delete_cancel'));
});
},
createTestResourcePool(createTestResourcePoolForm) {
this.$refs[createTestResourcePoolForm].validate(valid => {
if (valid) {
let vri = this.validateResourceInfo();
if (vri.validate) {
this.convertSubmitResources();
this.result = this.$post("/testresourcepool/add", this.form, () => {
this.$message({
type: 'success',
message: this.$t('commons.save_success')
},
this.createVisible = false,
this.initTableData());
});
} else {
this.$warning(vri.msg);
return false;
}
} else {
return false;
}
if (!info.maxConcurrency) {
resultValidate.validate = false
return false;
}
});
return resultValidate;
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
search() {
this.initTableData();
},
create() {
this.createVisible = true;
listenGoBack(this.closeFunc);
},
edit(row) {
this.updateVisible = true;
this.form = JSON.parse(JSON.stringify(row));
this.convertResources();
listenGoBack(this.closeFunc);
},
convertResources() {
let resources = [];
if (this.form.resources) {
this.form.resources.forEach(function (resource) {
let configuration = JSON.parse(resource.configuration);
configuration.id = resource.id
resources.push(configuration);
})
},
convertSubmitResources() {
let resources = [];
let poolId = this.form.id;
this.infoList.forEach(function (info) {
let resource = {"configuration": JSON.stringify(info)};
if (poolId) {
resource.testResourcePoolId = poolId;
}
resources.push(resource);
}
this.infoList = resources;
},
del(row) {
window.console.log(row);
this.$confirm(this.$t('test_resource_pool.delete_prompt'), this.$t('commons.prompt'), {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.result = this.$get(`/testresourcepool/delete/${row.id}`, () => {
this.initTableData();
this.$success(this.$t('commons.delete_success'));
});
this.form.resources = resources;
},
updateTestResourcePool(updateTestResourcePoolForm) {
this.$refs[updateTestResourcePoolForm].validate(valid => {
if (valid) {
let vri = this.validateResourceInfo();
if (vri.validate) {
this.convertSubmitResources();
this.result = this.$post("/testresourcepool/update", this.form, () => {
this.$message({
type: 'success',
message: this.$t('commons.modify_success')
},
this.updateVisible = false,
this.initTableData(),
self.loading = false);
});
} else {
this.$warning(vri.msg);
return false;
}
}).catch(() => {
this.$info(this.$t('commons.delete_cancel'));
});
},
createTestResourcePool(createTestResourcePoolForm) {
this.$refs[createTestResourcePoolForm].validate(valid => {
if (valid) {
let vri = this.validateResourceInfo();
if (vri.validate) {
this.convertSubmitResources();
this.result = this.$post("/testresourcepool/add", this.form, () => {
this.$message({
type: 'success',
message: this.$t('commons.save_success')
},
this.createVisible = false,
this.initTableData());
});
} else {
this.$warning(vri.msg);
return false;
}
});
},
closeFunc() {
this.form = {};
this.updateVisible = false;
this.createVisible = false;
removeGoBackListener(this.closeFunc);
},
changeSwitch(row) {
this.result.loading = true;
this.$info(this.$t('test_resource_pool.check_in'), 1000);
this.$get('/testresourcepool/update/' + row.id + '/' + row.status)
.then(() => {
this.$success(this.$t('test_resource_pool.status_change_success'));
this.result.loading = false;
}).catch(() => {
this.$error(this.$t('test_resource_pool.status_change_failed'));
row.status = 'INVALID';
this.result.loading = false;
})
}
} else {
return false;
}
})
},
convertSubmitResources() {
let resources = [];
let poolId = this.form.id;
this.infoList.forEach(function (info) {
let configuration = JSON.stringify(info);
let resource = {"configuration": configuration, id: info.id};
if (poolId) {
resource.testResourcePoolId = poolId;
}
resources.push(resource);
});
this.form.resources = resources;
},
updateTestResourcePool(updateTestResourcePoolForm) {
this.$refs[updateTestResourcePoolForm].validate(valid => {
if (valid) {
let vri = this.validateResourceInfo();
if (vri.validate) {
this.convertSubmitResources();
this.result = this.$post("/testresourcepool/update", this.form, () => {
this.$message({
type: 'success',
message: this.$t('commons.modify_success')
},
this.updateVisible = false,
this.initTableData(),
self.loading = false);
});
} else {
this.$warning(vri.msg);
return false;
}
} else {
return false;
}
});
},
closeFunc() {
this.form = {};
this.updateVisible = false;
this.createVisible = false;
removeGoBackListener(this.closeFunc);
},
changeSwitch(row) {
this.result.loading = true;
this.$info(this.$t('test_resource_pool.check_in'), 1000);
this.$get('/testresourcepool/update/' + row.id + '/' + row.status)
.then(() => {
this.$success(this.$t('test_resource_pool.status_change_success'));
this.result.loading = false;
}).catch(() => {
this.$error(this.$t('test_resource_pool.status_change_failed'));
row.status = 'INVALID';
this.result.loading = false;
})
}
}
}
</script>
<style scoped>
.box {
padding-left: 5px;
}
.box {
padding-left: 5px;
}
</style>

View File

@ -25,7 +25,7 @@
</el-button>
</el-col>
<el-col :span="12" class="head-right">
<el-col :span="11" class="head-right">
<span class="head-right-tip" v-if="index + 1 === testCases.length">
{{ $t('test_track.plan_view.pre_case') }} : {{
testCases[index - 1] ? testCases[index - 1].name : ''
@ -44,11 +44,6 @@
<el-button plain size="mini" icon="el-icon-arrow-down"
:disabled="index + 1 >= testCases.length"
@click="handleNext()"/>
<el-divider direction="vertical"></el-divider>
<el-button type="primary" size="mini" :disabled="isReadOnly" @click="saveCase()">
{{ $t('test_track.save') }}
</el-button>
</el-col>
</el-row>
@ -577,6 +572,8 @@ export default {
this.isFailure = this.testCase.steptResults.filter(s => {
return s.executeResult === 'Failure' || s.executeResult === 'Blocking';
}).length > 0;
} else {
this.isFailure = false;
}
},
saveIssues() {

View File

@ -30,7 +30,7 @@
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="creator"
prop="creatorName"
:label="$t('test_track.review.review_creator')"
show-overflow-tooltip>
</el-table-column>
@ -66,10 +66,6 @@
<template v-slot:default="scope">
<ms-table-operator :is-tester-permission="true" @editClick="handleEdit(scope.row)"
@deleteClick="handleDelete(scope.row)">
<!-- <template v-slot:middle>-->
<!-- <ms-table-operator-button :isTesterPermission="true" type="success" tip="重新发起" icon="el-icon-document"-->
<!-- @exec="reCreate(scope.row)"/>-->
<!-- </template>-->
</ms-table-operator>
</template>
</el-table-column>