JMeter ordered execution - jmeter

I am setting up a project for performance test a REST application. I need to create N records in a file (productName, category) and hit an endpoint to add them.
Under Test Plan, I created a ThreadGroup, Loop controller and beanshell sampler to create the file.
ThreadGroup
-LoopController
--Beanshell Sampler
Add Product (ThreadGroup)
-Add Product (Http request)
--Http Header Manager
--CSV Data Set Config
-View Results in Table
I want to create N records before I want other ThreadGroup to start picking records but I am unable to figure it out how.

As far as I understand you just want to run the thread groups one by one, so in Test Plan there's an option you have to tick, and it's called 'Run Thread Groups consecutively' (click at the top of the tree on the left where you see Test Plan name and check its options on the bottom in main part of the window).
The other approach that is far more better is to use 'setUp Thread Group' (Add -> Threads -> setUp Thread Group) to run the setup at the beginning and then the rest of the test from other Thread Groups in parallel.
I hope it helps.

Related

Running Jmeter Test in multiple accounts parallelly

I have set of sampler under one Thread Group as
TestPlan
ThreadGroup
SimpleController
Login(HTTP Sampler)
FetchCSRFToken(HTTP Sampler)
LoopController(Count -> 5)
Testcase1(HTTP Sampler)
Testcase2(HTTP Sampler)
Testcase3(HTTP Sampler)
Now I got a requirement to run the above test cases in multiple accounts parallelly.
I googled and find out having Multiple Thread Group is a better idea since I suppose to run it parallelly and I have to pass CSRF token in all test cases header.
Is it possible to have two thread groups without duplicating the test cases inside Loop Controller of Thread Group-1 to Thread Group-2?
Kindly suggest if any other way as well.
If you want to avoid code duplication - just put the "shared" code under a Test Fragment and reference it using Module Controller(s) where required
In general a Thread Group should represent a logical/business group of users, if you just need to add more users doing the same actions - you can parameterize credentials, URLs, parameters, etc. so each thread will use different set of data on each iteration, the most commonly used approach for parameterization is CSV Data Set Config

How can we ask jmeter to process the next record which has unique number

I need to click and submit a sequential record in my application every time a concurrent user logged in. should not select a same record because the submit button wont available for the same record if the concurrent user tries to select. I do have 40 pages which jmeter should automatically select next record every time user logged in. Per page 10 records will be there, and 300 concurrent users will logged in.
Please advise what need to mention in bean-shell?
JMeter doesn't "click" any buttons, it acts on HTTP protocol level therefore you need to investigate what network request does "button click" cause and what are the differences between them.
Most probably it's a matter of simple correlation, so you need to do something like:
Add setUp Thread Group to your test plan
Add HTTP Request sampler to the setUp Thread Group and configure it to iterate 40 pages and extract the unique numbers (or other unique button identifiers) using the suitable JMeter Post-Processor and store them into JMeter Variables. You should end with something like:
VAR_1=unique_number_1
VAR_2=unique_number_2
...
VAR_400=unique_number_400
Add JSR223 Sampler to the setUp Thread Group and use the following Groovy code to convert the variables to JMeter Properties
SampleResult.setIgnore()
vars.entrySet().each { variable ->
if (variable.getKey().startsWith('VAR_')) {
props.put(variable.getKey(), variable.getValue())
}
}
That's it, in the main Thread Group you can use __P() and __threadNum() functions combination so each thread (virtual user) will get its own "button" to "click" like:
${__P(VAR_${__threadNum},)}

Performing many tests in 1 test plan

I need to perform tests on hundreds of HTTP links one after the other.
That means i want to, for instance, perform a 3 minute test with 5 users on 1 link and after that's done, do the same for the next link.
1 way to do this is to create a ThreadGroups for each link, each having a HTTPsampler and just have all of the run consecutively. But i read that that would create memory problems for the testing machine.
So what is the correct way of doing this? I really don't feel like creating and manualy running a separate TestPlan for every link.
You can use only one HTTP Request sampler, the suggested Test Plan structure:
Thread Group with the number of threads (virtual users) you want to simulate
CSV Data Set Config containing the list of URLs
Runtime Controller configured to last 180 seconds
HTTP Request sampler configured to hit the URL:
This way you will hit 1st URL for 180 seconds then 2nd URL for 180 seconds, etc.
For the problem you have mentioned you can create single test plan instead of multiple test plans and add multiple thread groups inside it and make sure that run thread consecutively is checked.
In each thread group mention the thread count and test duration as mentioned in the example below.

JMeter Test Plan settings

I am new to JMeter. I'm using JMeter version 5.0.
I have created a new Test Plan. Test Plan has a few settings.
Can you please explain the use of each checkbox?
Checkboxes are:
1) Run ThreadGroups consecutively(i.e one at a time)
2) Run tearDown ThreadGroups after shutdown of main threads.
3) Functional test mode(i.e. save Response data and Sampler Data)
When trying to understand JMeter, go through its component reference (below)
You should keep the defaults unless specific case is needed.
Functional Testing is not recommended/needed unless you are debugging (and also not needed usually)
teardown/setup groups are useful for setting/cleaning tasks in test.
And usually you want run multiple Thread Groups serially rather than in parallel.
Selecting Functional Testing instructs JMeter to save the additional sample information - Response Data and Sampler Data - to all result files. This increases the resources needed to run a test, and may adversely impact JMeter performance. If more data is required for a particular sampler only, then add a Listener to it, and configure the fields as required.
The option does not affect CSV result files, which cannot currently store such information.
Also, an option exists here to instruct JMeter to run the Thread Group serially rather than in parallel.
Run tearDown Thread Groups after shutdown of main threads: if selected, the tearDown groups (if any) will be run after graceful shutdown of the main threads. The tearDown threads won't be run if the test is forcibly stopped.
1) Run ThreadGroups consecutively(i.e one at a time)
In a test plan usually, you would have different thread groups ( user groups ) sending requests to different services. For example
Thread Group 1 > Load and Login to the System
Thread Group 2 > A Form Submission in the System
Keeping the above-mentioned thread groups, if you have selected Run ThreadGroups consecutively option it will run The Thread group 1 first and then move to the second one. If not there will be a parallel execution of all active Thread groups.
2) Run tearDown ThreadGroups after shutdown of main threads
There is no difference in a normal Thread Group and a Teardown Thread Group when it comes to the functionality. You can specify the Post-Test actions in the Teardown Thread Group and use Run tearDown ThreadGroups after shutdown of main threads to execute them after the normal thread Group Execution
As an example if you have created a user profile for your performance testing purposes and if you want to remove the user after the test execution. You can create the request to delete the user in this thread group
3) Functional test mode(i.e. save Response data and Sampler Data)
When you run a huge set of requests I recommend you to NOT to use this. The reason is if you have selected this option it will include all the request and response data (including HTML, etc. ) in your log files. ( Normally it won't record your response and sampler data ) Even if you run the test in NON-GUI mode the log file would be few GBs if you have selected this option. So it's better to use this if you are debugging or running a less number of users in your test.
Run ThreadGroups consecutively(i.e one at a time)
If your test plan contains two thread groups i.e ThreadGroup-1 and ThreadGroup-2.
If above property is unchecked -then the active threads from both the thread group
will run parallel and
if checked - That means JMeter will start ThreadGroup-1 first, then ThreadGroup-2 and so on.
So by using this property you can instruct JMeter to run the Thread Groups serially.
Run tearDown ThreadGroups after shutdown of main threads
By default JMeter always run tear down thread group after completion of normal thread group. But if there is any failure in the above thread group and threads stopped due to some reason. Then this tear down thread group will not run. But if this property is checked then tear down thread group will always run.

Run certain ThreadGroup (or just an action) periodically

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.

Resources