JMeter - Access TransactionController in Beanshell Listener - jmeter

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

Related

How to keep certain thread delay between requests and store correlation id for all the request during load test

May i know how to achieve this scenario in JMeter.
Requirement 1 : Request 1 should execute for 15 mins, once 15 mins crossed request 2 should execute and request 1 to be stopped.
Requirement 2 : In request 1, we need to capture all dynamic value and store it some place and same dynamic value we should use it as request body for request 2. We like to run large numbers of users. Not sure, how to store all the response in some files or other alternatives.
Ex : Request 1 - > Trigger -> Store response somewhere(15 min run & 100 iteration) - stopped
Request 2 - > Trigger after 15 min - Execute request with above 100 iteration response)
Either take a look at Runtime Controller, using this guy you can choose how long its child(ren) will be run or just put your requests 1 and 2 into separate Thread Groups
If you want to store full responses into a file take a look at:
Post-Processors to capture the required part of the response into a JMeter Variable
Sample Variables property to tell JMeter to save this variable into .jtl results file
Flexible File Writer if you want to write the values into a separate file

Randomised JMeter Test plan

I'm trying to do a randomised interleaved. A cut down version is as follows.
If I have:-
Thread Group
HTTP - A
HTTP - B
Random Controller
HTTP - 1
HTTP - 2
HTTP - 3
HTTP - 4
HTTP - 5
HTTP - 6
HTTP - 7
HTTP - B
I get mostly what I'm after i.e.
A,B,[Random from 1-8],A,B,[Random from 1-8] etc..
The problem is that if I set to 8 runs I don't always get each of 1-8 being run.
What I'm after is a blend with what Random Order Controller does (run each child once) but only one.
The problem with
Thread Group
HTTP - A
HTTP - B
Random Order Controller
HTTP - 1
HTTP - 2
HTTP - 3
HTTP - 4
HTTP - 5
HTTP - 6
HTTP - 7
HTTP - B
Is that it does
A,B,[Randomly run each of 1-8 once] then ends.
e.g.
A,B,7,1,6,3,8,5,4,2 then ends.
What I need is the numeric requests are randomly selected but only run once each with A & B always run as interleaved requests.
e.g.
A,B,7,A,B,1,A,B,6,A,B,3,A,B,8,A,B,5,A,B,4,A,B,2
Thoughts?
Put everything under Interleave Controller and tick ignore sub-controller blocks box:
If you want to run the whole A->B->X sequence 8 times you will need to set the number of loops to 24 under the Thread Group
In general using random execution order is not the best idea as tests should (or even must) be repeatable so maybe it worth considering using Switch Controller instead?

How to run multiple http requests sequentially multiple times

I'm using jmeter for testing. I have 1 thread group setup and multiple http requests under that thread group. Jmeter will run those requests sequentially. But how do I get them to run sequentially multiple times?
My setup is as follows:
Thread Group
-http request 1
* variables
* save file
* results tree
-http request 2
* variables
* save file
* results tree
-http request 3
* variables
* save file
* results tree
I want jmeter to run them multiple times in order. For example I want them to run twice. So I want request 1 to run, then request 2 and then request 3. Then I want request 1 to run, then request 2 and finally request 3.
jmeter test plan
updated test plan
http request defaults
http request defaults variables
http request 1
http request 1 variables
http request 2
htpp request 2 variables
Put the loop count to 2 in the thread group and then it will run in sequence twice.
Please check below:-
Updated:-

Jmeter user session wise different data set

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

Why JMeter running thread 6 times when property value says 1

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?

Resources