Jmeter throughput controller actions run per iteration - jmeter

I have the following scenario.
HTTP Cookie Manager - clear cookies after each iteration
Login http action -> 30%
Show profile (the user must be logged in) -> 20%
Purchase (the user must be logged in) -> 50%
The problem is, in presence of throughput controller there is no guarantee that per iteration the user will be logged in before any other action that requires the user to be logged in, so after any iteration the cookies will be cleared which means the session will be invalidated, there is a probability the the action will fail since no user logged in.
Taking into account the clear the cookies is a need.
If there is a way like per each iteration the login will be triggered once and the other actions will be repeated to target the throughput controller.
Is there any idea that is suitable for my scenario using jmeter?

Your scenario does not make a lot of sense as given the user needs to be logged in in order to perform Show profile and/or Purchase tasks you should perform login for 100% of users before viewing the profile or making the purchase. So I would recommend moving your Login http action outside the Throughput Controller like:
Login http action
Show profile
Throughput Controller
Purchase
Throughput Controller
Another option will be using Switch Controller, this way you will get confidence that each child test element will be executed at least once. Check out Running JMeter Samplers with Defined Percentage Probability article for more details.

Related

Less Data is getting inserted database after running Jmeter script

I recorded .jmx script by recording Blazemeter tool.
I followed below steps:
Login into application.
By default user landed on page which is Search Page where Patient list is displayed.
Now I select Patient and Navigate to Flowsheet page by clicking on HD Flowsheet menu button. Patient selection is mandatory.
Saved Flowsheet.
Logged Out.
Thread Group Detail:
Action to be taken after a Sample error: Continue
Number of Threads(users): 10
Ramp-up period (seconds): 100
Loop Count: 1
Same User on each Iteration : Yes
After executing script with above Thread group, In database only 6 Flowsheet is getting inserted instead of 10 flowsheet.
I checked View Result Tree, It is showing no error and also in Summary report it is showing 0% error.
What can be root cause? What strategy I should follow in such cases to debug script?
JMeter automatically treats HTTP response status codes below 400 as successful, it won't do any extra checks for the "flowshit" creation or insertion simply because it doesn't know anything about it.
My expectation is that your test silently fails somewhere, add View Results Tree listener and inspect response details for each step, most probably you will see that either you're submitting the same flowsheet over and over again or your script got stuck somewhere.
If you want to add an extra layer of verification, i.e. ensure that response contains specific value, you can add a Response Assertion to each request and specify pass/fail criteria there
In general when it comes to modern web applications the chance you will be able to successfully replay recorded script is close to zero because there are multiple dynamic parameters involved like ID of the patient or flowsheet, cookies, tokens, etc. and these dynamic values need to be correlated

How to control no. of requests per user in Jmeter

I am doing load testing for one ecommerce website. I am using Ultimate thread group.
Now I want to send per user only 1 request. So for ex: If 500 users then only 500 request should send. How can I achieve it using Ultimate thread group?
Why I want above because I am doing whole process like login, select product, add to cart and checkout. So it should do everything only once per user.
Your test design is a little bit flaky as given each user does login, select product, add to cart and checkout you will have at least 4 requests per user which gives 2000 requests in total (doesn't include embedded resources calls). You can use Transaction Controller to group these requests into one "workflow" however it won't limit actual amount of requests.
If you need to run your workflow by each user only once you may run into a situation when either load will be less than 500 concurrent users or test duration will be less than 30/60 minutes, see JMeter Test Results: Why the Actual Users Number is Lower than Expected
If you add more iterations each user will be executing your workflow more than once
Normally web test plan should look as follows:
Given each user executes test scenario steps and acting like a real user
Gradually increase the number of users unless application response time becomes too high or errors start occurring, whatever comes the first
Analyze results, identify the bottleneck, report your findings
Lets say the duration of the test is 1 hour. First user completes the workflow you had mentioned in the first 10 mins itself. What should happen after the workflow for the user? Should the thread be idle for the remaining 50 mins?
I think you should use the regular Thread Group with 500 threads and loop count as 1. Ultimate Thread Group is for duration based tests. You could use Once Only Controller as a workaround inside to do the action only once for the user. But it is an ugly approach.
You can use Throughput Controller.
The Throughput Controller allows the user to control how often it is executed. There are two modes:
percent execution
total executions
Percent executions
causes the controller to execute a certain percentage of the iterations through the test plan.
Total executions
causes the controller to stop executing after a certain number of executions have occurred.
Like the Once Only Controller, this setting is reset when a parent Loop Controller restarts.

Only repeat request per data set row

Currently I am setting up performance tests with visual studio. I have a data set containing 30 rows.
My test scenario is intended to be as follows:
User logs in
Visits 30 URLs defined in my data set
User logs out
With the default functionality, the scenario does:
User logs in
Visits URL 1 defined in my data set
User logs out
User logs in
Visits URL 2 defined in my data set
User logs out etc.
This happens 30 times in total.
Is there a way to only repeat the step where the data rows are referred to?
Thanks!
There are at least two approaches.
First approach. Have three tests. One for logging in and a second for logging out. The third test has the main activity which is to visit one URL and it will be data driven. In the load test specify the load test mix to have the login and logout tests as the initialisation and termination tests, the main test will be added to the test mix. Set the "percentage of new users" in the scenario properties to be 0%.
Second approach. Have just one test with the login and logout at the start and finish of this test. Between them have a loop that visits the URLs specified in the data source. Set the "advance data cursors" property of the loop to true.

Issue with throughput controller

my thread count is 100 and iteration count is 100 .50 users are registred users and 50 users are guest users.
home page -5%: This page should run for 5 % total hit of both guest and logged in user irrespctive of user type.
Login page- 50% : This page run for 50% of total hit.
Search page 20%- This page should run for 20 % total hit- This can be run for guest as well as logged in user.
product page 15%- this page run for 15 % total hit-This can be run for guest as well as logged in user and this prequest is using parameters from search page(3rd request)
Add to cart 10%- This page should run for 10% of total hit- For performing this request i need to make sure that user is already logged in user and parameters are captured from search page reques(3 rd request)
I wan to create test plan for the above condition
For me, the question itself is not fully understandable.
As it not possible in single Thread Group to achieve the requirements, Following is the Test Plan you can try out to achieve the dependencies along with the percentage of distribution. This is NOT a correct solution but I claim it as a probable solution. You can customize as per your needs.
Test plan
...Thread Group (configure 100 users)
......HTTP Cookie Manager
......Throughput Controller (by percentage throughput - 5%, uncheck Per User checkbox)
.........Home Page (Transaction Controller)
......Throughput Controller (by percentage throughput- 20%, uncheck Per User checkbox)
............Search Page (Transaction Controller)
......Throughput Controller (by percentage throughput- 15%, uncheck Per User checkbox)
............Product Page (Transaction Controller)
......Throughput Controller (by percentage throughput- 50%, uncheck Per User checkbox)
.........Login page (Transaction Controller)
............Login Request (HTTP Sampler)
.........Throughput Controller (by percentage throughput- 20%, uncheck Per User checkbox)
............AddToCart (Transaction Controller)
......Aggregate Report
Important Notes:
Added Throughput Controllers as a parent of Transaction Controllers to control the percentages. Uncheck Per User checkbox.
Transaction Controller contains the HTTP Samplers. eg: Login Transaction contains all the HTTP Samplers that are responsible for Login operation.
Add Aggregate Report listener under Thread Group, to capture all the request results.
Image reference:

Jmeter concurrent user load Test Plan

I am new to Jmeter. My project Manager said to me to test the website load with 100 concurrent user.
Following functionality of website considering to load test-
User Registration
Get Registration Page Request
Post Registration Page Request
Login and User profile navigation
Get Login Page request
Post Login page request
Get User Dashboard request
Get edit Profile page request
Get change password request
Get Invite Friend Page request
My Test Scenario is 50 concurrent user Accessing Registration page and other 50 concurrent user accessing User profile(login,dashboard, etc) .
I have created following test plan for the same -
And did thread configurations for registration and Login same as -
Total No of Threads : 50
Rampup period : 600 sec
Duration of holding load : 3600 sec
Configured constant timer (delay for each request 200 ms) for both Thread Group requests also added some listeners for collecting the result. I have following question -
Is it correct way to include these many request in test plan for complete load test of My website ?
Do I have configured right thread properties or what else I can do for achieve the best ?
Think Time
Your test plan looks good, however the current configuration doesn't represent 100 concurrent users as 200ms think time is something for "superhuman". Real users "think" for a longer period between operations and it should vary depending on the nature of simulated request. So I would suggest using individual Uniform Random Timers with the relevant think time ranges for each request.
Overall Test Design from the "reality" perspective
If you have some extra time you could think about bringing more reality into your simulation like:
X users perform registration
Y users editing their profiles
Z users inviting friends
etc.
So distribution would represent normal anticipated usage of your application. Your load test should be as realistic as possible, only this way you will be able to tell for sure "my application is able to support this many users providing reasonable response time". Take a look at Throughput Controller
Overall Performance
Disable Active Threads Over Time and especially View Results in Table listeners during test run
Configure PerfMon Metrics Collector listener to store the captured values into a file. Later you will be able to open the file and analyze the metrics
Run the test in non-GUI mode
follow other recommendations from 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure

Resources