how to run two requests sequentially in jmeter - 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

Related

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.

Jmeter hml request order get change when increase the number of users and due to that post reguler expression get failed

I record and run the Jmeter script by keeping number of users = 1, in tread group.
Results tree output:
I increased the number of users to 3 and result tree output order changed.
Therefore my some of regular expression exacter logics get failed and resultant responses failed. How can I avoid this situation.
Is there way to manage result tree execution order.
If your regular expressions are under the requests and not at the same level as of HTTP requests then it should not be a problem.Every thread/vUser will run independently. But, in view results you will see request as and when executed by different threads and not in sequence.
As per JMeter Functions and Variables user manual chapter:
Variables are local to a thread
Each JMeter thread (virtual user) executes Samplers upside down (or according to the Logic Controllers). JMeter threads are absolutely independent from each other and each thread has its own variables.
So the problem must be somewhere else, inspect the state of the variables using Debug Sampler and the response data for /oauth calls - it might simply not contain the necessary token value.
Also there is a suspicious call to bundle.js, my expectation is that you should not be executing it directly. The good practices is to configure HTTP Request Defaults to download embedded resources and use parallel pool to be closer to what real browsers do.
See Web Testing with JMeter: How To Properly Handle Embedded Resources in HTML Responses article for more detailed explanation.

Jmeter, delay http request with many extracted urls

i have a issue with to many calls to the server.
I have extracted several urls with the "regex extractor".
In the next step, a "http request" calls these urls by ${extractet-urls}
But all requests after the 8th url gets a error 500 response from the server.
I tried to input several timers between, before and everywhere else, but it hasn't an impact.
So my question is:
how can i delay in this single http request which calls all the extracted urls?
Thanks for your help :)
After the requeat you can add sampler ->Java Request. Then change classname to SleepTest and it'll wait 1 second (configurable)
Add a Constant Timer as a child of the HTTP Request sampler (see Scoping Rules for details) and provide desired delay there (in milliseconds). It will cause the relevant thread to "sleep" for the defined amount of milliseconds before executing the HTTP Request. See A Comprehensive Guide to Using JMeter Timers to learn more about using Timers in JMeter tests.
Another option could be using Test Action sampler to create a delay, it doesn't generate sample result so you won't see it in .jtl results file.
The final approach is depending on what you're trying to achieve and how your test is designed.
Alternatively, you can add a Thread Group and define a ramp up time, then put the request inside this group. The ramp up time takes the startup overload too.

How to send multiple requests simultaneously with dynamically changing resource in jmeter?

I need to send multiple post requests simultaneously. And the problem is that transaction id in url should always be unique.
I added Synchronizing timer to send requests at once and added BeanShell PostProcessor to increment transaction id after request is sent.
But this works only if requests are executed one by one. How to increment transaction id if I need to run requests all at once?
Just use __counter() function in "global" mode like ${__counter(FALSE,)} instead of manually incrementing the "txnId" variable:
Demo:
See How to Use a Counter in a JMeter Test article for more information on generating incremented numeric values in JMeter.
Going forward remember that you need to implement some form of inter-thread communication to ensure that the same variable is not updated by 2 threads at the same time.

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

Resources