支持压力配置rps参数
This commit is contained in:
parent
36544f3621
commit
b6e24a9644
|
@ -22,6 +22,7 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
private final static String HASH_TREE_ELEMENT = "hashTree";
|
private final static String HASH_TREE_ELEMENT = "hashTree";
|
||||||
private final static String STRING_PROP = "stringProp";
|
private final static String STRING_PROP = "stringProp";
|
||||||
private final static String CONCURRENCY_THREAD_GROUP = "com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup";
|
private final static String CONCURRENCY_THREAD_GROUP = "com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup";
|
||||||
|
private final static String VARIABLE_THROUGHPUT_TIMER = "kg.apc.jmeter.timers.VariableThroughputTimer";
|
||||||
private EngineContext context;
|
private EngineContext context;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,6 +76,8 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
parseHashTree(ele);
|
parseHashTree(ele);
|
||||||
} else if (nodeNameEquals(ele, CONCURRENCY_THREAD_GROUP)) {
|
} else if (nodeNameEquals(ele, CONCURRENCY_THREAD_GROUP)) {
|
||||||
processConcurrencyThreadGroup(ele);
|
processConcurrencyThreadGroup(ele);
|
||||||
|
} else if (nodeNameEquals(ele, VARIABLE_THROUGHPUT_TIMER)) {
|
||||||
|
processVariableThroughputTimer(ele);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,6 +103,34 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processVariableThroughputTimer(Element variableThroughputTimer) {
|
||||||
|
if (variableThroughputTimer.getChildNodes().getLength() > 0) {
|
||||||
|
final NodeList childNodes = variableThroughputTimer.getChildNodes();
|
||||||
|
int stringPropCount = 0;
|
||||||
|
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||||
|
Node node = childNodes.item(i);
|
||||||
|
if (node instanceof Element) {
|
||||||
|
Element ele = (Element) node;
|
||||||
|
if (invalid(ele)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// kg.apc.jmeter.timers.VariableThroughputTimer的stringProp的name属性是动态的
|
||||||
|
if (nodeNameEquals(ele, STRING_PROP)) {
|
||||||
|
if (stringPropCount < 2) {
|
||||||
|
stringPropCount++;
|
||||||
|
} else {
|
||||||
|
stringPropCount = 0;
|
||||||
|
ele.getFirstChild().setNodeValue(context.getProperty("duration").toString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ele.getFirstChild().setNodeValue(context.getProperty("rpsLimit").toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void parseStringProp(Element stringProp) {
|
private void parseStringProp(Element stringProp) {
|
||||||
if (stringProp.getChildNodes().getLength() > 0 && context.getProperty(stringProp.getAttribute("name")) != null) {
|
if (stringProp.getChildNodes().getLength() > 0 && context.getProperty(stringProp.getAttribute("name")) != null) {
|
||||||
stringProp.getFirstChild().setNodeValue(context.getProperty(stringProp.getAttribute("name")).toString());
|
stringProp.getFirstChild().setNodeValue(context.getProperty(stringProp.getAttribute("name")).toString());
|
||||||
|
|
Loading…
Reference in New Issue