How to run the jmeter thread groups one after another - json

The situation is next: I need to run the performance tests using jmeter. I have setup several Graphql requests, tested them and they work perfectly. The idea of the flow is next:
The user login to the platform using graphql mutation, and in response headers receives accessToken, which is valid for an hour.
The next graphql request must parce the generated token, and perform the next mutation using this token.
The idea is to test the platform with 250k requests, which takes more than 1 hour, and as you probably understand - the token is expired.
What I have done within my script:
I've created 2 thread groups. In the first, there is a Flow is Control action element, which is setup to pause duration for 3600000 msec. This means that it will run the Login request once per hour.
I'm scraping the token with JSON extractor, and parcing it using the BeanShell post-processor, by the following command:
props.put("accessToken", vars.get("accessToken"));
Second thread group has a Graphql request to perform the 250k requests to the server and uses the token value from HTTP headers:
Bearer ${__P(accessToken)}
Everything works fine, accept the fact, that I don't know how to setup the scenario, where the thread group with login will finish its run, after the second thread group will complete 250k requests.
I've tried adding the loop controller to Login, set as infinite, but the thing that once the second group will complete 250k requests - the run won't be finished, as the Login will be running forever once per hour.
Any ideas?

You can add a Loop Controller or Throughput Controller and configure them to execute these 250k requests followed by Flow Control Action Sampler configured like:
When the sampler is reached - it will tell all the threads in all thread groups to stop.
Also be informed that since JMeter 3.1 you're supposed to be using JSR223 Test Elements and Groovy language for scripting so it makes sense to consider migration now. Storing a property once per hour with 1 thread is not something you should be worrying but for more resource intensive tasks Groovy behaves much better (for example it has built-in JSON support so you can discard the JSON Extractor)

Related

How to test 10 threads with JMeter?

Reach 10 threads
a. The 10 threads should be created in a 1-minute period (i.e. - after 60 seconds, thread number 10 will kick in)
Each thread should
a. Execute an HTTP request to http://blazedemo.com
i. Verify that the word ‘welcome’ is in the body of the response
b. Then, wait for 10 secs
c. Execute an HTTP request to http://blazedemo.com/register
i. Wait 5 seconds before the request is executed.
d. Extract the XSRF token from the response header.
e. Use Beanshell script to log the extracted token to the Jmeter log.
Thread Group configuration to implement 10 users ramping up for 1 minute would be the following:
HTTP Request sampler for http://blazedemo.com/ would be:
To check Welcome text presence use Response Assertion configured like:
To wait for 10 seconds use Flow Control Action Sampler
To open http://blazedemo.com/register add another HTTP Request sampler:
To wait for 5 seconds before request use Constant Timer
To extract XSRF Token use Regular Expression Extractor
I don't know who told you to use Beanshell, you need to make this person aware that since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language as Groovy has much better performance and more features comparing to Beanshell. In order to print the tokens for each user add JSR223 PostProcessor as a child of 2nd HTTP Request sampler and put the following code into "Script" area:
log.info("Token for user: " + ctx.getThreadNum() + " is: " + vars.get("token"));
More information:
Building a Web Test Plan
Building an Advanced Web Test Plan

how does google-cloud-function generate function-execution-id?

A Cloud Function triggered by an HTTP request has a corresponding function-execution-id for each calling request (in the request and response header). It is used for tracing and viewing the log of a specific request in Stack Driver Logging. In my case, it is a string of 12 characters. When I continuously do HTTP requests to a cloud function and see the function-execution-id, I get the result below:
j8dorcyxyrwb
j8do4wolg4i3
j8do8bxu260m
j8do2xhqmr3s
j8dozkdlrjzp
j8doitxtpt29
j8dow25ri4on
On each line, the first 4 characters are the same "j8do" but the rest are different, so I wonder what is the structure of function-execution-id.
How was it generated?
The execution id is opaque, meaning that it doesn't contain any useful data. It is just a unique ID. How it was generated should not be of any issue to you, the consumer. From examination, it looks like it might be some time-based value similar to UUIDv1, but any code that you write that consumes these IDs should make no assumptions about how they were generated.

Jmeter trigger http request after another http request is succesful. Concurrent requests with condition

I have 2 thread groups
Thread group1:
csv data set configure
{
loop through the csv file(CSVFile.csv) that contain fileNames of json data to post
eg: CSVFile.csv
file1.json
file2.json
.....so on
}
http request (That posts the data to rest api) (lets call it POST request)
{
extracts data from each json file and put it in http body and post to rest api
eg:
extract data from file1.json and post
}
jsr223 post processor
{
extracting data from above http responce and saving it to a file
}
Thread group2:
csv data configure
{
reads data from csv file
}
http request (Perform GET operation on rest api) (lets call it GET request)
{
eg:
GET ip:port/searchParameter=value
}
Now the problem is how to trigger thread group2 every time a iteration of http request of thread group1 is complete and go for iteration 2 without waiting for thread group2 to complete.
eg:
POST request -> file1.json completion should trigger GET request
As the GET request continues to execute
POST request -> file2.json should be excuted concurrently
CAN I DO THIS?
I would recommend removing interim step of saving the response data into a file and read it in 2nd Thread Group, you could achieve the same within the bounds of a single Thread Group using JSON Extractor and JMeter Variables - this approach will be much faster as in-memory operations are very quick comparing to disk IO operations and you will not have to worry about thread groups synchronisation.
However if you would like to keep things as they are you can consider using Inter-Thread Communication plugin which can be used for synchronisation of different Thread Groups basing on simple FIFO queue so 2nd Thread Group will start when it gets the signal from the first Thread Group.
Check out How to Use the Inter-Thread Communication Plugin in JMeter article for more information if needed.
You can install Inter-Thread Communication Plugin using JMeter Plugins Manager
You can using if controller to handle. You check if thread 1 success, you put status success. If fail you put status fail
Thread 2 check status from Thread 1. If success then run http request

How to Run Http Samplers in sequence order (step by step as per the ThreadGroup Order)

Behavior of my application:
HTTP Request Login
..JSON Path Extractor - Im extracting the session id
Debug Sample - Checking the session id
HTTP Request -- Im passing the session id to these requests
HTTP Request -- Im passing the session id to these requests
HTTP Request -- Im passing the session id to these requests
If I run the above script for one time Im getting the expected results above requests are passing step by step process.
If I run the above script with - Number of Threads as 5 .Then Login is hitting for 3 times other urls hitting for 2 times.
I need to run the above script one order for number of times.
I'm not seeing any regular expression extractor which you would need to pass in the session ID from one request to another. Also, if your back end uses cookies make sure to add the http cookie manager.
Here are some good JMeter getting started videos which also cover what you're trying to do:
http://blazemeter.com/blog/jmeter-tutorial-video-series

flex, multi request from the command class, how to differentiate each response from results in command

I run into a question that asked by a flex interviewer:
If there are 2 requests from the command class, and when back end process the request, they may take different time(the first command may take longer time to process so that it returns after the response of the second request).so, in your result-handler of your how do you know which response is for which request?
Note: they are in the same command, and they are processed by the same result handler.