How to find gap in API response - JMeter - jmeter

I am new to JMeter and scripting overall.
Here's my scenario - My response from the HTTP request generates data every second and the response gives the timestamp along with other data. I have to identify if there is any gap in the timestamp sequence just to identify if there is any gap in the data overall.
Example of my response is attached (timestamp highlighted).
How can I achieve this? The whole idea is that the data should be present for every second, and missing data needs to be identified.
Post Note - There will be thousands of rows depending on the start and end time I am passing in the request, but since JMeter limits the data row to 1000 rows only and my data is going to be more than that, how can I loop my request so that the end time passed in my previous request becomes the start date of my next request and the request becomes a 15 minute time range request which will generate 900 records.
Please let me know if more details is needed or if I don't make any sense.
Please see the attachment as well.
Any guidance will be really helpful.
Thank you!
Keshaventer image description here
I'm new to scripting so don't have much idea on how to proceed with this and how to accomplish this.

I'm not very good by parsing incomplete JSON by looking at screenshots so I can only provide a generic answer:
You can create custom pass/fail criteria using JMeter Assertions in general and in your case JSR223 Assertion in particular
Response body can be fetched as prev.getResponseData() where prev stands for the previous SampleResult
Once done you can use XmlSlurper to extract data attribute values and store them into some form of Array
And finally iterate the array and check if the next item is 1 second ahead of the previous

Related

Dynamic value changing from server response compare to replace in the JMeter script

Few of the token values are changing compare to response to replaced in the script. please let me know how to over come this issue
1st value
Recorded Server response in JMeter recording log
VI1js8eNsTKaakYaEsdhPPg+nlPY2SL6/0RoyxBL1BE=
Replaced value in the JMeter script
VI1js8eNsTKaakYaEsdhPPg%2BnlPY2SL6%2F0RoyxBL1BE%3D
2nd value
Server response
C/K6QoR6Qjk/pLQAyvQ5FiRXFK9BAxeRJAEDJ+BGA+w=
Replaced value in the JMeter script
C%2FK6QoR6Qjk%2FpLQAyvQ5FiRXFK9BAxeRJAEDJ%2BBGA%2Bw%3D
Please hlep to to over come this issue.
Thanks
Raghav
Most probably there is some form of encryption/decryption logic which is applied to certain request parameters, it's not possible to guess the algorithm so if you don't know it you need to ask around.
Once you will know what exact encryption algorithm is being applied - you should be able to perform the same either using __digest() or __groovy() functions

Jmeter - wait for a specific response and collect total response time

our application is testing file upload and I'm curious if I can make Jmeter wait for a specific response and then report collective time.
What I have now is:
whileLoop()
-- HTTP Sampler
-- JSON Extractor
JSON Extracor pulls out a specific field and if it's not null then the loop stops.
The problem is that JMeter doesn't report response time as a sum of all the responses (response times) it had to make and that is what I'm looking for. Is there a way to implement this?
You can put this code inside a Transaction Controller .
You should get what you want.

How to decide which value to fetch?

I have jmeter script contains five transactions of which one transaction contains more than one dynamic values. And I want to know how to decide which value to fetch in order to pass it to further transaction?
You need to fetch those values which are required.
Record your scenario 2 times
Inspect request details using View Results Tree listener
Find request parameters (they may be in the request headers as well) which are different between 2 recordings
These are the dynamic parameters you need to correlate (extract from the previous response and pass to the next request)
Alternatively you can use a cloud-based JMeter scripts recording solution which is capable of exporting recorded scripts in "SmartJMX" mode with automatic correlation of all dynamic parameters so you won't have to worry about it. Check out How to Cut Your JMeter Scripting Time by 80% guide for details.

Need to add unique value every time when run the POST api request in jmeter

Need to add unique value every time/always when run the POST api request in jmeter. I have API which is POST request, this request added 'roleId' which should be unique every time (should not use the id which was already created). I have tried below options but response says duplicate id.
1. Add http request with POST body> add 'Counter' to this request with min: 25 and max: 50 with increment:1
When run the request it always starts with '25' and it fails from the second run as it says duplicate value because in the first run this id has been inserted in table
2. User defined variables: used __Random function but for this also same issue.
3. CSV data set config: same issue.
Please suggest what would be the best approach to solve the issue.
__UUID function can generate a GUID structure which is pretty much unique, something like: 9e73f1a6-c1dc-44f7-b73a-508871f98b83
__time() function can generate current timestamp in milliseconds from the start of the Unix epoch, something like 1492417676453 (it won't help if you have > 1 request in millisecond)
__threadNum() function returns current virtual user number
__iterationNum() function (available via JMeter Plugins) returns current loop number (thread group level)
__counter() function which generates an incremented value each time it's being called
You can use any combination of the above in order to generate your roleId, if you have doubts let us know the criteria so we could come up with the best solution. In the meantime check out Apache JMeter Functions - An Introduction article series to get the overall idea about using Functions in JMeter tests.

Developing JMeter test plan with results from multiple REST end points

Is this possible in JMeter to develop a test plan that will have result of first test (an ID) will be input of next test and so on in next test upto 4 tests because each test generates a unique ID and each of these IDs are dependent on each other. Each one is related as follows: submission ID > execution ID > both will generate completion ID with result pass or fail. These are REST API calls. I need to run concurrency users load testing. Finally I need measure latency, throughput from each test.
Between sampler requests, parse the api response using JSON post processor, assign it to ${variable_name} and use it in other requests.
It should look something like this.
Thread group
Userdefined variables
Http Sampler
Regex to get id
Http Sampler
Regex to get id
If you want to measure the response time of all the sampler have a simple controller as parent of all samplers
thank you for quick tip. I was able to get one step working by passing ID into a regular expression, but the same regular expression did not work for 3rd step. Let me give more details here. Basically first post command gives submission ID > I used that ID into regular expression > run a get command in next step with an URL something like '/../2ndStep/submissionId' > this is passed > I'm using the same regular expression in next get command with an URL something like '/../3rdStep/submissionId/executions'> this is supposed to give another executionId and it is failing for me. I'm not sure what I'm missing.
thank you all for suggesting working solution. But I need to do this different way to achieve the following requirement.
When I run POST command test on my REST API HTTP request using JMeter, it returns an ID in response. This ID will be used by other steps for completing the job. I'm currently passing ID into regular expression and using that in between the samplers of each step as it was suggested above and then measuring latency, but the GET steps which are dependent on that ID could take sometime to complete. So I can not put those GET steps into one thread because two of the steps are failing as they could take some time to complete. Is there a way to separate POST command from the remaining and start polling GET commands on the remaining steps automatically to remedy this. Bottom line is I need to measure latency of each step and throughput too. Please let me know if there is a way to achieve this in JMeter?
Thanks again,
Santana

Resources