How to attach labels (from user defined variables) to jmeter response data? - jmeter

I want to compare results of two sql queries of the following type
select count(*) from X where userid='${userid}'
where X is some subquery (different in both actual queries).
I want to check whether both of these queries return the same resultset using jmeter.
Hence, I created two jdbc requests in the thread group, and I supply the userids through a set of 50 userids stored in a csv file. All this works fine.
The core problem is that I have two samplers in a thread group, and I want to compare their results. I came across a similar question, which suggests to use a post-processor to store the response into a file.
However, being a newbie in JMeter, I could only manage to create 2 post-processors (1 for each request ) which write "prev.getResponseDataAsString()" to different files.
I get the following output, in one of the files
1
0
1
0
1
93583
1
42456
1
37033
1
37033
1
93583
It is clear from this result, that I have no idea which thread produced which result in the file, which brings me to my question.
How do I attach labels to jmeter response data?

There is a sampler called a "Debug Sampler"
And a counter config in your threads, so for each thread the count is incremented
If you add that debug sampler and change the title to "Debug printout Thread ${counterThread}"
Then that will show up in your view results tree

You can store result sets into a JMeter Variables and use i.e. Response Assertion or Beanshell Assertion to compare two variable values. Depending on response data type the approaches may differ.
Check out Debugging JDBC Sampler Results in JMeter article to learn how to work with JDBC test elements results, if anything remains unclear update your question with more details.

Related

How to update the array values from existing based on the condition and again pass same array with updated array element

We are using for each control to iterate an array based on matchNr count. First time My application is sending all reports call to server together , next time after 10 sec delay again my application sending the same reports calls which are not get completed in first time and so on.
Ex. suppose application is having 10 reports then first time 10 requests goes, then again same request goes by eliminating the completed one (this request count should be less or equal to earlier one)
Note:
Application is having different report count for each users. we can not put fix reports to all users.
Request is same here, only application is adding report name in the body part of the request.
We are trying to simulate chrome behavior with Jmeter during load test.
Array is having the total report count[image1]
request is same only parameter is getting change for each request[image2]
ForEach Controller doesn't execute its children "together"
We are not telepathic enough to guess how does you "array" look like and how exactly you want to "update" it
If you have JMeter Variables in form of:
foo_1=something
foo_2=something else
....
foo_matchNr=number of matches
and want to update the variables with some "new" values there are 2 options:
Set Variables Action sampler (can be installed using JMeter Plugins Manager)
Or any suitable JSR223 Test Element, any of them has vars shorthand for JMeterVariables class instance providing read/write capabilities for JMeter Variables in current thread's scope.

Passing property between threads in Jmeter

In J meter, I am unable pass property from thread 1 to thread 2 if there is JDBC request in thread 1. If there is no JDBC request, property is getting passed from thread 1 to thread 2. Any specific reason for this, Any changes i need to do? kindly help me on this.
Passing values between Thread Groups is not something you should be normally doing, I would recommend reconsidering the design of your JMeter script so it would not be required
There are several ways of passing values between different thread groups starting from using __setProperty() and __P() functions combination, using interim CSV files, and ending up with Inter-Thread Communication Plugin, they all should work irrespective of presence/absence of the JDBC test elements in this or that Thread Group
When anything goes wrong in the absolute majority of cases JMeter will print something to jmeter.log file, first of all check it for any warnings/errors and if they are not there - check the variables/properties values using Debug Sampler

Using JMeter PreProcessor and User Variables logic

I am new to JMeter and it maybe a stupid question but I still find it hard to understand the concept here.
I have a simple test.
Thread Group with a Single thread with loop count of 2
PreProcessor that place two
variables on the vars map
A loop that execute a request twice based
on the PreProcessor parameters
I expected that the preprocessor will initialize the parameter and it will use the same values twice in the request.
It looks like it’s executing the PreProcessor once pair call.
When I switch the PreProcessor with similar User Defined Variables it reuses the same value on every call.
Can anyone explain the logic here?
I am using JMeter 2.11
A PreProcessor is executed each time the HTTP Request is executed so if you have a total of 2 iterations, you should see log twice, you have it 4 times so maybe number of iteration is different than what your write or you have 2 threads.
When you use User Defined Variables, the value is computed once and then reused. Value will be different per thread.
After reading the documentations and with #UBIK LOAD PACK help I used User Variables and it worked
User Variables - are specific to individual threads.
Pre-Processor is attached to a Sampler element (e.g. http request in our case), then it will execute just prior to that sampler element running
So 4 request for different parameters because it runs before every request
User Defined Variables - It is processed at the start of a test, no matter where it is placed. For simplicity, it is suggested that the element is placed only at the start of a Thread Group. This is why I get the same value all the time

Clarification on Regular expression Extractor and CSV Data set config

Question 1 ) I am reading user credentials from a CSV file and trying to simulate concurrent 3 user login scenario like below.
My csv file data is like below, each in a new row. The problem now im facing is all requests are useing credential_001 if I use Attached ( thread group Settings .JPG) thread group settings. but if I make it to loop count 3, then it sends login requests for 3 users. What is wrong in my approach. please advice
credential_001
credential_002
credential_003
[http://i.imgur.com/FNXTMvA.jpg][1]
Question 2 ) When I capture 3 session tokens in first authentication cycle, I wand to use that 3 requests in next 3 requests. How can I do this ? is it posible to do like this. with my current approach it is always send the session token of first authentication in later http samplers.
[http://i.imgur.com/vhJrGt3.jpg][2]
below is the regular exp extra im using , and Im using ${SessionGuid} in later http sampler
Question 1
Consider switching to __CSVRead() function as CSV Data Set config switches to next row on next iteration, not on next thread. Example CSVRead configuration will look like:
${__CSVRead(/path/to/file/with/credentials.csv,0)
Question 2
Consider using __threadNum() function together with ${SessionGuid} variable, this way you'll be able to get
SessionGuid1 for the first thread
SessionGuid2 for the second thread
You can evaluate SessionGuid1, SessionGuid2, etc. variables using __V() function as follows:
${__V(SessionGuid${__threadNum})}
For extended information on above and more functions check out How to Use JMeter Functions post series.

Comparing results from two samplers in JMeter

I have several samplers in a thread group, each retrieving a piece of information. I then need to validate the consistency of the results from two different samplers. In particular I need to assert whether a field in one sampler response equals a field in the JDBC response. What is the best way to do something like that?
I have thought about adding a beanshell postprocessor to each sampler in order to extract the field value from each sample and save it in two variables and then adding a beanshell assertion that accesses those variables, but I wonder if there is a more direct approach.
In the JMeter API documentation I could not see anything to access another sampler response other than the previous one.
I posted the same question on the Jmeter user mailing list and from the feedback I got it seems that indeed it is not possible to access the result of another sampler than the previous one.
The answer is then to save each sampler response in a variable via a postprocessor so that it can be used later.

Resources