Multiple user login to iterate through a sequence of threads in JMeter - jmeter

I have to simulate multiple user logging in and going through a sequence of web services in JMeter. The web services are-
1.login
2.startjob
3.endjob
4.logout
I have 10 users and all of them will simultaneously login and run through the steps 1-4.
The steps are-
User will login using "login" service. They will get a session token (ST) in the response.
Using the ST from above step the user will start the job using "startjob" service
After the job is finished, "endjob" service is used.
Finally user is logged out using "logout" service.
So far I have been able to do the above steps properly for one user.
I have created a CSV file with 10 usernames and passwords and am able to make only the "login" service iterate through all users using CSV Data Set Config.
How do I make each individual user go through steps 1-4?

In JMeter, each individual Thread or User will execute every sample within it in upside-down order. So for a single user, when we run the test, the result will appear in that order. But Ramp up time is related to Thread creation:
How long JMeter should take to get all the threads started is the
Ramp up time.
Within this time, all the users will be initiated and all those Threads will execute the samples underlying it in the same fashion as it does for a single user.So in you case, all the 10 thread will go through steps 1-4, but the threads will initiate within your ramp up time.
If you observe the output in View Results in Table listener and trace the Start Time of the samples for a corresponding Thread, you will see that those samples are executed through the steps of 1-4.
For an example, I have 4 samples under my Thread Group and I have defined Threads or Users : 3 and Ramp up : 5. All those three Threads executed the samples Through 1 to 4.
Image here:

Related

jMeter how to make user wait until the previous loop is done

I am new to jmeter, so please bare with me if I have asked a silly question. I have a thread where I want to run that thread like 100 times. In the thread I have scripts like
Add a member to a mailbox,
Get the mailbox details and confirm the member added was displayed
update the member role in that mailbox
Delete the member from that mailbox
I am using same mailbox and user for my test for my loop. Here the issue is the same member cannot be added to the same mailbox unless we delete that member from that mailbox.
So when I run the test with just 5 iterations, the add script for first iteration was passed and next 4 iterations for that add script getting failed. Because the first thread already added the user to that mailbox and while the second user tries to add the same user it fails, that's expected.
Steps I tried:
I even tried using constant timer in my add script to wait for 4secs so my previous user actions should be done. That's my understanding. Please correct me if that's wrong.
The other thing I tried was ramp-up time to 8 secs and then the script for 5 users ran fine. But when I increase the users to 50 then almost 50% of the scripts failed.
Here comes my problem. How do I make the second user to wait until the first user done with the delete script, so second user can use the same data and so on.
Attached are some screens of my scripts
Please let me know if you need any other information.
Thanks
Each JMeter thread (virtual user) should represent a real user with its own credentials and mailbox. Credentials and/or mailbox can be parameterized, normally people use CSV Data Set Config to provide test data for JMeter scripts
If you have only one user/mailbox - you won't be able to use more than 1 thread (virtual user) in the Thread Group, to wit if you need to run the scenario 100 times - you need to set it up like:
Another option is using Critical Section Controller. But be aware that there will be no concurrency (only 1 user will be running the test at a time), if you need to have more - you will need to use different credentials for different users

jmeter - I would like to know if it's possible to have login as part of the set up and logout as part of tear down for 250 concurrent users

I have scenario where I want to run load test for 250 users.
Ramp up time is 10 mins for 250 users and run test for 50 min duration.
Question 1 : Is it recommended to do login and login out as part of set and tear down .. as the dev team does not measure login and log out .?
Question 2 : How do i keep the the other thread group in loops during the 50 min duration . ?
I wouldn't go for it as normally different thread groups should represent the different groups of virtual users, setUp thread group is for accomplishing the pre-conditions for the test and tearDown thread group is for cleaning everything up. If you perform the login in the setup thread group - there will be negative consequences like having to pass login context (tokens, headers, cache, etc.) to other thread groups. So I would rather move login to be the integral part of the main thread group and if needed remove login/logout via Filter Results Tool (not part of vanilla JMeter, can be installed using JMeter Plugins Manager)
It can be done on either on Thread Group level like this:
or you can "loop" the arbitrary part of the test by putting it under the Runtime Controller:

Apache Jmeter Load Test to achieve that only one thread starts until test achieve the desired number of users

I have implemented a testplan in Apache Jmeter to measure how the system serves the request with XY users.
Steps:
User Login via a web browser with username and password
After the login, user click on the given link which starts a job on the server
When I configure thread group with the GIVEN number of users I can see the Jmeter stars thread within the given time range. Like this:
1 user --> starts 1 job
2 users --> starts 1 + 1 job
3 users --> starts 1 + 1 + 1 job
...
So When the test ends I have 6 started job instead of 3 :(
So my question is:
How it is possible that every time starts only one job within the given time range to achieve the predefined user number?
For example:
If I have 10 users I would like to see only 10 started jobs at the end of the test.
If I have 100 users I would like to see only 100 started
jobs at the end of the test
Here is the Expected Active Users Count, where you can see that when the test achieved the 10 users there are more than desired job started because the active users' number increased +1 after the previous thread ends.
Expected Active Users Count
If you need to execute a job by a user only once it's better to consider switching to the "normal" Thread Group configured like:
If you want to continue using the Ultimate Thread Group - put your request(s) which trigger the job creation under the Once Only Controller, but in this case you will see a lot of error messages in the jmeter.log file (which can be supressed if you're fine with this approach)

Multiple user login in JMeter

I am trying to perform load testing on NodeJS application, the application allows single login session for an user.
But, when i tried to perform load testing with 8 concurrent users (using the same credentials) it was working.
So, i tried to create 10 user IDs and added to the CSV file and configured "CSV Data Set Config" and "HTTP Cookie Manager" and set the "Number of Threads" to 80.
When I run the test plan, the credentials are not passed to each sessions equally. for example, userID1 is passed 3 times and userID2 is passed 7 times.
Can you clarify the reason for this behaviour and how to run the threads with each credentials (8 sessions for every credentials) from csv file ?
Make sure you have set the options for CSV Data Set Config as All Threads for Sharing mode and provide a minimum ramp-up period (say 1 second) so that each thread reads the CSV lines properly without clashes.
For the question why it worked 8 concurrent sessions , where you allow only single session from UI - My guess is you used the same credentials for all 8 users - so server might have considered it to be 8 parallel requests from the same user. It depends on how session is maintained. For eg., if it was with a session-cookie , then If you had 8 different cookies it might have failed. But this is only a guess, as I don't know how its done in your app.
JMeter acts as follows:
All threads are started within the bounds of the ramp-up period which you define in the Thread Group
Each thread starts executing Samplers upside down (or according to the Logic Controllers) as fast as it can
JMeter waits for previous request to finish before starting next Sampler
When the thread doesn't have any more Samplers to execute and loops to iterate - it's being shut down
If you observe the situation when this or that logic was used more than another, most probably the response time for the login was less.
You might want to check the size of the response as for successful requests it should be more or less the same and it might be the situation when the server returns HTTP Status code 200 but response body contains errors, to wit some logins may fail silently, if this is the case it makes sense to add a Response Assertion to add some extra checks, i.e. presence of "Welcome" text or "Logout" link or absence of "error" text or whatever.
What i could understand is you are trying to achieve 8 session each user.in order to do that you have to make 10 concurrent threads and 8 iterations that is how you will achieve 8 session for every credentials.
But of your requirement is to run 80 concurrent users then try to make 80 users and run the test.

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.

Resources