Run certain ThreadGroup (or just an action) periodically - jmeter

I've got pretty similar problem as the one explained in this tread.
The problem is that my TestPlan has got several Thread Groups,
which are run consecutively (that is required).
Therefore, I cannot use the suggested solution of 'Add another Thread Group & Constant timer' as this would only work if I unchecked 'Run Thread Groups consecutively'.
So, I need to trigger my 'Take_access_token' thread either every 30min or before every other Thread Group.
I was thinking on applying some of the controllers:
Module or Interleave, but looks like they can apply only to the Sampler execution logic, and not the thread groups.
I'm sure jMeter has to have something.
What am i missing?)
Thanks for any help.

What can I understand from this question is that you want to trigger your thread groups consecutively but before that Take_acess_token should generate some token which will be used by other thread groups.
So my suggestion to achieve this requirement is shown in below snapshot
First apply token thread group with 1 user 1 iteration which will generate token and then save it to property to use it in another thread group then next thread group will perform some activity and once control will come out of this group it'll again enter into another thread group to generate token and similarly do this for other also
Hope this approach should help you!!

Disable "Take Access Token" threadgroup
Add a simple controller under "Take Access Token" threadgroup
Move all the samplers to newly added Simple controller
Now you can add "Module Controller" in start of each of your thread group
Set path to your simple controller in these module controllers
This can solve your issue without any duplication of code.

Related

How do I maintain sessions between Thread Groups in JMeter

I have 5 thread groups (Ultimate Thread Group) in JMeter. When I run the entire test, the samples in the first thread group work fine, those in the second thread group invoke the web sites timeout page, but when the same samples (in the second thread group) are put in the first thread group and the test run, they work fine and do not invoke the timeout page. I realise that I need to pass the session from the first thread group to the other thread groups, please how do I do this?
The following is the cookie data:-
The following are the thread groups:-
If you need to pass data between different Thread Groups most probably your test is badly designed.
Each JMeter thread (virtual user) must represent a real user with all its stuff (Cookies, Cache, Headers, think times, etc). If these 5 business actions are a part of a single used workflow - they need to be put under the same thread group.
Use different thread groups to represent different groups of business users.
If you really need to pass cookies between thread groups it can be done using JSR223 Scripting or Inter-Thread Communication Plugin

JMeter how to load certain group of users

I am loading a csv file with usernames and passwords of users.
Each user belongs to a certain group eg. Group1_user1, Group1_user2,.... Group7_user1, Group7_user2 etc.
I have recorded with my Script Recorder in JMeter the HTTP requests for log in of all the users and then the steps of a HTML stepper process.
Only one group has the permission to complete a step.. there is an hierachy in the groups.
So, my question is.. since I am loading all the users, how am I going to test each step for the users who belong only to the right group?
I cant use plug-in and I cant break my Test Plan into smaller Test Plans.
Normally you should be using different Thread Groups for representing different groups of logical users, so I would suggest moving at least those guys who have permission to complete a step into a separate thread group.
You can implement synchronization and passing data between thread groups if needed using Inter-Thread Communication Plugin
If you have to stay with the single Thread Group you can use If Controller or Switch Controller to conditionally decide which step can be taken by which user.
For example if you use the following __jexl3() function as the If Controller's condition:
${__jexl3("${username}".contains("Group1"),)}
then If Controllers child(ren) will be executed only if ${username} variable will contain Group1
Demo:

How to perform teardown for a specific Thread Group

is there a way to create a teardown for a specific Thread Group in Jmeter? That is, the object "tearDown Thread Group" seems to be executed at the end of each Thread Group in the test. It's possible to bind a tearDown only with a single Thread Group? If not, is there an other object to insert in the Thread Group to achieve that?
JMeter executes Samplers upside down (or according to Logic Controllers) so it's sufficient to put your "teardown" logic to the "bottom" of the Thread Group and the relevant Samplers will be executed "last".
Few more hints:
If you need to run your main logic for several iterations - put it under the Loop Controller
If you need to run your main logic for specific time - put it under the Runtime Controller
If you need to pass some data between Thread Groups you can use Inter-Thread Communication Plugin

Creating multiple thread groups in jmeter Testplan

I want to create 80 thread groups on Jmeter test plan, 1 thread group for 1 user. Can somebody help me with an easy way to achieve this? I'm using jmeter for the first time and the only way i know is to copy a thread group and rename after pasting
Duplicating code is not the best idea, consider using Module Controller
or Include Controller instead, this way you will be able to call a Test Fragment as many times as required.

load test with varying number of threads in JMeter

I am have been exploring JMeter for the last couple of days. And I am try to achieve the following:
I am trying to create a load test for a service such that, in the first loop 'n' threads are created and in the second loop 'n+m' threads are created and in the third loop 'n+2m' threads, in the fourth 'n+3m' threads and so on. I did find many solutions here and I tried replicating them, but somehow it is not working for me. The test plan I created looks something like this:
Step 1: Add a user defined variable called USERCOUNT = 0
Step 2: Create a thread group. I have used __intSum to increment USERCOUNT by one and storing the result back in USERCOUNT for future reference.
Ideally what I am expecting here is, in the first loop one thread is created, in second loop 2 thread are created and in the third loop 3 threads are created. So in total there should be 6 thread created. However the results show up something like this:
Not sure if I am missing something silly or my approach itself is completely wrong. Any help from the community would be appreciated. :)
I believe what you are trying to do is impossible. When JMeter starts a thread group for the first time it initializes the number of threads.
What you are essentially trying to do is re-run the same test three times with different numbers of users each time. JMeter cannot re-run a thread group once started, it can only re-run ("loop") a thread in a thread group. It is not possible to add threads to a running thread group once the ramp up and threads are initialized. (Let me know if I should try to explain that further).
If you want one thread group to populate the run-time settings of another thread group, you must have two thread groups in the test plan. At the test plan level, check off the option "Run Thread Groups Sequentially."
With that option, JMeter will not initialize the number of threads on the second thread group until the first one finishes. The first thread group can set a global property, and the second thread group can reference it in the number of threads.
How to set a property in beanshell: (this would be in Thread Group 1)
props.put("threadgroup_2_num_users","15");
How to reference that value in Thread Group 2:
${__P(threadgroup_2_num_users)}
If this does not help, maybe try to describe your end goal. What are you trying to learn about the thing you are testing?
Edit: Perhaps using the plugin package "Stepping Thread Group" will allow you to achieve the scenario you are trying in a single thread group. Check this out:
http://jmeter-plugins.org/wiki/SteppingThreadGroup/
JMeter currently doesn't provide possibility to change number of threads on-the-fly during test execution so I would suggest to go with the following alternatives:
Use i.e. Ultimate Thread Group available via JMeter Plugins which adds some extra features to JMeter's Thread Group so you will be able to implement your scenario
Consider so called "goal oriented scenario" when load is based on requests per second rather than on number of virtual users. You can precisely set desired throughput rate and even change it during test run using Constant Throughput Timer

Resources