fix(性能测试): 修复计算总线程数没有排除禁用的线程组的bug
This commit is contained in:
parent
2e16938c31
commit
bb4f30a9a1
|
@ -19,8 +19,8 @@ import org.apache.commons.collections.CollectionUtils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class AbstractEngine implements Engine {
|
||||
protected String JMETER_IMAGE;
|
||||
|
@ -106,17 +106,20 @@ public abstract class AbstractEngine implements Engine {
|
|||
String loadConfiguration = t.getLoadConfiguration();
|
||||
JSONArray jsonArray = JSON.parseArray(loadConfiguration);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
if (jsonArray.get(i) instanceof Map) {
|
||||
JSONObject o = jsonArray.getJSONObject(i);
|
||||
if (StringUtils.equals(o.getString("key"), "TargetLevel")) {
|
||||
s = o.getInteger("value");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (jsonArray.get(i) instanceof List) {
|
||||
JSONArray o = jsonArray.getJSONArray(i);
|
||||
for (int j = 0; j < o.size(); j++) {
|
||||
JSONObject b = o.getJSONObject(j);
|
||||
List<JSONObject> enabledConfig = o.stream()
|
||||
.filter(b -> {
|
||||
JSONObject c = JSON.parseObject(b.toString());
|
||||
if (StringUtils.equals(c.getString("deleted"), "true")) {
|
||||
return false;
|
||||
}
|
||||
return !StringUtils.equals(c.getString("enabled"), "false");
|
||||
})
|
||||
.map(b -> JSON.parseObject(b.toString()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (JSONObject b : enabledConfig) {
|
||||
if (StringUtils.equals(b.getString("key"), "TargetLevel")) {
|
||||
s += b.getInteger("value");
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue