In perf tests, I have the below scenario.
the first graphql call fetches multiple account numbers
Next, multiple graphql calls are triggered in parallel - one for each account number in the above response. URL is the same, but the request body has different account numbers.
I added a JSR223 postprocessor for the first request and read account numbers into a list (added them to vars). I can read the list in JSR223 sampler but I cannot find how to use the list to make parallel graphql calls.
The number of parallel graphql calls is equal to the size of the list. The url of requests is the same, the account number in the payload needs to be different.
I can only think of using Parallel Sampler, you can dynamically add children (HTTP requests to execute) using JSR223 PreProcessor like:
1.upto(vars.get('var_matchNr') as int, { index ->
sampler.addURL(vars.get('var_' + index))
})
make sure that your var_1, var_2, etc. variables contain the full URL with the parameters
Parallel Sampler and Controller are not the part of official JMeter distribution, they need to be installed using JMeter Plugins Manager
More information: How to Use the Parallel Controller in JMeter
Related
My test has 2 API requests.
The parameters passed in 2nd API request body are to be unique every time. So I used JSR223 PreProcessor with groovy to generate that using RandomUtils.
The Thread group is set to have 3 threads with 15 sec Ramp up time and used Loop Controller with Loop count as 10. 1st API is in thread group and 2nd API is in Loop Controller as it needs to run multiple times.
But during test execution, for 2nd API one thread is passing same request body with same parameters multiple times. Because of which the test fails. How is that possible?
It's impossible to state "how is that possible" without seeing your Groovy code.
The most common mistake is using JMeter Functions or Variables in Groovy scripts. As per JSR223 Sampler documentation:
The JSR223 test elements have a feature (compilation) that can significantly increase performance. To benefit from this feature:
Use Script files instead of inlining them. This will make JMeter compile them if this feature is available on ScriptEngine and cache them.
Or Use Script Text and check Cache compiled script if available property.
When using this feature, ensure your script code does not use JMeter variables or JMeter function calls directly in script code as caching would only cache first replacement. Instead use script parameters.
If this is your case - refactor your code to use vars shorthand for JMeterVariables class instance instead of JMeter Functions or Variables syntax and it should resolve your issue.
I want to develop JMeter 5 test plan with the following spec:
First call HTTP Rest API A. if the status code from A is not 200, keep repeatedly calling A until status code is 200. After first successful call to A, then proceed to call Rest API B.
There is CSV Data Set Config for API B which reads CSV file, each entry in CSV invokes a call to API B. When EOF is reached, JMeter must automatically exit (stop running).
API A must be called once every 10 minutes while API B is still being called (or JMeter is still running processing CSV file).
How to achieve this goal? 2 Thread groups are required or single thread group can do the job?
Please provide details like what should be the configs for test plan and thread group(s), the sequence of JMeter elements like While Controller, etc.
The purpose of the test plan is load testing API B, so multiple threads may call API B while a single thread is used to call API A.
You will need 2 Thread Groups in order to run requests against API A and API B with different number of users and concurrency
In order to repeat request to API A until response status code is 200:
Add a While Controller and use the following __groovy() function as the condition:
${__groovy((vars.get('code') ?: 42) as int != 200,)}
Add your HTTP Request for API A as a child of the While Controller
Add Boundary Extractor as a child of the HTTP Request and configure it like:
Add Flow Control Action sampler and configure it to sleep for 600000 milliseconds either inside the While loop or outside depending on your scenario
With regards to to stopping the test when the end of CSV file is reached it's just a matter of setting the next parameters in the CSV Data Set Config:
I want to fire multiple soap requests with different data through jmeter and I want all the soap requests to hit the application concurrently. Also I would like to know if I can do the same thing with soap ui? If possible do describe the steps in detail. Thanks in advance.
For JMeter:
Add HTTP Request sampler to your test plan
Add Switch to "Body Data" tab and put your XML payload skeleton there
Substitute the parts of the body you want to parameterise with JMeter Variables or Functions, the most commonly used for parameterisation test elements are:
CSV Data Set Config
__StringFromFile()
__FileToString()
__CSVRead()
For "concurrency" you also have different options:
If you want X threads to execute requests as fast as they can - just specify them in Thread Group
If you want X requests per second - go for Constant Throughput Timer
If you want all requests at exactly the same time - Synchronizing Timer
For SoapUI check out Simulating Different Types of Load article
So I have a REST API that I want to test with JMeter.
I have few different paths in the REST Service.
If we take an example of simple REST service that will calculate based on two values passed in request, I have four different paths
/add
/sub
/mul
/div
Now I want to test this with a 5000 requests but want to randomize the path and the values in request parameters in each request. Also if possible, want to get the results in 4 categories separately for each path.
Can someone please suggest the right combination of elements?
I am very new to JMeter and hence, expect a little elaborated answer. :)
The fastest and the easiest way is using __chooseRandom() function available via JMeter Plugins. The relevant configuration of the HTTP Request Sampler would be:
Path: /${__chooseRandom(add,sub,mul,div,path)} - get a random option and store it into ${path} JMeter Variable
Name: ${path} - change HTTP Request Sampler Label (for separate reporting)
You can install __chooseRandom() and other plugins Functions via JMeter Plugins Manager from the "Available Plugins" tab:
Be aware that your requests will be random hence your test scenario won't be repeatable so I would recommend considering using other test elements instead i.e. Throughput Controller or Switch Controller or Weighted Switch Controller.
See Running JMeter Samplers with Defined Percentage Probability article for above test elements configuration details.
Need some help on Jmeter for the following scenario please I need to simulate these steps in order to load our application.
a) make a request to a web-service.(done)
b) verify the response for some variables and extract a URL address from the response.(done)
c) Now using the extracted URL need to make another request.(extraction done)
d) in response a media file will be sent.
My Plan consists of "stepping thread group-->(Sampler 1)HTTP Request +couple of listeners for data gathering--> (Sampler 2)HTTP Request +couple of listeners for data gathering. the issue is that when i ran the plan the first sampler generated 4 requests but the second one generated only 2 can you tell me why is it so.
In general how can i simulate all 4 steps in one go for a single thread. I hope that i have cleared myself.
In JMeter each thread runs requests sequentially already.
So in order to do what you expect you'll need to use:
Post Processors called extractors to extract data into variables
Variables to inject in the requests
Read:
https://jmeter.apache.org/usermanual/test_plan.html#postprocessors
https://jmeter.apache.org/usermanual/functions.html#functions