我试图创建一个测试计划,当达到某个值时,然后发生一些功能。测试计划由多个以循环运行的线程组成,当达到某些条件时,我想发起HTTP请求。我会在下面讨论它的内核: 在我的测试中,我有多线程循环方式的逻辑,当条件满足时(条件每10秒满足一次),那么我需要迭代通过一个值,它的价值应该从以前的迭代保存 - 我定义的值是一个属性(user.properties
) - startIndex = 0
(初始化为0)。 所以我做了一个While Controller
它的状况是这样的:JMeter循环索引和属性更新
${__javaScript(${__P(startIndex,)}<=${currBulk},)}
我期待的HTTP请求,这依赖于内部,而价值startIndex
要当startIndex<=currBulk
变量执行。
的While Controller
里面的HTTP请求应该被解雇,直到所有的指标都包括在内,我都写过这样的内部BeanShell PostProcessor
:
int startIndexIncInt = Integer.parseInt(props.getProperty("startIndex")); //get the initiated index of the loop
startIndexIncInt = startIndexIncInt + 1; //increment it and see if needed to fire the request again, by the original While condition
vars.put("startIndexIncIntVar", String.valueOf(startIndexIncInt));
props.put("startIndex",vars.get("startIndexIncIntVar")); //the property incremental and update
所以,我为了把它设计一样,在下一时间(10秒后)我将更新startIndex
,这将与新的currBulk
(它总是由我的测试计划更新)进行比较。 而我只是不能完成它。我不断收到类似的错误:
startIndexIncInt = Integer.parseInt(props.ge . . . '' : Typed variable declaration : Method Invocation Integer.parseInt
不用说,我也定义不设置好的了var startIndexIncIntVar
(我通过调试取样检查)。 此外,我的问题是没有与时间进入while,我的问题基本上是我应该增量和使用我的HTTP请求(while条件,和beanshell后处理器脚本)的变量
只为更多它的信息,如果我写它的伪代码它应该是这样的:
startInc = 0
----Test plan loop----
------ test logic, currBulk incremented through the test-----
if(time condition to enter while){
while (startIndex <= currBulk){
Send HTTP request (the request depends on startIndex value)
startIndex++
}
}
请协助