How to create a test plan with unique header value in JMeter - jmeter

I'm trying this test plan with two requests suppose to have one header value unique for each test. Here is the structure of my current test plan.
Test plan >
HTTP Request1 details:
Host: Host1/api
Resource: method1
Request Method: POST
Headers: Tenant:x1
HTTP Request2 details:
Host: Host2/api
Resource: method1
Request Method: POST
Headers: Tenant:x1
So this test plan is used now to run multiple threads to measure the performance of the POST requests go to two different hosts but this test plan needs to be modified to have same threads (10 concurrent threads) submitted by different x1, x2, x3, ... xn tenants. That means x1 will submit 10 requests, x2 submits 10 requests,.. and so on, in parallel. The rest of the items are same in the test plan.
Please advice if there is a way to achieve this in JMeter?

You can use the below setup.
1.Use CSV data set config for the input of two different value..I have take Host but you can take any like in your case Tenant:X1. So, two column with different values.
2.Then, Under the HTTP sampler add header manager and pass the value like Name:-Tenant and Value:-${CSV_Header_Name}.
As you can see in the below Host1:Host1_val1 is added in the request. Host1 is from header manager and its value from CSV.
Now, if I understand you scenario, you need to run X1 10 times in parallel during a thread execution and the header value should remain same for all 10 i.e X1.
To do that, use bzm- Parallel Controller plugin and copy paste your request 10 times. All the 10 request under bzm controller will run parallely with the same header value for a particular thread.
OR, if you need only two request with different header each time it is executed then, remove bzm parallel controller and put only two requests i.e. HTTP1 and HTTP2 as show below.
Hope this help.

Related

JMeter test plan for invoking API A and then API B, how to accomplish that?

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:

Jmeter Dynamic parallel graphql requests

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

Performing many tests in 1 test plan

I need to perform tests on hundreds of HTTP links one after the other.
That means i want to, for instance, perform a 3 minute test with 5 users on 1 link and after that's done, do the same for the next link.
1 way to do this is to create a ThreadGroups for each link, each having a HTTPsampler and just have all of the run consecutively. But i read that that would create memory problems for the testing machine.
So what is the correct way of doing this? I really don't feel like creating and manualy running a separate TestPlan for every link.
You can use only one HTTP Request sampler, the suggested Test Plan structure:
Thread Group with the number of threads (virtual users) you want to simulate
CSV Data Set Config containing the list of URLs
Runtime Controller configured to last 180 seconds
HTTP Request sampler configured to hit the URL:
This way you will hit 1st URL for 180 seconds then 2nd URL for 180 seconds, etc.
For the problem you have mentioned you can create single test plan instead of multiple test plans and add multiple thread groups inside it and make sure that run thread consecutively is checked.
In each thread group mention the thread count and test duration as mentioned in the example below.

Firing multiple soap requests with different data through JMeter

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

how to run two requests sequentially in jmeter

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

Resources