我在 HTTP 请求下有 JSR233 侦听器,它存储所有响应时间值,创建数组,然后对数组进行排序以找到 90% 行,然后在达到最终 90% 行阈值时标记最后一个事务/请求通过或失败。一切都在 GUI 中完美运行,但我正在使用 Docker Image 在 Gitlab CI 中运行这个测试,看起来这个 JSR233 脚本在 10 次中被忽略了 8 次,但有 2 次在那里也能正常工作。真的很困惑它在Windows控制台JMeter非gui中也表现得很奇怪,它被忽略可能是
String requests = props.get("requests");
long requestsSum = 0;
if (requests != null) {
requestsSum = Long.parseLong(props.get("requests"));
}
long thisRequest = sampleResult.getTime();
requestsSum++;
props.put("requests", String.valueOf(requestsSum));
props.put("rt"+String.valueOf(requestsSum), String.valueOf(thisRequest));
if ( requestsSum > 4 ) {
ArrayList strList = new ArrayList();
for (int i=1;i<6; i++){
strList.add(Integer.parseInt(props.get("rt"+String.valueOf(i))));
}
vars.putObject("ArrayListBeforeSorting",strList);
Collections.sort(strList);
vars.putObject("ArrayListAfterSorting",strList);
String HID = vars.get("ArrayListAfterSorting"); String[] words = HID.split(",");
log.info("ninetypercent line is: " + words[3]);
vars.put("NPL" , words[3]);
int ninetypercentline = Integer.parseInt(words[3].trim());
if ( ninetypercentline > 100 ) {
sampleResult.setSuccessful(false);
sampleResult.setResponseMessage("ninety percent line is reached");
}
}