JMeter使用Redis数据的样本顺序

时间:2018-07-30 07:34:35

标签: redis jmeter

我在JMeter测试中将Redis数据集用作数据源。我已经使用从JSR223采样器检索的值配置了redis密钥。

下面是我的测试采样器。

enter image description here

在灵敏的JSR223采样器中,我检索一个先前的值$ {operator}并放入属性中。

然后在下一个采样器中

enter image description here

我将值重用为$ {__ P(operator)}。

与此有关的问题是,在jp @ gc RedisDataset之前,它似乎不运行JSR233采样器。因此脚本会失败,如下所示。

Stop Thread seen for thread XXXXXX 1-1, reason: org.apache.jorphan.util.JMeterStopThreadException: End of Redis data detected, thread will exit

如果我运行脚本一次注释了Redis数据集采样器,并在启用它的情况下进行了第二次运行,则可以看到该值,因为该值已存储在Jmeter内存中,通过这种方式,很明显Redis数据集在JSR223采样器之前运行。我无法将JSR 233采样器从测试片段中移到更高的级别,因为我需要在测试片段中运行它。

是否存在定义Redis采样器执行顺序的位置? 还是有一种方法可以在Jmeter中定义顺序,以便JSR223在Redis采样器之前运行?

=================================== 更新1

@ Dmitri-t回复后,我对项目进行了如下更新。 enter image description here

enter image description here

2 个答案:

答案 0 :(得分:1)

根据JMeter用户手册的Execution Order章:

0. Configuration elements
1. Pre-Processors
2. Timers
3. Sampler
4. Post-Processors (unless SampleResult is null)
5. Assertions (unless SampleResult is null)
6. Listeners (unless SampleResult is null)

Redis Data Set是一个配置元素,因此将在之前执行

使此operator属性动态化的唯一方法是像这样的overriding it via -J command-line argument

jmeter -Joperator=something -n -t test.jmx -l result.jtl

答案 1 :(得分:0)

我以下列方式工作了

TestPlan
|--Thread group
  |--Module Controller -1
  |  |--CSV Data Set Config - to load operator name(this is going to be reused in other thread groups)      
  |--Module Controller -2
     |--JSR233 Sampler - To read a second level file with ${operator} in its name
     |--For Each Controller - to read through the second level file
     |  |--User Defined Variables  - to split the line from the second level file in to variables
     |--HTTP Request - Action sampler with ${operator} and other variables

Ref:Iterating over a csv file