fix(性能测试): 修复最大并发数没有按照资源池来限制的bug

Closes #1708
This commit is contained in:
Captain.B 2021-03-25 19:25:08 +08:00
parent 1879984912
commit b4bb64f9da
1 changed files with 27 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<el-col> <el-col>
<el-form :inline="true"> <el-form :inline="true">
<el-form-item :label="$t('load_test.select_resource_pool')"> <el-form-item :label="$t('load_test.select_resource_pool')">
<el-select v-model="resourcePool" :disabled="isReadOnly" size="mini"> <el-select v-model="resourcePool" :disabled="isReadOnly" size="mini" @change="resourcePoolChange">
<el-option <el-option
v-for="item in resourcePools" v-for="item in resourcePools"
:key="item.id" :key="item.id"
@ -42,6 +42,7 @@
v-model="threadGroup.threadNumber" v-model="threadGroup.threadNumber"
@change="calculateTotalChart(threadGroup)" @change="calculateTotalChart(threadGroup)"
:min="resourcePoolResourceLength" :min="resourcePoolResourceLength"
:max="maxThreadNumbers"
size="mini"/> size="mini"/>
</el-form-item> </el-form-item>
<br> <br>
@ -219,7 +220,8 @@ export default {
resourcePools: [], resourcePools: [],
activeNames: ["0"], activeNames: ["0"],
threadGroups: [], threadGroups: [],
resourcePoolResourceLength: 1 resourcePoolResourceLength: 1,
maxThreadNumbers: 5000,
} }
}, },
mounted() { mounted() {
@ -336,6 +338,22 @@ export default {
}); });
} }
}, },
resourcePoolChange() {
let result = this.resourcePools.filter(p => p.id === this.resourcePool);
if (result.length === 1) {
let threadNumber = 0;
result[0].resources.forEach(resource => {
threadNumber += JSON.parse(resource.configuration).maxConcurrency;
})
this.maxThreadNumbers = threadNumber;
this.threadGroups.forEach(tg => {
if (tg.threadNumber > threadNumber) {
this.$set(tg, "threadNumber", threadNumber);
}
})
this.calculateTotalChart();
}
},
calculateTotalChart() { calculateTotalChart() {
let handler = this; let handler = this;
if (handler.duration < handler.rampUpTime) { if (handler.duration < handler.rampUpTime) {
@ -344,6 +362,11 @@ export default {
if (handler.rampUpTime < handler.step) { if (handler.rampUpTime < handler.step) {
handler.step = handler.rampUpTime; handler.step = handler.rampUpTime;
} }
// 线
let resourcePool = this.resourcePools.filter(v => v.id === this.resourcePool)[0];
if (resourcePool) {
this.resourcePoolResourceLength = resourcePool.resources.length;
}
let color = ['#60acfc', '#32d3eb', '#5bc49f', '#feb64d', '#ff7c7c', '#9287e7', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3']; let color = ['#60acfc', '#32d3eb', '#5bc49f', '#feb64d', '#ff7c7c', '#9287e7', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3'];
handler.options = { handler.options = {
color: color, color: color,