我有一個事務控制器,它在我的Jmeter測試計劃中有一個http請求。交易名稱和網址來自CSV文件。最後,執行總計分爲5個不同的交易。如何在指定的線程數量失敗後停止Jmeter測試
TestPlan中:
TestPlan中 -Thread組 - 用戶定義的變量
總樣品執行將是8000-10000。現在我想要的,如果總樣本失敗達到100,我的JMeter測試應該停止測試執行。
我已經添加了用戶定義的變量名「thread」並且值爲「0」。我在Beanshell中添加了以下代碼後處理器
int count= Integer.parseInt(vars.get("thread"));
if (prev.getErrorCount()==1){
count++;
System.out.println(count);
vars.put("thread",Integer.toString(count));
}
if (count==100){
System.out.println("Reached to max number of errors in load test, stopping test");
log.info ("Reached to max number of errors in load test, stopping test");
prev.setStopTestNow(true);
}
某種程度上代碼不能按預期工作。當錯誤計數達到100時,Jmeter測試不會停止。當錯誤計數達到130時停止測試。我不確定誰來修復上面的代碼。
有人能讓我知道上面的代碼中有什麼問題嗎?
您是否有嵌套樣本? – Ross
如果我爲單個用戶運行它,並保持錯誤計數限制爲3,它工作正常。 3名失敗者後停止測試。但是,當我運行5個用戶,最大錯誤數爲3,8次失敗後停止測試。 它是簡單的腳本。沒有嵌套樣本。 – user1169236
您是否嘗試過使用道具而不是'vars'? – Ross