I have a Test Plan that contains the following:
Test Fragment
Simple Controller with label "User Login"
HTTP Sampler with label "User Login to website"
ThreadGroup 1
Module Controller to call Test Fragment - Simple Controller with label "User Login"
TG1 - Sampler 1
ThreadGroup 1
Module Controller to call Test Fragment - Simple Controller with label "User Login"
TG2 - Sampler 1
My problem is jmeter generate the following in jtl file
User Login to website
TG1 - Sampler 1
TG2 - Sampler 1
I can't differentiate "User Login to website" call from each Thread Group.
How to configure jmeter to generate test result for each Thread Group despite using the same sampler from Test Fragment?
something like
TG1 User Login to website
TG2 User Login to website
TG1 - Sampler 1
TG2 - Sampler 1
You can add to User Login Name request the thread group name by adding the following __groovy function:
${__groovy(ctx.getThreadGroup().getName())}
This will group user login per thread group in results
Related
I got a thread group of 10 users. I want to to connect these 10 users to an URL path mysite.com/1.
Then I want to loop a second time on these thread group and connect them to mysite.com/2.
And I need to repeat this process 10 times (i.e until mysite.com/10)...
I there a simple way of achieving that? I've already tried to use counter but what it does is connecting user1 to /1, user2 to /2 and so on...
Add While Controller to your Thread Group and put the following expression to the "Condition" area:
${__javaScript(${counter} < 11,)}
Add Counter test element as a child of the While Controller and configure it as follows:
In your HTTP Request sampler refer the incrementing value as ${counter} where required.
See How to Use a Counter in a JMeter Test to learn how to properly generate incrementing values in JMeter tests.
My test plan is as following
- Test Plan
- Thread Group (No of Threads: 4)
- HTTP Request Defaults
- HTTP Cookie Manager
- CSV Data Set Config(Login Information) [4 user login]
- Simple Controller
- HTTP Request(GET: Open Login Page)
- HTTP Request(POST: Login auth)
- Loop Controller
- CSV Data Set Config(Operation Information) [8 operation data]
- HTTP Request(GET: Open Operation page)
- HTTP Request(POST: Commit Operation)
- HTTP Request(POST: Logout)
In this plan suppose I provide 4 users and 8 operation data.
What it doing is running 8 operation for 4 users each in total of 8x4=32 operations.
How could I make this as following
1st user will do 2 operations
2nd user will do 2 operations
3rd user will do 2 operations
4th user will do 2 operations
I want to provide user session wise different operations that 4 users will do number of transactions but the transactions will not be same.
How can I achieve this?
If I'm getting your test scenario correctly you can just set the "Sharing Mode" of your CSV Data Set Config (Operation Information) to Current Thread Group.
Current thread group - each file is opened once for each thread group in which the element appears
If you want more precise control I believe Switch Controller is what you're looking for, using it you can select which user will go for which execution branch.
See Running JMeter Samplers with Defined Percentage Probability article for more information.
As requested, I am posting my solution. Below is the test plan story.
Test Plan
Thread Group
I used only 1 thread in my thread group and 4 in the loop count as shown below.
Loop Controller
CSV Config for the both the files
Output
I have ${__P(NUM_USERS, 1)}, ${__P(RAMP_TIME, 1)}, ${__P(NUM_ITERATIONS, 1)} values set.
I have this in the script:
Thread Group
HTTP Cache Manager
HTTP Cookie Manager
CSV User Data Set Config
Login Controller
Login Request
API call - Got JSON Response
Beanshell - get some stuff out of response and create a hashmap
Beanshell - Print key and values of HashMap
I am expecting it to run once and exit but it shows the print statement from the beanshell 6 times.
What I am doing wrong?
I've created a BeanShell Listener element in my test plan which I use to collect SampleResult data for each HttpRequest and send to third party software. Presently there are four HttpRequests in my plan:
Get - Hit Login Page
Post - Submit data to Login Page
Get - Hit page to setup session
Get - Hit 'Home Page'
Steps 2 and 3 are related and ran sequentially so from a reporting perspective are essentially '1 step'. I've created a TransactionController around these two elements but my Listener script only appears to be able to retrieve the result data from the second of these two elements. Essentially I want my script to get the total time taken for these two steps for reporting.
Any thoughts?
I can't reproduce your scenario (using JMeter 2.8). Here is how my test plan looks like:
Thread Group
HTTP Request 1
Transaction Controller
HTTP Request 2
HTTP Request 3
HTTP Request 4
Beanshell Listener
My Beanshell Listener has row
log.info(sampleResult.toString() + " - " + sampleResult.getLatency());.
It logs (with omitted log info):
HTTP Request 1 - 143
HTTP Request 2 - 84
HTTP Request 3 - 83
Transaction Controller - 167
HTTP Request 4 - 93
Looks like it works
Apart from the Home page Suppose there are 2 pages i.e page A ,Page B , first step user have to login, then if that user have the permission to view page Page A ,Page B then he can go to those page else on clicking those page name from the top navigational bar user will remain in the home page.
1 login
2 Home [If Login Successful]
|
Check if have permission to view --------- Logout
|Yes
2 Page A
|
Check if have permission to view Page B --------- Logout
|Yes
3 Page B
|
4 logout
Suppose there are 3 users ,i.e user 1 , user 2 and user 3. Now User 1 have the permission to view both page A , page B but user 2 have the permission to view only page A and user 3 do not have the permission to view any of this two pages.
i have used assertion under the page A sampler , page B sampler to check weather correct threads are accessing this pages or not that is system is allowing only the authorized person or not.
in the thread group i have opted if error occur then " stop thread " , thats why if any thread fail to assert then it is not getting counted in the future , thats why in the logout sampler only 1 thread is showing, and that thread is for user 1 because this user have the permission to view both page A ,B . and user 2 and 3 are not considered as they have fail assertion in the previous stages. so is there any way out that in the logout page i can send all those thread which have cleared the login section successfully irrespective of there view page permission.
so at the time of logout in the logout page for user 1 in the referrer field it will show the link of page b but for user 2 at the logout page referrer field value will show the link of Page A. and for user 3 it will be home page.
so can any one please tell me how the referrer field value can be change dynamically based on user permission in the logout page .
This is a possible scenario, as I don't know how you are checking the permissions of the logged users.
HTTP Request - Login
Regular Expression Tester - capture an expected value to validate login
If Controller - If Login OK
HTTP Request - Home
Regular Expression Tester - Referrer to Home (Headers option maybe)
HTTP Request - Page A Permission Verifier
Regular Expression Tester - extract permission validation value
If Controller - If user has permission to Page A
HTTP Request - Page A
Regular Expression Tester - Referrer to Page A (Headers option maybe)
HTTP Request - Page B Permission Verifier
Regular Expression Tester - extract permission validation value
If Controller - If user has permission to Page B
HTTP Request - Page B
Regular Expression Tester - Referrer to Page B (Headers option maybe)
Http Request - Logout
HTTP Header Manager - Referrer: ${referrer}