Response time from individual api request in jmeter - jmeter

Flow:
API A is calling API B
Api B is calling C
API C IS CALLING DB
How to find the response time from B to A?
In jmeter response time over time graph gives the over all response time.
I want to find the individual response.
Ex client calls a . A ll cal B, B ll call C, C will fetch the response from db and give to B within 5ms , B will give response to A within 5 ms and A will give to client within 5ms.
If I add response time over time graph I will see 15 ms but how do O find from b to a?

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

How to get the transaction fees of Near transactions and which operations involves Near amount?

https://explorer.near.org/blocks/99qdUGNmGMMQQdKGmgA7Lf6PjaXAHgVVy53DLHJZpcbb
Block - 35866073 has 5 transactions
ChunkHash - GwMUrTgEfqEaV9s8ngvqUn9c4hi4G8Ywpggoy4VDwnok
5 transactionHshses
TransactionHash 2 - AMDbiQUJx2Dd9FfbaYYbNj2D6T6xPJMHgWCZ4RTrN1UU
Transfer from comchien.near to 85a577d5db02df7830c8ad3db76ca6a90dee6f176c8478eb12dbf30d8d2d54ee - 5.58572
TransactionFee - ? there is some transaction Fee shown in explorer but in Json structure i dont see the transaction fee , can you plese help how can i get the transaction fee
TransactionHash 2- 6Beo8SFyjPjjtFnT3b2aEGDHgPY9HxGZ17vWvpSN733c
I can see storage_deposit , near_deposit and ft_transfer_call. Does all the amount gets transferred to wrap.near. And same transaction Fees is missing in json struture.
Transactions in NEAR are just inputs. To see the outputs (execution outcomes), you need to query transaction details using tx RPC to see transaction_outcome -> outcome -> tokens_burned field. That is the transaction initial processing fee. Next, you need to fetch receipt execution outcomes (well, it is right there in the tx RPC response) and sum all the receipts_outcome -> outcome -> tokens_burned. That is exactly what NEAR Explorer does.
You also could find this doc useful where I explain all balance changes there.

How to store request response data concurrently

i'm setting a test plan running this thread groups sequentially:
Execute request A using 10 threads, 500 loops.
Execute request B using 10 thread, 500 loops, and the output from step 1.
My problem is this:
On each request A, i receive an ID that i need to pass to request B.
What is the best way to store all the IDs and then use them on step 2?
At this time, i am "JSonExtracting" each ID from response and store on a CSV file to pass to step 2.
The problem is the concurrence of the treads. Some times i got empty spots on the file or concatenated strings which will produce an error on step 2.
I was not able to store this to an array variable to use on step 2.
To write the IDs to a file, i am using this code on a BeanShell Listener inside my threadGroup. I strongly believe this is not the most correct way to do it.
f = new FileOutputStream("${DocumentIdsFile}", true);
p = new PrintStream(f);
p.println("${DocumentId}");
p.close();
f.close();
log.info("Id: ${Id}");
How can i solve this concurrence problem?
If you receive an ID at the request A, just use it in request B, passing it throug variable:
Parse ID value in request A response using one of the Post-Processors to store it in variable, for example "ID".
Use it's value in your request B as a parametr:
GET https://myserver.com/myapp/getSomethig/${ID}

Execute httpSample conditionally JMeter

I need to test a REST method for saving an object. In order to have the ability to save it I need to request an authToken that is updating each 100 seconds.
Right now I have a thread containing both requests , and the login request is executed each time the saving does. How can I make the login execute once at the start of the thread and then each 100 seconds ?
P.S. I've tried separating it in 3 threads , one for the initial login , the other with a loop and a 100 seconds timer and finally the one with the actual test. It does work ,but it seems like a bad solution.
How about:
|-Login
|-Loop n times
|-Save
n being number of times that will be just about less than 100ms?
or
|-If login valid?
| |-NO: Login
|
|-Save
option 3:
ThreadGoup1
|- Login
|- Beanshell update shared token
|- Constant throughput timer
ThreadGroup2
|- Beanshell fetch shared token
|- Save
A constant throughput timer allows you to run at a set throughput. Once every 100 seconds is 0.6 samples per minute, I'm not certain you can do fractions, but even 1 sample a minute should work for you.

jmeter vs python requests - different response time

I am running a load testing with Jmeter and python Requests package, but get different result when I try to access the same website.
target website: http://www.somewebsite.com/
request times: 100
avg response time for Jmeter: 1965ms
avg response time for python Requests: 4076ms
I have checked response html content of jmeter and python Requests are the same. So it means they all got the correct response from website. but not sure why it has 2 times difference with each other. Is there anyone know is there any deep reason for that?
the python Requests sample code:
repeat_time = 100
url = 'http://www.somewebsite.com/'
base_time = datetime.datetime.now()
time_cost = base_time
for i in range(repeat_time):
start_time = datetime.datetime.now()
r = requests.get(url, headers=headers)
end_time = datetime.datetime.now()
print str(r.status_code) + ';time cost: %s' % (end_time - start_time)
time_cost += (end_time - start_time)
print 'total time: %s' % (time_cost - base_time)
print 'average time: %s' % ((time_cost - base_time).total_seconds() / repeat_time)
Without your JMeter code, I can't tell you what the difference is, but let me give you an idea of what's happening in that one call to requests:
We create a Session object, plus the urllib3 connection pools we use
We do a DNS look-up for 'www.somewebsite.com' which shouldn't be too negatively affecting this request
We open a socket for 'www.somewebsite.com:80'
We send the request
We receive the first byte of the response
We determine if the user wanted to stream the body of the response, if not we read all of it and cache it locally.
Keep in mind that the three most intensive parts (usually) are:
DNS lookup (for various reasons, but as I already said, it shouldn't be a problem here)
Socket creation (this is always an expensive operation)
Reading the entirety of the body and caching it locally.
That said, each response object should have an attribute, elapsed which will give you the time to the first byte of the response body. In other words, it will measure the time between when the request is actually sent and when the end of the headers is found.
That might give you far more accurate information than what you're measuring now, which is the time to the last byte of the message.
That said, keep in mind that what you're doing in that for-loop is also invoking the garbage collector a lot:
Create Session, it's adapters, the adapters connection pools, etc.
Create socket
Discard socket
Discard Session
Goto 1
If you create a session once, your script will perform better in general.

Resources