How to get data from Redis' Hash data structure using JMeter

419 Views Asked by At

I am QA using JMeter 5.3 with installed Redis Data Set (version 0.3). In my tests I want to get data from Redis database, using Redis Data Set. Problem is that data are stored in the Hash data structure, but Redis Data Set doesn't support Hashes (only Lists or Sets). My question is: is it different way to get data from Redis' Hash via JMeter or it's not possible for today? Do you know if there are any plans to add Hashes support to this plugin? Thank you in advance for answers. Best regards.

1

There are 1 best solutions below

0
On

You have 3 options:

  1. State that it is not possible

  2. Try to reach out to Redis plugin developers/maintainers via JMeter Plugins Support Forum and ask to implement this functionality asap

  3. Use JSR223 Test Elements and Groovy language to read the data from Redis hash entries, it can be done relatively simple. Assuming the example given here

    HSET myhash field1 "Hello"
    

    you can read the value in any suitable JSR223 Test Element as:

    def jedis = new redis.clients.jedis.Jedis('your_redis_host', your_redis_port)
    def value = jedis.hget('myhash', 'field1')
    

    Demo:

    enter image description here

    More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It