refactor(性能测试): 增加压力参数校验

--bug=1024918 --user=刘瑞斌 【性能测试】执行性能测试空指针错误 https://www.tapd.cn/55049933/s/1356639
This commit is contained in:
CaptainB 2023-03-29 14:00:10 +08:00 committed by 刘瑞斌
parent 4747691abc
commit d16a80cef7
6 changed files with 75 additions and 32 deletions

View File

@ -120,9 +120,6 @@ public class EngineFactory {
}
if (values instanceof List) {
Object value = b.get("value");
if (value == null) {
MSException.throwException(Translator.get("load_configuration_value_is_null") + ", key:" + key);
}
if ("TargetLevel".equals(key)) {
switch (strategy) {
default:

View File

@ -133,8 +133,10 @@ public class JmeterDocumentParser implements EngineSourceParser {
String autoStopDelay = "30";
if (autoStopDelays instanceof List) {
Object o = ((List<?>) autoStopDelays).get(0);
if (o != null) {
autoStopDelay = o.toString();
}
}
// 清空child
removeChildren(autoStopListener);
// 添加子元素
@ -146,8 +148,10 @@ public class JmeterDocumentParser implements EngineSourceParser {
String autoStop = "false";
if (autoStops instanceof List) {
Object o = ((List<?>) autoStops).get(0);
if (o != null) {
autoStop = o.toString();
}
}
if (!BooleanUtils.toBoolean(autoStop)) {
return;
}
@ -166,8 +170,10 @@ public class JmeterDocumentParser implements EngineSourceParser {
String serializeThreadGroup = "false";
if (serializeThreadGroups instanceof List) {
Object o = ((List<?>) serializeThreadGroups).get(0);
if (o != null) {
serializeThreadGroup = o.toString();
}
}
List<Element> childNodes = element.elements();
for (Element item : childNodes) {
if (nodeNameEquals(item, BOOL_PROP)) {
@ -654,8 +660,10 @@ public class JmeterDocumentParser implements EngineSourceParser {
if (tgTypes instanceof List) {
Object o = ((List<?>) tgTypes).get(0);
((List<?>) tgTypes).remove(0);
if (o != null) {
tgType = o.toString();
}
}
if (StringUtils.equals(tgType, THREAD_GROUP)) {
processBaseThreadGroup(threadGroup, THREAD_GROUP);
}
@ -713,29 +721,37 @@ public class JmeterDocumentParser implements EngineSourceParser {
if (targetLevels instanceof List) {
Object o = ((List<?>) targetLevels).get(0);
((List<?>) targetLevels).remove(0);
if (o != null) {
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);
if (o != null) {
rampUp = o.toString();
}
}
Object durations = context.getProperty("duration");
String duration = "2";
if (durations instanceof List) {
Object o = ((List<?>) durations).get(0);
((List<?>) durations).remove(0);
if (o != null) {
duration = o.toString();
}
}
Object onSampleErrors = context.getProperty("onSampleError");
String onSampleError = "continue";
if (onSampleErrors instanceof List) {
Object o = ((List<?>) onSampleErrors).get(0);
((List<?>) onSampleErrors).remove(0);
if (o != null) {
onSampleError = o.toString();
}
}
Object units = context.getProperty("unit");
if (units instanceof List) {
Object o = ((List<?>) units).get(0);
@ -746,15 +762,19 @@ public class JmeterDocumentParser implements EngineSourceParser {
if (deleteds instanceof List) {
Object o = ((List<?>) deleteds).get(0);
((List<?>) deleteds).remove(0);
if (o != null) {
deleted = o.toString();
}
}
Object enableds = context.getProperty("enabled");
String enabled = "true";
if (enableds instanceof List) {
Object o = ((List<?>) enableds).get(0);
((List<?>) enableds).remove(0);
if (o != null) {
enabled = o.toString();
}
}
threadGroup.addAttribute("enabled", enabled);
if (BooleanUtils.toBoolean(deleted)) {
@ -814,36 +834,46 @@ public class JmeterDocumentParser implements EngineSourceParser {
if (targetLevels instanceof List) {
Object o = ((List<?>) targetLevels).get(0);
((List<?>) targetLevels).remove(0);
if (o != null) {
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);
if (o != null) {
rampUp = o.toString();
}
}
Object steps = context.getProperty("Steps");
String step = "2";
if (steps instanceof List) {
Object o = ((List<?>) steps).get(0);
((List<?>) steps).remove(0);
if (o != null) {
step = o.toString();
}
}
Object holds = context.getProperty("Hold");
String hold = "2";
if (holds instanceof List) {
Object o = ((List<?>) holds).get(0);
((List<?>) holds).remove(0);
if (o != null) {
hold = o.toString();
}
}
Object onSampleErrors = context.getProperty("onSampleError");
String onSampleError = "continue";
if (onSampleErrors instanceof List) {
Object o = ((List<?>) onSampleErrors).get(0);
((List<?>) onSampleErrors).remove(0);
if (o != null) {
onSampleError = o.toString();
}
}
Object units = context.getProperty("unit");
if (units instanceof List) {
Object o = ((List<?>) units).get(0);
@ -854,15 +884,19 @@ public class JmeterDocumentParser implements EngineSourceParser {
if (deleteds instanceof List) {
Object o = ((List<?>) deleteds).get(0);
((List<?>) deleteds).remove(0);
if (o != null) {
deleted = o.toString();
}
}
Object enableds = context.getProperty("enabled");
String enabled = "true";
if (enableds instanceof List) {
Object o = ((List<?>) enableds).get(0);
((List<?>) enableds).remove(0);
if (o != null) {
enabled = o.toString();
}
}
threadGroup.addAttribute("enabled", enabled);
if (BooleanUtils.toBoolean(deleted)) {
@ -894,8 +928,10 @@ public class JmeterDocumentParser implements EngineSourceParser {
if (tgTypes instanceof List) {
Object o = ((List<?>) tgTypes).get(0);
((List<?>) tgTypes).remove(0);
if (o != null) {
tgType = o.toString();
}
}
if (StringUtils.equals(tgType, THREAD_GROUP)) {
threadGroup.setName(THREAD_GROUP);
threadGroup.addAttribute("guiclass", THREAD_GROUP + "Gui");
@ -933,8 +969,10 @@ public class JmeterDocumentParser implements EngineSourceParser {
String duration = "2";
if (durations instanceof List) {
Object o = ((List<?>) durations).remove(0);
if (o != null) {
duration = o.toString();
}
}
Object units = context.getProperty("unit");
if (units instanceof List) {
((List<?>) units).remove(0);
@ -956,43 +994,55 @@ public class JmeterDocumentParser implements EngineSourceParser {
if (targetLevels instanceof List) {
Object o = ((List<?>) targetLevels).get(0);
((List<?>) targetLevels).remove(0);
if (o != null) {
threads = o.toString();
}
}
Object iterateNum = context.getProperty("iterateNum");
String loops = "1";
if (iterateNum instanceof List) {
Object o = ((List<?>) iterateNum).get(0);
((List<?>) iterateNum).remove(0);
if (o != null) {
loops = o.toString();
}
}
Object onSampleErrors = context.getProperty("onSampleError");
String onSampleError = "continue";
if (onSampleErrors instanceof List) {
Object o = ((List<?>) onSampleErrors).get(0);
((List<?>) onSampleErrors).remove(0);
if (o != null) {
onSampleError = o.toString();
}
}
Object rampUps = context.getProperty("iterateRampUpTime");
String rampUp = "10";
if (rampUps instanceof List) {
Object o = ((List<?>) rampUps).get(0);
((List<?>) rampUps).remove(0);
if (o != null) {
rampUp = o.toString();
}
}
Object deleteds = context.getProperty("deleted");
String deleted = "false";
if (deleteds instanceof List) {
Object o = ((List<?>) deleteds).get(0);
((List<?>) deleteds).remove(0);
if (o != null) {
deleted = o.toString();
}
}
Object enableds = context.getProperty("enabled");
String enabled = "true";
if (enableds instanceof List) {
Object o = ((List<?>) enableds).get(0);
((List<?>) enableds).remove(0);
if (o != null) {
enabled = o.toString();
}
}
threadGroup.addAttribute("enabled", enabled);
if (BooleanUtils.toBoolean(deleted)) {
threadGroup.addAttribute("enabled", "false");

View File

@ -1 +0,0 @@
load_configuration_value_is_null=

View File

@ -1 +0,0 @@
load_configuration_value_is_null=Load configuration error

View File

@ -1 +0,0 @@
load_configuration_value_is_null=压力配置参数错误

View File

@ -1 +0,0 @@
load_configuration_value_is_null=壓力配置參數錯誤