refactor: --story=1003124 --user=刘瑞斌 性能测试压力配置持续时间时分秒可以同时配置 https://www.tapd.cn/55049933/s/1054450

This commit is contained in:
Captain.B 2021-10-11 13:32:25 +08:00 committed by 刘瑞斌
parent 8595e2f6f3
commit 2035a17857
2 changed files with 173 additions and 171 deletions

View File

@ -19,7 +19,16 @@
<el-col :span="10"> <el-col :span="10">
<el-tag type="primary" size="mini" v-if="threadGroup.threadType === 'DURATION'"> <el-tag type="primary" size="mini" v-if="threadGroup.threadType === 'DURATION'">
{{ $t('load_test.thread_num') }}{{ threadGroup.threadNumber }}, {{ $t('load_test.thread_num') }}{{ threadGroup.threadNumber }},
{{ $t('load_test.duration') }}: {{ threadGroup.duration }} {{ getUnitLabel(threadGroup) }} {{ $t('load_test.duration') }}:
<span v-if="threadGroup.durationHours">
{{ threadGroup.durationHours }}{{ $t('schedule.cron.hours') }}
</span>
<span v-if="threadGroup.durationMinutes">
{{ threadGroup.durationMinutes }}{{ $t('schedule.cron.minutes') }}
</span>
<span v-if="threadGroup.durationSeconds">
{{ threadGroup.durationSeconds }}{{ $t('schedule.cron.seconds') }}
</span>
</el-tag> </el-tag>
<el-tag type="primary" size="mini" v-if="threadGroup.threadType === 'ITERATION'"> <el-tag type="primary" size="mini" v-if="threadGroup.threadType === 'ITERATION'">
{{ $t('load_test.thread_num') }} {{ threadGroup.threadNumber }}, {{ $t('load_test.thread_num') }} {{ threadGroup.threadNumber }},
@ -46,20 +55,32 @@
</el-form-item> </el-form-item>
<br> <br>
<div v-if="threadGroup.threadType === 'DURATION'"> <div v-if="threadGroup.threadType === 'DURATION'">
<el-form-item :label="$t('load_test.duration')"> <el-form-item :label="$t('schedule.cron.hours')">
<el-input-number <el-input-number controls-position="right"
:disabled="true" :disabled="true"
v-model="threadGroup.duration" v-model="threadGroup.durationHours"
:min="1" :min="0"
@change="calculateTotalChart()" :max="9999"
size="mini"/> @change="calculateTotalChart()"
size="mini"/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item :label="$t('schedule.cron.minutes')">
<el-radio-group v-model="threadGroup.unit" :disabled="true"> <el-input-number controls-position="right"
<el-radio label="S">{{ $t('schedule.cron.seconds') }}</el-radio> :disabled="true"
<el-radio label="M">{{ $t('schedule.cron.minutes') }}</el-radio> v-model="threadGroup.durationMinutes"
<el-radio label="H">{{ $t('schedule.cron.hours') }}</el-radio> :min="0"
</el-radio-group> :max="59"
@change="calculateTotalChart()"
size="mini"/>
</el-form-item>
<el-form-item :label="$t('schedule.cron.seconds')">
<el-input-number controls-position="right"
:disabled="true"
v-model="threadGroup.durationSeconds"
:min="0"
:max="59"
@change="calculateTotalChart()"
size="mini"/>
</el-form-item> </el-form-item>
<br> <br>
<el-form-item :label="$t('load_test.rps_limit')"> <el-form-item :label="$t('load_test.rps_limit')">
@ -168,6 +189,9 @@ const TARGET_LEVEL = "TargetLevel";
const RAMP_UP = "RampUp"; const RAMP_UP = "RampUp";
const STEPS = "Steps"; const STEPS = "Steps";
const DURATION = "duration"; const DURATION = "duration";
const DURATION_HOURS = "durationHours";
const DURATION_MINUTES = "durationMinutes";
const DURATION_SECONDS = "durationSeconds";
const UNIT = "unit"; const UNIT = "unit";
const RPS_LIMIT = "rpsLimit"; const RPS_LIMIT = "rpsLimit";
const RPS_LIMIT_ENABLE = "rpsLimitEnable"; const RPS_LIMIT_ENABLE = "rpsLimitEnable";
@ -230,6 +254,15 @@ export default {
case DURATION: case DURATION:
this.threadGroups[i].duration = item.value; this.threadGroups[i].duration = item.value;
break; break;
case DURATION_HOURS:
this.threadGroups[i].durationHours = item.value;
break;
case DURATION_MINUTES:
this.threadGroups[i].durationMinutes = item.value;
break;
case DURATION_SECONDS:
this.threadGroups[i].durationSeconds = item.value;
break;
case UNIT: case UNIT:
this.threadGroups[i].unit = item.value; this.threadGroups[i].unit = item.value;
break; break;
@ -265,17 +298,10 @@ export default {
} }
}); });
for (let i = 0; i < this.threadGroups.length; i++) { for (let i = 0; i < this.threadGroups.length; i++) {
// let tg = this.threadGroups[i];
switch (this.threadGroups[i].unit) { tg.durationHours = Math.floor(tg.duration / 3600);
case 'M': tg.durationMinutes = Math.floor((tg.duration / 60 % 60));
this.threadGroups[i].duration = this.threadGroups[i].duration / 60; tg.durationSeconds = Math.floor((tg.duration % 60));
break;
case 'H':
this.threadGroups[i].duration = this.threadGroups[i].duration / 60 / 60;
break;
default:
break;
}
} }
this.calculateTotalChart(); this.calculateTotalChart();
} }

View File

@ -22,12 +22,12 @@
<el-switch v-model="autoStop"/> <el-switch v-model="autoStop"/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('load_test.reaches_duration')"> <el-form-item :label="$t('load_test.reaches_duration')">
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly || !autoStop" :disabled="isReadOnly || !autoStop"
v-model="autoStopDelay" v-model="autoStopDelay"
:min="1" :min="1"
:max="9999" :max="9999"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('load_test.autostop_delay')"/> <el-form-item :label="$t('load_test.autostop_delay')"/>
</el-form> </el-form>
@ -51,7 +51,16 @@
<el-col :span="10"> <el-col :span="10">
<el-tag type="primary" size="mini" v-if="threadGroup.threadType === 'DURATION'"> <el-tag type="primary" size="mini" v-if="threadGroup.threadType === 'DURATION'">
{{ $t('load_test.thread_num') }}{{ threadGroup.threadNumber }}, {{ $t('load_test.thread_num') }}{{ threadGroup.threadNumber }},
{{ $t('load_test.duration') }}: {{ threadGroup.duration }} {{ getUnitLabel(threadGroup) }} {{ $t('load_test.duration') }}:
<span v-if="threadGroup.durationHours">
{{ threadGroup.durationHours }}{{ $t('schedule.cron.hours') }}
</span>
<span v-if="threadGroup.durationMinutes">
{{ threadGroup.durationMinutes }}{{ $t('schedule.cron.minutes') }}
</span>
<span v-if="threadGroup.durationSeconds">
{{ threadGroup.durationSeconds }}{{ $t('schedule.cron.seconds') }}
</span>
</el-tag> </el-tag>
<el-tag type="primary" size="mini" v-if="threadGroup.threadType === 'ITERATION'"> <el-tag type="primary" size="mini" v-if="threadGroup.threadType === 'ITERATION'">
{{ $t('load_test.thread_num') }} {{ threadGroup.threadNumber }}, {{ $t('load_test.thread_num') }} {{ threadGroup.threadNumber }},
@ -62,13 +71,13 @@
</template> </template>
<el-form :inline="true"> <el-form :inline="true">
<el-form-item :label="$t('load_test.thread_num')"> <el-form-item :label="$t('load_test.thread_num')">
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly" :disabled="isReadOnly"
v-model="threadGroup.threadNumber" v-model="threadGroup.threadNumber"
@change="calculateTotalChart()" @change="calculateTotalChart()"
:min="1" :min="1"
:max="maxThreadNumbers" :max="maxThreadNumbers"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('load_test.on_sample_error')"> <el-form-item :label="$t('load_test.on_sample_error')">
<el-select v-model="threadGroup.onSampleError" :disabled="isReadOnly" size="mini"> <el-select v-model="threadGroup.onSampleError" :disabled="isReadOnly" size="mini">
@ -89,103 +98,114 @@
</el-form-item> </el-form-item>
<br> <br>
<div v-if="threadGroup.threadType === 'DURATION'"> <div v-if="threadGroup.threadType === 'DURATION'">
<el-form-item :label="$t('load_test.duration')"> <el-form-item :label="$t('schedule.cron.hours')">
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly" :disabled="isReadOnly"
v-model="threadGroup.duration" v-model="threadGroup.durationHours"
:min="1" :min="0"
:max="9999" :max="9999"
@change="calculateTotalChart()" @change="calculateTotalChart()"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item :label="$t('schedule.cron.minutes')">
<el-radio-group v-model="threadGroup.unit" @change="changeUnit(threadGroup)"> <el-input-number controls-position="right"
<el-radio label="S">{{ $t('schedule.cron.seconds') }}</el-radio> :disabled="isReadOnly"
<el-radio label="M">{{ $t('schedule.cron.minutes') }}</el-radio> v-model="threadGroup.durationMinutes"
<el-radio label="H">{{ $t('schedule.cron.hours') }}</el-radio> :min="0"
</el-radio-group> :max="59"
@change="calculateTotalChart()"
size="mini"/>
</el-form-item>
<el-form-item :label="$t('schedule.cron.seconds')">
<el-input-number controls-position="right"
:disabled="isReadOnly"
v-model="threadGroup.durationSeconds"
:min="0"
:max="59"
@change="calculateTotalChart()"
size="mini"/>
</el-form-item> </el-form-item>
<br> <br>
<el-form-item :label="$t('load_test.rps_limit')"> <el-form-item :label="$t('load_test.rps_limit')">
<el-switch v-model="threadGroup.rpsLimitEnable" @change="calculateTotalChart()"/> <el-switch v-model="threadGroup.rpsLimitEnable" @change="calculateTotalChart()"/>
&nbsp; &nbsp;
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly || !threadGroup.rpsLimitEnable" :disabled="isReadOnly || !threadGroup.rpsLimitEnable"
v-model="threadGroup.rpsLimit" v-model="threadGroup.rpsLimit"
@change="calculateTotalChart()" @change="calculateTotalChart()"
:min="1" :min="1"
:max="99999" :max="99999"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<br> <br>
<div v-if="threadGroup.tgType === 'com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup'"> <div v-if="threadGroup.tgType === 'com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup'">
<el-form-item :label="$t('load_test.ramp_up_time_within')"> <el-form-item :label="$t('load_test.ramp_up_time_within')">
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly" :disabled="isReadOnly"
:min="1" :min="1"
v-if="rampUpTimeVisible" v-if="rampUpTimeVisible"
:max="getDuration(threadGroup)" :max="getDuration(threadGroup)"
v-model="threadGroup.rampUpTime" v-model="threadGroup.rampUpTime"
@change="calculateTotalChart()" @change="calculateTotalChart()"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('load_test.ramp_up_time_minutes', [getUnitLabel(threadGroup)])"> <el-form-item :label="$t('load_test.ramp_up_time_minutes')">
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly" :disabled="isReadOnly"
:min="1" :min="1"
:max="Math.min(threadGroup.threadNumber, threadGroup.rampUpTime)" :max="Math.min(threadGroup.threadNumber, threadGroup.rampUpTime)"
v-model="threadGroup.step" v-model="threadGroup.step"
@change="calculateTotalChart()" @change="calculateTotalChart()"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('load_test.ramp_up_time_times')"/> <el-form-item :label="$t('load_test.ramp_up_time_times')"/>
</div> </div>
<div v-if="threadGroup.tgType === 'ThreadGroup'"> <div v-if="threadGroup.tgType === 'ThreadGroup'">
<el-form-item :label="$t('load_test.ramp_up_time_within')"> <el-form-item :label="$t('load_test.ramp_up_time_within')">
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly" :disabled="isReadOnly"
v-if="rampUpTimeVisible" v-if="rampUpTimeVisible"
:min="1" :min="1"
:max="getDuration(threadGroup)" :max="getDuration(threadGroup)"
v-model="threadGroup.rampUpTime" v-model="threadGroup.rampUpTime"
@change="calculateTotalChart()" @change="calculateTotalChart()"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('load_test.ramp_up_time_seconds', [getUnitLabel(threadGroup)])"/> <el-form-item :label="$t('load_test.ramp_up_time_seconds')"/>
</div> </div>
</div> </div>
<div v-if="threadGroup.threadType === 'ITERATION'"> <div v-if="threadGroup.threadType === 'ITERATION'">
<el-form-item :label="$t('load_test.iterate_num')"> <el-form-item :label="$t('load_test.iterate_num')">
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly" :disabled="isReadOnly"
v-model="threadGroup.iterateNum" v-model="threadGroup.iterateNum"
:min="1" :min="1"
:max="9999999" :max="9999999"
@change="calculateTotalChart()" @change="calculateTotalChart()"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<br> <br>
<el-form-item :label="$t('load_test.rps_limit')"> <el-form-item :label="$t('load_test.rps_limit')">
<el-switch v-model="threadGroup.rpsLimitEnable" @change="calculateTotalChart()"/> <el-switch v-model="threadGroup.rpsLimitEnable" @change="calculateTotalChart()"/>
&nbsp; &nbsp;
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly || !threadGroup.rpsLimitEnable" :disabled="isReadOnly || !threadGroup.rpsLimitEnable"
v-model="threadGroup.rpsLimit" v-model="threadGroup.rpsLimit"
:min="1" :min="1"
:max="99999" :max="99999"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<br> <br>
<el-form-item :label="$t('load_test.ramp_up_time_within')"> <el-form-item :label="$t('load_test.ramp_up_time_within')">
<el-input-number <el-input-number controls-position="right"
:disabled="isReadOnly" :disabled="isReadOnly"
:min="1" :min="1"
v-model="threadGroup.iterateRampUp" v-model="threadGroup.iterateRampUp"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('load_test.ramp_up_time_seconds', [getUnitLabel(threadGroup)])"/> <el-form-item :label="$t('load_test.ramp_up_time_seconds')"/>
</div> </div>
</el-form> </el-form>
</el-collapse-item> </el-collapse-item>
@ -216,6 +236,9 @@ const RAMP_UP = "RampUp";
const ITERATE_RAMP_UP = "iterateRampUpTime"; const ITERATE_RAMP_UP = "iterateRampUpTime";
const STEPS = "Steps"; const STEPS = "Steps";
const DURATION = "duration"; const DURATION = "duration";
const DURATION_HOURS = "durationHours";
const DURATION_MINUTES = "durationMinutes";
const DURATION_SECONDS = "durationSeconds";
const UNIT = "unit"; const UNIT = "unit";
const RPS_LIMIT = "rpsLimit"; const RPS_LIMIT = "rpsLimit";
const RPS_LIMIT_ENABLE = "rpsLimitEnable"; const RPS_LIMIT_ENABLE = "rpsLimitEnable";
@ -319,7 +342,6 @@ export default {
this.$get('/performance/get-load-config/' + this.testId, (response) => { this.$get('/performance/get-load-config/' + this.testId, (response) => {
if (response.data) { if (response.data) {
let data = JSON.parse(response.data); let data = JSON.parse(response.data);
let oldVersion;
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
let d = data[i]; let d = data[i];
d.forEach(item => { d.forEach(item => {
@ -335,7 +357,15 @@ export default {
break; break;
case DURATION: case DURATION:
this.threadGroups[i].duration = item.value; this.threadGroups[i].duration = item.value;
oldVersion = item.unit; break;
case DURATION_HOURS:
this.threadGroups[i].durationHours = item.value;
break;
case DURATION_MINUTES:
this.threadGroups[i].durationMinutes = item.value;
break;
case DURATION_SECONDS:
this.threadGroups[i].durationSeconds = item.value;
break; break;
case UNIT: case UNIT:
this.threadGroups[i].unit = item.value; this.threadGroups[i].unit = item.value;
@ -393,21 +423,10 @@ export default {
}); });
} }
for (let i = 0; i < this.threadGroups.length; i++) { for (let i = 0; i < this.threadGroups.length; i++) {
// let tg = this.threadGroups[i];
if (oldVersion) { tg.durationHours = Math.floor(tg.duration / 3600);
break; tg.durationMinutes = Math.floor((tg.duration / 60 % 60));
} tg.durationSeconds = Math.floor((tg.duration % 60));
//
switch (this.threadGroups[i].unit) {
case 'M':
this.threadGroups[i].duration = this.threadGroups[i].duration / 60;
break;
case 'H':
this.threadGroups[i].duration = this.threadGroups[i].duration / 60 / 60;
break;
default:
break;
}
} }
this.calculateTotalChart(); this.calculateTotalChart();
} }
@ -524,18 +543,8 @@ export default {
let threadInc2 = Math.ceil(tg.threadNumber / tg.step); let threadInc2 = Math.ceil(tg.threadNumber / tg.step);
let inc2count = tg.threadNumber - tg.step * threadInc1; let inc2count = tg.threadNumber - tg.step * threadInc1;
let times = 1;
switch (tg.unit) { let duration = tg.duration;
case 'M':
times *= 60;
break;
case 'H':
times *= 3600;
break;
default:
break;
}
let duration = tg.duration * times;
for (let j = 0; j <= duration; j++) { for (let j = 0; j <= duration; j++) {
// x // x
let xAxis = handler.options.xAxis.data; let xAxis = handler.options.xAxis.data;
@ -614,48 +623,12 @@ export default {
return true; return true;
}, },
getHold(tg) { getHold(tg) {
if (tg.unit === 'S') { return tg.durationHours * 60 * 60 + tg.durationMinutes * 60 + tg.durationSeconds - tg.rampUpTime;
return tg.duration - tg.rampUpTime;
}
if (tg.unit === 'M') {
return tg.duration * 60 - tg.rampUpTime;
}
if (tg.unit === 'H') {
return tg.duration * 60 * 60 - tg.rampUpTime;
}
return tg.duration - tg.rampUpTime;
}, },
getDuration(tg) { getDuration(tg) {
if (tg.unit === 'S') { tg.duration = tg.durationHours * 60 * 60 + tg.durationMinutes * 60 + tg.durationSeconds;
return tg.duration;
}
if (tg.unit === 'M') {
return tg.duration * 60;
}
if (tg.unit === 'H') {
return tg.duration * 60 * 60;
}
return tg.duration; return tg.duration;
}, },
changeUnit(tg) {
this.rampUpTimeVisible = false;
this.$nextTick(() => {
this.rampUpTimeVisible = true;
this.calculateTotalChart();
});
},
getUnitLabel(tg) {
if (tg.unit === 'S') {
return this.$t('schedule.cron.seconds');
}
if (tg.unit === 'M') {
return this.$t('schedule.cron.minutes');
}
if (tg.unit === 'H') {
return this.$t('schedule.cron.hours');
}
return this.$t('schedule.cron.seconds');
},
convertProperty() { convertProperty() {
/// todo4jmeter ConcurrencyThreadGroup plugin /// todo4jmeter ConcurrencyThreadGroup plugin
let result = []; let result = [];
@ -668,6 +641,9 @@ export default {
{key: RAMP_UP, value: this.threadGroups[i].rampUpTime}, {key: RAMP_UP, value: this.threadGroups[i].rampUpTime},
{key: STEPS, value: this.threadGroups[i].step}, {key: STEPS, value: this.threadGroups[i].step},
{key: DURATION, value: this.getDuration(this.threadGroups[i])}, {key: DURATION, value: this.getDuration(this.threadGroups[i])},
{key: DURATION_HOURS, value: this.threadGroups[i].durationHours},
{key: DURATION_MINUTES, value: this.threadGroups[i].durationMinutes},
{key: DURATION_SECONDS, value: this.threadGroups[i].durationSeconds},
{key: UNIT, value: this.threadGroups[i].unit}, {key: UNIT, value: this.threadGroups[i].unit},
{key: RPS_LIMIT, value: this.threadGroups[i].rpsLimit}, {key: RPS_LIMIT, value: this.threadGroups[i].rpsLimit},
{key: RPS_LIMIT_ENABLE, value: this.threadGroups[i].rpsLimitEnable}, {key: RPS_LIMIT_ENABLE, value: this.threadGroups[i].rpsLimitEnable},