refactor(性能测试): 性能测试压力预览图修改

This commit is contained in:
Captain.B 2021-03-11 17:18:07 +08:00
parent b9be1ddd0e
commit d92f04c1bd
4 changed files with 148 additions and 61 deletions

View File

@ -348,7 +348,27 @@ export default {
let threadInc2 = Math.ceil(tg.threadNumber / tg.step);
let inc2count = tg.threadNumber - tg.step * threadInc1;
for (let j = 0; j <= tg.duration; j++) {
// x
let xAxis = handler.options.xAxis.data;
if (xAxis.indexOf(j) < 0) {
xAxis.push(j);
}
if (tg.tgType === 'ThreadGroup') {
seriesData.step = undefined;
if (j === 0) {
seriesData.data.push([0, 0]);
}
if (j > tg.rampUpTime) {
xAxis.push(tg.duration);
seriesData.data.push([j, tg.threadNumber]);
seriesData.data.push([tg.duration, tg.threadNumber]);
break;
}
} else {
seriesData.step = 'start';
if (j > timePeriod) {
timePeriod += timeInc;
if (inc2count > 0) {
@ -359,14 +379,14 @@ export default {
}
if (threadPeriod > tg.threadNumber) {
threadPeriod = tg.threadNumber;
//
xAxis.push(tg.duration);
seriesData.data.push([tg.duration, threadPeriod]);
break;
}
}
// x
let xAxis = handler.options.xAxis.data;
if (xAxis.indexOf(j) < 0) {
xAxis.push(j);
seriesData.data.push([j, threadPeriod]);
}
seriesData.data.push(threadPeriod);
}
handler.options.series.push(seriesData);
}
@ -445,6 +465,21 @@ export default {
for (let i = 0; i <= handler.duration; i++) {
// x
handler.options.xAxis.data.push(i);
if (handler.tgType === 'ThreadGroup') {
handler.options.series[0].step = undefined;
if (i === 0) {
handler.options.series[0].data.push([0, 0]);
}
if (i > handler.rampUpTime) {
handler.options.xAxis.data.push(handler.duration);
handler.options.series[0].data.push([i, handler.threadNumber]);
handler.options.series[0].data.push([handler.duration, handler.threadNumber]);
break;
}
} else {
handler.options.series[0].step = 'start';
if (i > timePeriod) {
timePeriod += timeInc;
if (inc2count > 0) {
@ -455,10 +490,14 @@ export default {
}
if (threadPeriod > handler.threadNumber) {
threadPeriod = handler.threadNumber;
handler.options.xAxis.data.push(handler.duration);
handler.options.series[0].data.push([handler.duration, handler.threadNumber]);
break;
}
handler.options.series[0].data.push(threadPeriod);
handler.options.series[0].data.push([i, threadPeriod]);
} else {
handler.options.series[0].data.push(threadPeriod);
handler.options.series[0].data.push([i, threadPeriod]);
}
}
}
this.calculateTotalChart();

View File

@ -28,6 +28,7 @@
<el-tabs class="testplan-config" v-model="active" type="border-card" :stretch="true">
<el-tab-pane :label="$t('load_test.basic_config')">
<performance-basic-config :is-read-only="isReadOnly" :test="test" ref="basicConfig"
@tgTypeChange="tgTypeChange"
@fileChange="fileChange"/>
</el-tab-pane>
<el-tab-pane :label="$t('load_test.pressure_config')">
@ -347,6 +348,10 @@ export default {
threadGroups.forEach(tg => {
handler.calculateChart(tg);
})
},
tgTypeChange(threadGroup) {
let handler = this.$refs.pressureConfig;
handler.calculateChart(threadGroup);
}
}
}

View File

@ -46,7 +46,7 @@
<el-table-column
label="ThreadGroup">
<template v-slot:default="{row}">
<el-select v-model="row.tgType" :placeholder="$t('commons.please_select')" size="small">
<el-select v-model="row.tgType" :placeholder="$t('commons.please_select')" size="small" @change="tgTypeChange(row)">
<el-option v-for="tg in threadGroupForSelect" :key="tg.tagName" :label="tg.name"
:value="tg.testclass"></el-option>
</el-select>
@ -377,6 +377,9 @@ export default {
threadGroupDisable(row) {
return this.threadGroups.filter(tg => tg.enabled == 'true').length === 1 && row.enabled == 'true';
},
tgTypeChange(row) {
this.$emit("tgTypeChange", row);
},
handleExceed() {
this.$error(this.$t('load_test.file_size_limit'));
},

View File

@ -42,10 +42,12 @@
<br>
<div v-if="threadGroup.threadType === 'DURATION'">
<el-form-item :label="$t('load_test.duration')">
<!-- 最多两天的测试时长 -->
<el-input-number
:disabled="isReadOnly"
v-model="threadGroup.duration"
:min="1"
:max="172800"
@change="calculateChart(threadGroup)"
size="mini"/>
</el-form-item>
@ -349,7 +351,6 @@ export default {
name: handler.threadGroups[i].attributes.testname,
data: [],
type: 'line',
step: 'start',
smooth: false,
symbolSize: 5,
showSymbol: false,
@ -390,7 +391,26 @@ export default {
let threadInc2 = Math.ceil(tg.threadNumber / tg.step);
let inc2count = tg.threadNumber - tg.step * threadInc1;
for (let j = 0; j <= tg.duration; j++) {
// x
let xAxis = handler.options.xAxis.data;
if (xAxis.indexOf(j) < 0) {
xAxis.push(j);
}
if (tg.tgType === 'ThreadGroup') {
seriesData.step = undefined;
if (j === 0) {
seriesData.data.push([0, 0]);
}
if (j > tg.rampUpTime) {
xAxis.push(tg.duration);
seriesData.data.push([j, tg.threadNumber]);
seriesData.data.push([tg.duration, tg.threadNumber]);
break;
}
} else {
seriesData.step = 'start';
if (j > timePeriod) {
timePeriod += timeInc;
if (inc2count > 0) {
@ -401,14 +421,14 @@ export default {
}
if (threadPeriod > tg.threadNumber) {
threadPeriod = tg.threadNumber;
//
xAxis.push(tg.duration);
seriesData.data.push([tg.duration, threadPeriod]);
break;
}
}
// x
let xAxis = handler.options.xAxis.data;
if (xAxis.indexOf(j) < 0) {
xAxis.push(j);
seriesData.data.push([j, threadPeriod]);
}
seriesData.data.push(threadPeriod);
}
handler.options.series.push(seriesData);
}
@ -492,6 +512,22 @@ export default {
for (let i = 0; i <= handler.duration; i++) {
// x
handler.options.xAxis.data.push(i);
if (handler.tgType === 'ThreadGroup') {
handler.options.series[0].step = undefined;
if (i === 0) {
handler.options.series[0].data.push([0, 0]);
}
if (i > handler.rampUpTime) {
handler.options.xAxis.data.push(handler.duration);
handler.options.series[0].data.push([i, handler.threadNumber]);
handler.options.series[0].data.push([handler.duration, handler.threadNumber]);
break;
}
} else {
handler.options.series[0].step = 'start';
if (i > timePeriod) {
timePeriod += timeInc;
if (inc2count > 0) {
@ -502,10 +538,14 @@ export default {
}
if (threadPeriod > handler.threadNumber) {
threadPeriod = handler.threadNumber;
handler.options.xAxis.data.push(handler.duration);
handler.options.series[0].data.push([handler.duration, handler.threadNumber]);
break;
}
handler.options.series[0].data.push(threadPeriod);
handler.options.series[0].data.push([i, threadPeriod]);
} else {
handler.options.series[0].data.push(threadPeriod);
handler.options.series[0].data.push([i, threadPeriod]);
}
}
}
this.calculateTotalChart();