feat(性能测试): 配置压测时长支持单位
This commit is contained in:
parent
4243cfdf7b
commit
c426bb2064
|
@ -676,6 +676,13 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
((List<?>) durations).remove(0);
|
((List<?>) durations).remove(0);
|
||||||
duration = o.toString();
|
duration = o.toString();
|
||||||
}
|
}
|
||||||
|
Object units = context.getProperty("unit");
|
||||||
|
String unit = "S";
|
||||||
|
if (units instanceof List) {
|
||||||
|
Object o = ((List<?>) units).get(0);
|
||||||
|
((List<?>) units).remove(0);
|
||||||
|
unit = o.toString();
|
||||||
|
}
|
||||||
Object deleteds = context.getProperty("deleted");
|
Object deleteds = context.getProperty("deleted");
|
||||||
String deleted = "false";
|
String deleted = "false";
|
||||||
if (deleteds instanceof List) {
|
if (deleteds instanceof List) {
|
||||||
|
@ -691,6 +698,17 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
enabled = o.toString();
|
enabled = o.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (unit) {
|
||||||
|
case "M":
|
||||||
|
duration = String.valueOf(Long.parseLong(duration) * 60);
|
||||||
|
break;
|
||||||
|
case "H":
|
||||||
|
duration = String.valueOf(Long.parseLong(duration) * 60 * 60);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
threadGroup.setAttribute("enabled", enabled);
|
threadGroup.setAttribute("enabled", enabled);
|
||||||
if (BooleanUtils.toBoolean(deleted)) {
|
if (BooleanUtils.toBoolean(deleted)) {
|
||||||
threadGroup.setAttribute("enabled", "false");
|
threadGroup.setAttribute("enabled", "false");
|
||||||
|
@ -761,6 +779,13 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
((List<?>) holds).remove(0);
|
((List<?>) holds).remove(0);
|
||||||
hold = o.toString();
|
hold = o.toString();
|
||||||
}
|
}
|
||||||
|
Object units = context.getProperty("unit");
|
||||||
|
String unit = "S";
|
||||||
|
if (units instanceof List) {
|
||||||
|
Object o = ((List<?>) units).get(0);
|
||||||
|
((List<?>) units).remove(0);
|
||||||
|
unit = o.toString();
|
||||||
|
}
|
||||||
Object deleteds = context.getProperty("deleted");
|
Object deleteds = context.getProperty("deleted");
|
||||||
String deleted = "false";
|
String deleted = "false";
|
||||||
if (deleteds instanceof List) {
|
if (deleteds instanceof List) {
|
||||||
|
@ -776,6 +801,17 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
enabled = o.toString();
|
enabled = o.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (unit) {
|
||||||
|
case "M":
|
||||||
|
hold = String.valueOf(Long.parseLong(hold) * 60);
|
||||||
|
break;
|
||||||
|
case "H":
|
||||||
|
hold = String.valueOf(Long.parseLong(hold) * 60 * 60);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
threadGroup.setAttribute("enabled", enabled);
|
threadGroup.setAttribute("enabled", enabled);
|
||||||
if (BooleanUtils.toBoolean(deleted)) {
|
if (BooleanUtils.toBoolean(deleted)) {
|
||||||
threadGroup.setAttribute("enabled", "false");
|
threadGroup.setAttribute("enabled", "false");
|
||||||
|
@ -928,10 +964,10 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Element createStringProp(Document document, String name, String value) {
|
private Element createStringProp(Document document, String name, String value) {
|
||||||
Element unit = document.createElement(STRING_PROP);
|
Element element = document.createElement(STRING_PROP);
|
||||||
unit.setAttribute("name", name);
|
element.setAttribute("name", name);
|
||||||
unit.appendChild(document.createTextNode(value));
|
element.appendChild(document.createTextNode(value));
|
||||||
return unit;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processThreadGroupName(Element threadGroup) {
|
private void processThreadGroupName(Element threadGroup) {
|
||||||
|
|
|
@ -37,6 +37,13 @@
|
||||||
@change="calculateChart(threadGroup)"
|
@change="calculateChart(threadGroup)"
|
||||||
size="mini"/>
|
size="mini"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-radio-group v-model="threadGroup.unit" :disabled="true">
|
||||||
|
<el-radio label="S">{{ $t('schedule.cron.seconds') }}</el-radio>
|
||||||
|
<el-radio label="M">{{ $t('schedule.cron.minutes') }}</el-radio>
|
||||||
|
<el-radio label="H">{{ $t('schedule.cron.hours') }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</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()"/>
|
||||||
|
@ -59,7 +66,7 @@
|
||||||
@change="calculateChart(threadGroup)"
|
@change="calculateChart(threadGroup)"
|
||||||
size="mini"/>
|
size="mini"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('load_test.ramp_up_time_minutes')">
|
<el-form-item :label="$t('load_test.ramp_up_time_minutes', [getUnitLabel(threadGroup)])">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
:disabled="true"
|
:disabled="true"
|
||||||
:min="1"
|
:min="1"
|
||||||
|
@ -79,7 +86,7 @@
|
||||||
v-model="threadGroup.rampUpTime"
|
v-model="threadGroup.rampUpTime"
|
||||||
size="mini"/>
|
size="mini"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('load_test.ramp_up_time_seconds')"/>
|
<el-form-item :label="$t('load_test.ramp_up_time_seconds', [getUnitLabel(threadGroup)])"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -112,7 +119,7 @@
|
||||||
@change="calculateChart(threadGroup)"
|
@change="calculateChart(threadGroup)"
|
||||||
size="mini"/>
|
size="mini"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('load_test.ramp_up_time_seconds')"/>
|
<el-form-item :label="$t('load_test.ramp_up_time_seconds', [getUnitLabel(threadGroup)])"/>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -137,6 +144,7 @@ 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 UNIT = "unit";
|
||||||
const RPS_LIMIT = "rpsLimit";
|
const RPS_LIMIT = "rpsLimit";
|
||||||
const RPS_LIMIT_ENABLE = "rpsLimitEnable";
|
const RPS_LIMIT_ENABLE = "rpsLimitEnable";
|
||||||
const THREAD_TYPE = "threadType";
|
const THREAD_TYPE = "threadType";
|
||||||
|
@ -196,11 +204,10 @@ export default {
|
||||||
this.threadGroups[i].iterateRampUp = item.value;
|
this.threadGroups[i].iterateRampUp = item.value;
|
||||||
break;
|
break;
|
||||||
case DURATION:
|
case DURATION:
|
||||||
if (item.unit) {
|
|
||||||
this.threadGroups[i].duration = item.value;
|
this.threadGroups[i].duration = item.value;
|
||||||
} else {
|
break;
|
||||||
this.threadGroups[i].duration = item.value * 60;
|
case UNIT:
|
||||||
}
|
this.threadGroups[i].unit = item.value;
|
||||||
break;
|
break;
|
||||||
case STEPS:
|
case STEPS:
|
||||||
this.threadGroups[i].step = item.value;
|
this.threadGroups[i].step = item.value;
|
||||||
|
@ -506,6 +513,18 @@ export default {
|
||||||
}
|
}
|
||||||
this.calculateTotalChart();
|
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');
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
report: {
|
report: {
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
<el-table :data="granularityData">
|
<el-table :data="granularityData">
|
||||||
<el-table-column property="start" :label="$t('load_test.duration')">
|
<el-table-column property="start" :label="$t('load_test.duration')">
|
||||||
<template v-slot:default="scope">
|
<template v-slot:default="scope">
|
||||||
<span>{{ scope.row.start }} - {{ scope.row.end }}</span>
|
<span>{{ scope.row.start }}S - {{ scope.row.end }}S</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column property="granularity" :label="$t('load_test.granularity')"/>
|
<el-table-column property="granularity" :label="$t('load_test.granularity')"/>
|
||||||
|
|
|
@ -47,10 +47,17 @@
|
||||||
:disabled="isReadOnly"
|
:disabled="isReadOnly"
|
||||||
v-model="threadGroup.duration"
|
v-model="threadGroup.duration"
|
||||||
:min="1"
|
:min="1"
|
||||||
:max="172800"
|
:max="99999"
|
||||||
@change="calculateChart(threadGroup)"
|
@change="calculateChart(threadGroup)"
|
||||||
size="mini"/>
|
size="mini"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-radio-group v-model="threadGroup.unit">
|
||||||
|
<el-radio label="S">{{ $t('schedule.cron.seconds') }}</el-radio>
|
||||||
|
<el-radio label="M">{{ $t('schedule.cron.minutes') }}</el-radio>
|
||||||
|
<el-radio label="H">{{ $t('schedule.cron.hours') }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</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()"/>
|
||||||
|
@ -74,7 +81,7 @@
|
||||||
@change="calculateChart(threadGroup)"
|
@change="calculateChart(threadGroup)"
|
||||||
size="mini"/>
|
size="mini"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('load_test.ramp_up_time_minutes')">
|
<el-form-item :label="$t('load_test.ramp_up_time_minutes', [getUnitLabel(threadGroup)])">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
:disabled="isReadOnly"
|
:disabled="isReadOnly"
|
||||||
:min="1"
|
:min="1"
|
||||||
|
@ -95,7 +102,7 @@
|
||||||
@change="calculateChart(threadGroup)"
|
@change="calculateChart(threadGroup)"
|
||||||
size="mini"/>
|
size="mini"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('load_test.ramp_up_time_seconds')"/>
|
<el-form-item :label="$t('load_test.ramp_up_time_seconds', [getUnitLabel(threadGroup)])"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -128,7 +135,7 @@
|
||||||
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')"/>
|
<el-form-item :label="$t('load_test.ramp_up_time_seconds', [getUnitLabel(threadGroup)])"/>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -154,6 +161,7 @@ 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 UNIT = "unit";
|
||||||
const RPS_LIMIT = "rpsLimit";
|
const RPS_LIMIT = "rpsLimit";
|
||||||
const RPS_LIMIT_ENABLE = "rpsLimitEnable";
|
const RPS_LIMIT_ENABLE = "rpsLimitEnable";
|
||||||
const HOLD = "Hold";
|
const HOLD = "Hold";
|
||||||
|
@ -253,11 +261,10 @@ export default {
|
||||||
this.threadGroups[i].iterateRampUp = item.value;
|
this.threadGroups[i].iterateRampUp = item.value;
|
||||||
break;
|
break;
|
||||||
case DURATION:
|
case DURATION:
|
||||||
if (item.unit) {
|
|
||||||
this.threadGroups[i].duration = item.value;
|
this.threadGroups[i].duration = item.value;
|
||||||
} else {
|
break;
|
||||||
this.threadGroups[i].duration = item.value * 60;
|
case UNIT:
|
||||||
}
|
this.threadGroups[i].unit = item.value;
|
||||||
break;
|
break;
|
||||||
case STEPS:
|
case STEPS:
|
||||||
this.threadGroups[i].step = item.value;
|
this.threadGroups[i].step = item.value;
|
||||||
|
@ -290,6 +297,7 @@ export default {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
this.$set(this.threadGroups[i], "unit", this.threadGroups[i].unit || 'S');
|
||||||
this.$set(this.threadGroups[i], "threadType", this.threadGroups[i].threadType || 'DURATION');
|
this.$set(this.threadGroups[i], "threadType", this.threadGroups[i].threadType || 'DURATION');
|
||||||
this.$set(this.threadGroups[i], "iterateNum", this.threadGroups[i].iterateNum || 1);
|
this.$set(this.threadGroups[i], "iterateNum", this.threadGroups[i].iterateNum || 1);
|
||||||
this.$set(this.threadGroups[i], "iterateRampUp", this.threadGroups[i].iterateRampUp || 10);
|
this.$set(this.threadGroups[i], "iterateRampUp", this.threadGroups[i].iterateRampUp || 10);
|
||||||
|
@ -576,6 +584,18 @@ export default {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
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() {
|
||||||
/// todo:下面4个属性是jmeter ConcurrencyThreadGroup plugin的属性,这种硬编码不太好吧,在哪能转换这种属性?
|
/// todo:下面4个属性是jmeter ConcurrencyThreadGroup plugin的属性,这种硬编码不太好吧,在哪能转换这种属性?
|
||||||
let result = [];
|
let result = [];
|
||||||
|
@ -585,7 +605,8 @@ export default {
|
||||||
{key: TARGET_LEVEL, value: this.threadGroups[i].threadNumber},
|
{key: TARGET_LEVEL, value: this.threadGroups[i].threadNumber},
|
||||||
{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.threadGroups[i].duration, unit: 'S'},
|
{key: DURATION, value: this.threadGroups[i].duration, unit: 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},
|
||||||
{key: HOLD, value: this.threadGroups[i].duration - this.threadGroups[i].rampUpTime},
|
{key: HOLD, value: this.threadGroups[i].duration - this.threadGroups[i].rampUpTime},
|
||||||
|
|
|
@ -31,6 +31,7 @@ export function findThreadGroup(jmxContent, handler) {
|
||||||
tg.enabled = tg.attributes.enabled;
|
tg.enabled = tg.attributes.enabled;
|
||||||
tg.tgType = tg.name;
|
tg.tgType = tg.name;
|
||||||
tg.threadType = 'DURATION';
|
tg.threadType = 'DURATION';
|
||||||
|
tg.unit = 'S';
|
||||||
})
|
})
|
||||||
return threadGroups;
|
return threadGroups;
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,7 +481,7 @@ export default {
|
||||||
delete_file: "The file already exists, please delete the file with the same name first!",
|
delete_file: "The file already exists, please delete the file with the same name first!",
|
||||||
thread_num: 'Concurrent users:',
|
thread_num: 'Concurrent users:',
|
||||||
input_thread_num: 'Please enter the number of threads',
|
input_thread_num: 'Please enter the number of threads',
|
||||||
duration: 'Duration time (seconds)',
|
duration: 'Duration time',
|
||||||
granularity: 'Aggregation time (seconds)',
|
granularity: 'Aggregation time (seconds)',
|
||||||
input_duration: 'Please enter a duration',
|
input_duration: 'Please enter a duration',
|
||||||
rps_limit: 'RPS Limit:',
|
rps_limit: 'RPS Limit:',
|
||||||
|
|
|
@ -478,14 +478,14 @@ export default {
|
||||||
delete_file: "文件已存在,请先删除同名文件!",
|
delete_file: "文件已存在,请先删除同名文件!",
|
||||||
thread_num: '并发用户数:',
|
thread_num: '并发用户数:',
|
||||||
input_thread_num: '请输入线程数',
|
input_thread_num: '请输入线程数',
|
||||||
duration: '压测时长(秒)',
|
duration: '压测时长',
|
||||||
granularity: '聚合时间(秒)',
|
granularity: '聚合时间(秒)',
|
||||||
input_duration: '请输入时长',
|
input_duration: '请输入时长',
|
||||||
rps_limit: 'RPS上限:',
|
rps_limit: 'RPS上限:',
|
||||||
input_rps_limit: '请输入限制',
|
input_rps_limit: '请输入限制',
|
||||||
ramp_up_time_within: '在',
|
ramp_up_time_within: '在',
|
||||||
ramp_up_time_minutes: '秒内,分',
|
ramp_up_time_minutes: '{0}内,分',
|
||||||
ramp_up_time_seconds: '秒内增加并发用户',
|
ramp_up_time_seconds: '{0}内增加并发用户',
|
||||||
iterate_num: '迭代次数 (次): ',
|
iterate_num: '迭代次数 (次): ',
|
||||||
by_iteration: '按迭代次数',
|
by_iteration: '按迭代次数',
|
||||||
by_duration: '按持续时间',
|
by_duration: '按持续时间',
|
||||||
|
|
|
@ -478,7 +478,7 @@ export default {
|
||||||
delete_file: "文件已存在,請先刪除同名文件!",
|
delete_file: "文件已存在,請先刪除同名文件!",
|
||||||
thread_num: '並發用戶數:',
|
thread_num: '並發用戶數:',
|
||||||
input_thread_num: '請輸入線程數',
|
input_thread_num: '請輸入線程數',
|
||||||
duration: '壓測時長(秒)',
|
duration: '壓測時長',
|
||||||
granularity: '聚合時間(秒)',
|
granularity: '聚合時間(秒)',
|
||||||
input_duration: '請輸入時長',
|
input_duration: '請輸入時長',
|
||||||
rps_limit: 'RPS上限:',
|
rps_limit: 'RPS上限:',
|
||||||
|
|
Loading…
Reference in New Issue