feat(性能测试): 支持选择线程组
This commit is contained in:
parent
3a7a37bc19
commit
7599c4c5fc
|
@ -594,6 +594,81 @@ public class JmeterDocumentParser implements DocumentParser {
|
|||
if (!hashTree.hasChildNodes()) {
|
||||
MSException.throwException(Translator.get("jmx_content_valid"));
|
||||
}
|
||||
Object tgTypes = context.getProperty("tgType");
|
||||
String tgType = "ThreadGroup";
|
||||
if (tgTypes instanceof List) {
|
||||
Object o = ((List<?>) tgTypes).get(0);
|
||||
((List<?>) tgTypes).remove(0);
|
||||
tgType = o.toString();
|
||||
}
|
||||
if (StringUtils.equals(tgType, THREAD_GROUP)) {
|
||||
processBaseThreadGroup(threadGroup);
|
||||
}
|
||||
if (StringUtils.equals(tgType, CONCURRENCY_THREAD_GROUP)) {
|
||||
processConcurrencyThreadGroup(threadGroup);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processBaseThreadGroup(Element threadGroup) {
|
||||
/*
|
||||
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="登录" enabled="true">
|
||||
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
|
||||
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
|
||||
<boolProp name="LoopController.continue_forever">false</boolProp>
|
||||
<stringProp name="LoopController.loops">1</stringProp>
|
||||
</elementProp>
|
||||
<stringProp name="ThreadGroup.num_threads">1</stringProp>
|
||||
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
|
||||
<boolProp name="ThreadGroup.scheduler">false</boolProp>
|
||||
<stringProp name="ThreadGroup.duration"></stringProp>
|
||||
<stringProp name="ThreadGroup.delay"></stringProp>
|
||||
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
|
||||
</ThreadGroup>
|
||||
*/
|
||||
removeChildren(threadGroup);
|
||||
Document document = threadGroup.getOwnerDocument();
|
||||
Object targetLevels = context.getProperty("TargetLevel");
|
||||
String threads = "10";
|
||||
if (targetLevels instanceof List) {
|
||||
Object o = ((List<?>) targetLevels).get(0);
|
||||
((List<?>) targetLevels).remove(0);
|
||||
threads = o.toString();
|
||||
}
|
||||
Object rampUps = context.getProperty("RampUp");
|
||||
String rampUp = "1";
|
||||
if (rampUps instanceof List) {
|
||||
Object o = ((List<?>) rampUps).get(0);
|
||||
((List<?>) rampUps).remove(0);
|
||||
rampUp = o.toString();
|
||||
}
|
||||
Object holds = context.getProperty("Hold");
|
||||
String hold = "2";
|
||||
if (holds instanceof List) {
|
||||
Object o = ((List<?>) holds).get(0);
|
||||
((List<?>) holds).remove(0);
|
||||
hold = o.toString();
|
||||
}
|
||||
Element elementProp = document.createElement("elementProp");
|
||||
elementProp.setAttribute("name", "ThreadGroup.main_controller");
|
||||
elementProp.setAttribute("elementType", "LoopController");
|
||||
elementProp.setAttribute("guiclass", "LoopControlPanel");
|
||||
elementProp.setAttribute("testclass", "LoopController");
|
||||
elementProp.setAttribute("testname", "Loop Controller");
|
||||
elementProp.setAttribute("enabled", "true");
|
||||
elementProp.appendChild(createBoolProp(document, "LoopController.continue_forever", false));
|
||||
elementProp.appendChild(createStringProp(document, "LoopController.loops", "-1"));
|
||||
threadGroup.appendChild(elementProp);
|
||||
threadGroup.appendChild(createStringProp(document, "ThreadGroup.on_sample_error", "continue"));
|
||||
threadGroup.appendChild(createStringProp(document, "ThreadGroup.num_threads", threads));
|
||||
threadGroup.appendChild(createStringProp(document, "ThreadGroup.ramp_time", rampUp));
|
||||
threadGroup.appendChild(createStringProp(document, "ThreadGroup.duration", hold));
|
||||
threadGroup.appendChild(createStringProp(document, "ThreadGroup.delay", "0"));
|
||||
threadGroup.appendChild(createBoolProp(document, "ThreadGroup.scheduler", true));
|
||||
threadGroup.appendChild(createBoolProp(document, "ThreadGroup.same_user_on_next_iteration", true));
|
||||
}
|
||||
|
||||
private void processConcurrencyThreadGroup(Element threadGroup) {
|
||||
// 重命名 tagName
|
||||
Document document = threadGroup.getOwnerDocument();
|
||||
document.renameNode(threadGroup, threadGroup.getNamespaceURI(), CONCURRENCY_THREAD_GROUP);
|
||||
|
|
|
@ -46,7 +46,9 @@
|
|||
<el-table-column
|
||||
label="ThreadGroup">
|
||||
<template v-slot:default="{row}">
|
||||
{{ row.name.substring(row.name.lastIndexOf(".") + 1) }}
|
||||
<el-select v-model="row.tgType" :placeholder="$t('commons.please_select')" size="small">
|
||||
<el-option v-for="tg in threadGroupForSelect" :key="tg.tagName" :label="tg.name" :value="tg.testclass"></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
|
@ -176,6 +178,20 @@ export default {
|
|||
apiScenarios: [],
|
||||
loadApiAutomationVisible: false,
|
||||
selectIds: new Set(),
|
||||
threadGroupForSelect: [
|
||||
{
|
||||
name: 'ThreadGroup',
|
||||
tagName: 'ThreadGroup',
|
||||
testclass: 'ThreadGroup',
|
||||
guiclass: 'ThreadGroupGui'
|
||||
},
|
||||
{
|
||||
name: 'ConcurrencyThreadGroup',
|
||||
tagName: 'com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup',
|
||||
testclass: 'com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup',
|
||||
guiclass: "com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroupGui"
|
||||
},
|
||||
]
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
|
|
@ -62,25 +62,39 @@
|
|||
size="mini"/>
|
||||
</el-form-item>
|
||||
<br>
|
||||
<el-form-item :label="$t('load_test.ramp_up_time_within')">
|
||||
<el-input-number
|
||||
:disabled="isReadOnly"
|
||||
:min="1"
|
||||
:max="threadGroup.duration"
|
||||
v-model="threadGroup.rampUpTime"
|
||||
@change="calculateChart(threadGroup)"
|
||||
size="mini"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('load_test.ramp_up_time_minutes')">
|
||||
<el-input-number
|
||||
:disabled="isReadOnly"
|
||||
:min="1"
|
||||
:max="Math.min(threadGroup.threadNumber, threadGroup.rampUpTime)"
|
||||
v-model="threadGroup.step"
|
||||
@change="calculateChart(threadGroup)"
|
||||
size="mini"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('load_test.ramp_up_time_times')"/>
|
||||
<div v-if="threadGroup.tgType === 'com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup'">
|
||||
<el-form-item :label="$t('load_test.ramp_up_time_within')">
|
||||
<el-input-number
|
||||
:disabled="isReadOnly"
|
||||
:min="1"
|
||||
:max="threadGroup.duration"
|
||||
v-model="threadGroup.rampUpTime"
|
||||
@change="calculateChart(threadGroup)"
|
||||
size="mini"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('load_test.ramp_up_time_minutes')">
|
||||
<el-input-number
|
||||
:disabled="isReadOnly"
|
||||
:min="1"
|
||||
:max="Math.min(threadGroup.threadNumber, threadGroup.rampUpTime)"
|
||||
v-model="threadGroup.step"
|
||||
@change="calculateChart(threadGroup)"
|
||||
size="mini"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('load_test.ramp_up_time_times')"/>
|
||||
</div>
|
||||
|
||||
<div v-if="threadGroup.tgType === 'ThreadGroup'">
|
||||
<el-form-item :label="$t('load_test.ramp_up_time_within')">
|
||||
<el-input-number
|
||||
:disabled="isReadOnly"
|
||||
:min="1"
|
||||
v-model="threadGroup.rampUpTime"
|
||||
size="mini"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('load_test.ramp_up_time_seconds')"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div v-if="threadGroup.threadType === 'ITERATION'">
|
||||
<el-form-item :label="$t('load_test.iterate_num')">
|
||||
|
@ -131,6 +145,7 @@ import MsChart from "@/business/components/common/chart/MsChart";
|
|||
import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup";
|
||||
|
||||
const HANDLER = "handler";
|
||||
const THREAD_GROUP_TYPE = "tgType";
|
||||
const TARGET_LEVEL = "TargetLevel";
|
||||
const RAMP_UP = "RampUp";
|
||||
const ITERATE_RAMP_UP = "iterateRampUpTime";
|
||||
|
@ -265,6 +280,9 @@ export default {
|
|||
case HANDLER:
|
||||
this.threadGroups[i].handler = item.value;
|
||||
break;
|
||||
case THREAD_GROUP_TYPE:
|
||||
this.threadGroups[i].tgType = item.value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -535,6 +553,7 @@ export default {
|
|||
{key: ITERATE_RAMP_UP, value: this.threadGroups[i].iterateRampUp},
|
||||
{key: ENABLED, value: this.threadGroups[i].enabled},
|
||||
{key: DELETED, value: this.threadGroups[i].deleted},
|
||||
{key: THREAD_GROUP_TYPE, value: this.threadGroups[i].tgType},
|
||||
]);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -29,6 +29,8 @@ export function findThreadGroup(jmxContent, handler) {
|
|||
tg.deleted = 'false';
|
||||
tg.handler = handler;
|
||||
tg.enabled = tg.attributes.enabled;
|
||||
tg.tgType = tg.name;
|
||||
tg.threadType = 'DURATION';
|
||||
})
|
||||
return threadGroups;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue