Search code examples
redisjmeterbeanshell

Connect Jmeter to Redis with Beanshell


I want to connect Jmeter to Redis DB, I want to do it via java programming. I added jedis-2.2.1.jar file to lib folder. and create a test plan with only bean-shell preprocessor. I can not understand what I can see, since nothing happened, and the response tree is blank, Can someone please advise how to connect to redis via jmeter (please without the redis plugin)

Provided the Pic of the program, it is a simple program just want to connect.

** I am new in java scripting in Jmeter and the only jar I added is jedis.jar, the program is a script from the net. not created thread group in the test plan

with void main it is not worked also

enter image description here enter image description here


Solution

    1. You need to add a Sampler to your Test Plan. PreProcessors are executed before samplers, single PreProcessor won't do any work as it will simply not be executed. So you either need to add a Sampler to your test plan or convert your PreProcessor to be a Sampler
    2. Since JMeter 3.1 it is recommended to use JSR223 Elements and Groovy language for any form of scripting. The reasons are in:

      • Groovy performance is much better as it is capable of compiling scripts and caching them
      • Groovy fully supports Java syntax, valid Java code most likely will be valid Groovy code while with Beanshell you are stuck with Java 5 language level
      • Groovy provides many enhancements on top of Java SDK

    See Apache Groovy - Why and How You Should Use It article for more information, benchmarks, examples of real-life Groovy usage, etc.