3

I'm using jmeter for load testing so I'm a little bit stuck at this situation. Below is the scenario.

There are two HTTPS (target1 and target2) requests, which needed to be generated sequentially in jmeter.

ID value from response to target1 request is needed in target2. Said ID is valid only once.

What I tried was:

Take the ID from the first request each time individually and send it in the target2 request by increasing the Threads only not the loop count, because ID won't work for the 2nd time.

Is there any other way we can do perf test for this, because I need to test at least 5K-7.5K users.

4 Answers 4

2

JMeter always executes requests in sequential order. Retrieve the ID in first request by using Regular Expression Extractor and try to print in second request by using Beanshell PostProcessor.

2

Put the requests in Critical Section Controller (under Logic Controller) according to your desired order.

1
  • 1
    This might be technically correct, but it still leaves the OP with the real problem: automatically retrieving the required ID parameter from the first response and inserting it into the second request.
    – Kate Paulk
    Jun 26, 2020 at 11:25
1

You can try and adding JSR223 PostProcessor.

The script will look like this: vars.put("response", prev.getResponseDataAsString());

but response that you get might be quite a lot. Since you only need the ID, then try adding Regular Expression Extractor too.

Then the "response" variable can be access as ${response} and you can pass it on your targeted https2.

1

What's the problem with increasing the number of loops? If you hit the target1 second time it will produce the new ID, won't it? So the previous JMeter Variable holding the previous ID will be overwritten with the new ID so you will be able to hit the target2 normally.

It also shouldn't be a problem to simulate 5-7k of virtual users from a mid-range modern laptop, just make sure to follow JMeter Best Practices, if one machine is not enough you can always go for running JMeter in distributed mode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.