fix(性能测试): 修复固定节点或自定义分配用户数时最大并发数不能限制的问题

--bug=1020219 --user=刘瑞斌 [性能测试]github#20103性能测试设置完资源池中压力机的最大并发数,压测执行时,分配策略选固定节点、自定义策略 没限制住单个压力机的最大并发数 https://www.tapd.cn/55049933/s/1320156
This commit is contained in:
CaptainB 2022-12-28 09:54:20 +08:00 committed by 刘瑞斌
parent 6a59f4c1bc
commit 80bd9b4f14
4 changed files with 30 additions and 2 deletions

View File

@ -206,7 +206,7 @@
<div v-if="threadGroup.strategy === 'auto'"></div> <div v-if="threadGroup.strategy === 'auto'"></div>
<div v-else-if="threadGroup.strategy === 'specify'"> <div v-else-if="threadGroup.strategy === 'specify'">
<el-form-item :label="$t('load_test.specify_resource')"> <el-form-item :label="$t('load_test.specify_resource')">
<el-select v-model="threadGroup.resourceNodeIndex" size="mini"> <el-select v-model="threadGroup.resourceNodeIndex" @change="specifyNodeChange(threadGroup)" size="mini">
<el-option <el-option
v-for="(node, index) in resourceNodes" v-for="(node, index) in resourceNodes"
:key="node.ip" :key="node.ip"
@ -224,7 +224,8 @@
<el-table-column prop="ratio" :label="$t('test_track.home.percentage')"> <el-table-column prop="ratio" :label="$t('test_track.home.percentage')">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<el-input-number size="mini" v-model="row.ratio" <el-input-number size="mini" v-model="row.ratio"
v-if="rampUpTimeVisible"
@change="customNodeChange(threadGroup)"
:min="0" :step=".1" controls-position="right" :min="0" :step=".1" controls-position="right"
:max="1"></el-input-number> :max="1"></el-input-number>
</template> </template>
@ -734,6 +735,8 @@ export default {
} }
if (tg.strategy === "custom") { if (tg.strategy === "custom") {
this.customNodeChange(tg);
let sum = tg.resourceNodes.map(n => n.ratio).reduce((total, curr) => { let sum = tg.resourceNodes.map(n => n.ratio).reduce((total, curr) => {
total += curr; total += curr;
return total; return total;
@ -744,6 +747,10 @@ export default {
} }
} }
if (tg.strategy === "specify") {
this.specifyNodeChange(tg);
}
if (!tg.threadNumber || !tg.duration if (!tg.threadNumber || !tg.duration
|| !tg.rampUpTime || !tg.step || !tg.iterateNum) { || !tg.rampUpTime || !tg.step || !tg.iterateNum) {
this.$warning(this.$t('load_test.pressure_config_params_is_empty')); this.$warning(this.$t('load_test.pressure_config_params_is_empty'));
@ -774,6 +781,24 @@ export default {
return []; return [];
} }
}, },
specifyNodeChange(threadGroup) {
this.$set(this, 'maxThreadNumbers', threadGroup.resourceNodes[threadGroup.resourceNodeIndex].maxConcurrency);
if (threadGroup.threadNumber > this.maxThreadNumbers) {
threadGroup.threadNumber = this.maxThreadNumbers;
}
this.calculateTotalChart();
},
customNodeChange(threadGroup) {
threadGroup.resourceNodes.forEach(node => {
if (node.ratio * threadGroup.threadNumber > node.maxConcurrency) {
setTimeout(() => {
this.$warning(this.$t('load_test.max_current_threads_tips', [node.ip]));
});
node.ratio = (node.maxConcurrency / threadGroup.threadNumber).toFixed(2);
}
});
this.calculateTotalChart();
},
convertProperty() { convertProperty() {
/// todo4jmeter ConcurrencyThreadGroup plugin /// todo4jmeter ConcurrencyThreadGroup plugin
let result = []; let result = [];

View File

@ -1108,6 +1108,7 @@ export default {
stoptest: 'Stop test', stoptest: 'Stop test',
stoptestnow: 'Stop the test immediately', stoptestnow: 'Stop the test immediately',
batch_delete_confirm: "Confirm batch delete performance test", batch_delete_confirm: "Confirm batch delete performance test",
max_current_threads_tips: 'Exceeded the maximum concurrent number of this node {0}',
report: { report: {
diff: "Compare", diff: "Compare",
set_default: 'Set to Default', set_default: 'Set to Default',

View File

@ -1113,6 +1113,7 @@ export default {
stoptest: '停止测试', stoptest: '停止测试',
stoptestnow: '立即停止测试', stoptestnow: '立即停止测试',
batch_delete_confirm: "确认批量删除性能测试", batch_delete_confirm: "确认批量删除性能测试",
max_current_threads_tips: '超出此节点{0}最大并发数',
report: { report: {
diff: "对比", diff: "对比",
set_default: '恢复默认', set_default: '恢复默认',

View File

@ -1113,6 +1113,7 @@ export default {
stoptest: '停止測試', stoptest: '停止測試',
stoptestnow: '立即停止測試', stoptestnow: '立即停止測試',
batch_delete_confirm: "确认批量删除性能测试", batch_delete_confirm: "确认批量删除性能测试",
max_current_threads_tips: '超出此節點{0}最大並發數',
report: { report: {
diff: "對比", diff: "對比",
set_default: '恢復默認', set_default: '恢復默認',