0

As part of my setUp Thread Group, I plan on creating objects that I need to refer to later on. Some of these objects are to test particular request methods like GET/PATCH/DELETE - things that need a specific ID. I want data separation so that I don't try and GET an item that another request has used to DELETE.

I am trying to work out the best way to extract IDs from the created objects to use in subsequent thread groups. I could write them out to a file, or save them as variables (to then refer to as properties later on).

If I were to write them out to a CSV file, could my subsequent thread groups all use the same file but work through the file intelligently so that thread 1 starts at row 1, thread 2 starts at row 2 etc? If so, how would this be setup in JMeter? Currently, I have separated out the individual GET/PATCH/DELETE requests into different thread groups so I have more control over how many times they execute. I can easily add CSV Data Configs to each thread group but I'm pretty sure they'd all start at row 1...?

The alternatives I've considered are to try and group requests into thread groups but I'd not so easily be able to control thread group numbers.

Hope this makes sense - let me know if not and I'll try and add more info. Any other suggestions for this sort of scenario, feel free to offer them!

3
  • Have you tried using variables, as you said? Variables are meant to deal with things like this. Jul 31, 2020 at 12:38
  • Why can't you use the property variables to use it among the thread groups?Writing the csv file for each request will not be nice practise. It will consume more ram of your system because of this your actual load test will be affected Jul 31, 2020 at 13:57
  • @MohamedSulaimaanSheriff - I have been trying to get property values to work. However, I am adding new items in a loop, which may execute a different number of times depending on what I'm doing. So, for each item added, I will want to extract its ID and save it to a property. I haven't found a way to dynamically name the property - is there a way? E.g. <property name> + <counter value from loop>. If I can do that then I think it should work.
    – Moorpheus
    Aug 3, 2020 at 9:57

1 Answer 1

2
  1. If you want to go for the CSV file you can use the following __groovy() function:

    ${__groovy(new File('/path/to/your/file.csv').readLines().get(ctx.getThreadNum()),)}
    
    • for 1st thread it will return 1st row from csv
    • for 2nd thread it will return 2nd row
    • etc.
  2. It might be better/easier to use Inter-Thread Communication Plugin which can pass data between different threads even if they're residing in different Thread Groups

1
  • Is there an equivalent for getThreadNum() that is able to output the total number of thread groups running? E.g. if I have 1 thread in each group then the above function would read row 1 in thread group 1 and row 2 in thread group 2.
    – Moorpheus
    Aug 3, 2020 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.