4
votes

I want to create a Thread Group in jmeter to create users and their devices with many (for example 5000) devices.

I have no problem to create this test and I want to have the name of the users and device in a correlative order.

1. user1--device1 
2. user2--device2
3. user3--device3

I already created the test but to create 5000 users and devices in the same Thread Group I need to run 5000 iterations with 3 requests each, using 1 thread, because otherwise I have the same user name repeated by multiple threads (for example with 3 threads)

1. user1--device1 
2. user2--device2 
3. user3--device3 
4. user1--device1
5. user2--device2
6. user3--device3
7. user1--device1
8. user2--device2    
9. user3--device3

My question is: is there any way to share the loop counter between threads in order to create 5000 users/devices with more than one thread (for example 20 threads). This will help me a lot because instead of waiting for 20 minutes, it will be a minute to create the users.

Many thanks!

http://pastebin.com/S1izFC9r

Added explanation I want for example maximun 9 devices (counter_max) but I want to run it with 3 threads. I want the result be like that

  1. thread1--user1-device1
  2. thread2--user2--device2
  3. thread3--user3--device3
  4. thread1--user4--device4
  5. thread2--user5--device5
  6. thread3--user6--device6
  7. thread1--user7--device7
  8. thread2--user8--device8
  9. thread3--user9--device9
1
Sure, just have a Counter with "Track counter independently for each user" unchecked and it will track counter for all threads. Or share your plan to see what you are currently doing.Kiril S.
I had simplified the script at maximum in order to copy here. It only create tenants (users). The order part is not a problem. I want to create consecutive tenants in different threads. I just attached the fileGuel135
As I told you earlier, you need to uncheck "Track counter independently for each user" option in the counter. In your script I can see that it's checked: <boolProp name="CounterConfig.per_user">true</boolProp>Kiril S.
I had already try with this to false before put the reply and it doesn't work. I will try again in one hour when I arrive to home. many thanks!Guel135
Hello Kiril, I already try and the counter works at the same, I want to make for example. I think I am not well explained what I want. if I put for example max counter to 3 and I have 3 threads in the thread group I want it to work like (added to general question)Guel135

1 Answers

1
votes

I think you can implement it using __counter() function in "global" mode, like: ${__counter(FALSE,)}

  • __counter() function returns incremented value each time it's being called
  • in the "global" mode counter value is shared across threads

Counter Global Demo

So you should be able to use as many threads as required and each thread will use the next counter value to create your users and devices with multiple threads.

See How to Use a Counter in a JMeter Test article for comprehensive information on using "counter" config element and function.