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"
@ -32,7 +32,7 @@
</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 }},
{{$t('load_test.iterate_num')}} {{threadGroup.iterateNum}} {{ $t('load_test.iterate_num') }} {{ threadGroup.iterateNum }}
</el-tag> </el-tag>
</template> </template>
<el-form :inline="true"> <el-form :inline="true">
@ -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,
@ -649,7 +672,7 @@ export default {
border-bottom: 1px solid #DCDFE6; border-bottom: 1px solid #DCDFE6;
} }
/deep/ .el-collapse-item__content{ /deep/ .el-collapse-item__content {
padding-left: 10px; padding-left: 10px;
padding-bottom: 5px; padding-bottom: 5px;
border-left-width: 8px; border-left-width: 8px;