This is a migrated thread and some comments may be shown as answers.

Load Testing Dynamic Values in Request Body

4 Answers 458 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 15 May 2020, 11:16 AM

Hey guys,

So I am doing a Load Test and I see you can dynamically assign dynamic Targets
In my case this is sessionIDs from a .csv file I Bound to the test already.

This is working good so far, SessionIDs are replaced in the Request Headers succesfully.

BUT:

There are instances where we send the sessionID in the Request Body, instead. I see I can manually edit the Post Data in the "Edit User Profile" popup, but I would like to make it dynamically choose a sessionID from my .csv file
I also tried adding a Custom Dynamic Target until I realized These affect Response(!) Body rather than Request(!) Body.

So my Question is:
Is there a way to tell TestStudio to dynamically replace Values in the Request Body?
Plus is there an easy way to bulk-do it or globally Change it? Because I would like to avoid doing this hundreds of times over.

 

Thanks and Kind regard
Ben

 

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 20 May 2020, 09:45 AM

Hi Ben,

It seems that you have tried out most of the options, which Test Studio provides to parameterize the load testing user profile. 

What you need to cover the described requirements are the dynamic targets and as these may be quite complex, I will provide some further information on the topic for you.

The general case for a dynamic target is to pass some dynamic information generated from the server from one request's response to the next request's body. In Test Studio there are automatically detected targets, which, unfortunately, does not always cover the needs of the specific requests and client-server communication. 

Therefore, we have developed and implemented the Custom dynamic targets, which allow you to customize any user profile as per its specifics. 

Then, here are some notes about the custom targets -

  • one of the most important is that such target is also taking specific value from the a request's response to provide it to the next request's body.
  • When creating a custom target, you can choose where to take the value from - the response body, headers or cookies. 
  • Next is to configure where to send that value - you can choose between Query Parameter, Header, Cookie, POST data, URL.
  • The custom targets can be also used to data drive any value in certain request. Even if the certain value is not returned in any response, you can add a custom target, which gets any value from a response, but defines the destination. Then, data drive that value

The above topics seem to cover your first query in regards the dynamic customization of a user profile. In regards your second query, I have to admit that there are no global values you can define and bulk edit these. Basically, if a request needs 4 dynamic values - in the post data, 2 query parameters and a cookie, for example, you need to add four different dynamic targets to pass these to the request. 

I hope this information will help you in adjusting the user profile for your load test. Of course, I remain available the continue the discussion and if you need to, it will be very helpful if you can share a sample load test to use as an example. 

Thank you in advance for your time.

Regards,
Elena
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Alexandra
Top achievements
Rank 1
answered on 12 Feb 2021, 12:28 AM

Hello,

I am also facing a similar challenge:

The REQUEST body of /POST login/ has the user name & password which I want to Data bind on my Load test, so that I can have a list of users on the Data Source.

The problem is that since the Custom Dynamic Targets do not allow me to use Data Binding on the Request body, as of 2021, is there any workaround for this?

Thanks,

Alex

0
Benjamin
Top achievements
Rank 1
answered on 12 Feb 2021, 09:16 AM

Hey Alex,

sadly I didn't manage to dynamically bind data to the Request Body. What I did was this:

- I recorded my User Profiles with Fiddler
- Then I unzipped the .saz archive and edited the sessionIDs in the raw Fiddler data (notepad++ replace all)
- Zipped it back up, changed ending to .saz
- Imported that forged .saz archive as user profile in Test Studio

That is not a very elegant solution as basically all my users were sharing the same sessionIDs at that point, but at least the responses didn't default to error codes because their session was invalid. It got the job done ;)

Hopefully Elena or some other Telerik staff can present a better solution. Until then maybe this sparks an idea in your head.

Kind regards
Ben

 

 

 

 

 

 

 

 

 

0
Elena
Telerik team
answered on 12 Feb 2021, 11:51 AM

Hi Ben, Alex,

Thank you for sharing your thoughts on the topic in this thread. 

I wanted to step in and provide some additional notes as I have the feeling that the provided details do not address your doubts. 

When defining a dynamic target in Test Studio you are using one source step, from which response is the dynamic data taken, and one destination step, which defines where in the request to place the changing values - replace the URL for redirects, replace a query parameter, set a cookie, replace a value from the POST data. All options for the destination step concern how the request will be built and sent to the server, and are not related to its. response. 

Next topic is data driving a load test in Test Studio - this is only possible through the dynamic targets. The scenario, which seems to be bothering you is how to data drive some data in a request, which is not defined through dynamic targets from the previously executed steps. 

If I have understood correctly, then the option is to use dummy custom dynamic targets. These should be set to pass any data to the request, which body you need to parameterize. Once these dynamic targets are bound to the external data, which provides the correct values, the test should run as you expect it. Of course, if there is no is external data connected, which contains valid data, the load test execution will fail. 

I hope that this brings some further understanding for the case. I remain available to continue the discussion, though.

Regards,
Elena
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
valery
Top achievements
Rank 1
commented on 23 Feb 2022, 12:46 AM

Hi Elena,

Where can I read how to replace value in request body/post data with Custom Dynamic Target value?

This is my post data:

loginForm%3AUserName=<user_name>&loginForm%3APassword=<password>&loginForm_SU...

Thanks,

Valery

Elena
Telerik team
commented on 24 Feb 2022, 10:28 AM

Hi Valery, 

Here you can read how to create and set a custom dynamic target. You first need to identify the request in which response is the data you need and use it as source step. Then, in the destination part set the step in which you need to replace the POST data (in this case). 

If the values that you need to replace are not generated during the test run and are predefined like the user name and password, you can data drive the load test and use a data source to change these values.

The tricky part here is that the dynamic targets can be data driven. That means you need  custom targets for the username and password, which you can then data drive. Important for these custom targets is the destination part. The source could be whatever as it will not be really used - it will be replaced from the data in the data file. This is why we call that kind of custom targets dummy targets. 

I hope this information helps you sort out your difficulties. Let us know in case of further questions. 

Regards,
Elena

valery
Top achievements
Rank 1
commented on 24 Feb 2022, 01:51 PM

Hi Elena,

Thank you for the info. 

Can you please explain how to parameterize Post Data of the request?

Do I need to replace complete Post Data with a custom target?

What if I need to change more than one field in Post Data? In my case user id and password.

Can you please point me to more advanced documentation explaining request Post Data parameterization?

Is it possible to have a training session to discuss how to use custom targets to parameterize Post Data?

Thanks,

Valery

Elena
Telerik team
commented on 25 Feb 2022, 10:48 AM

Hi Valery,

Setting up a load test and identifying the dynamic targets is quite specific for the each application and is based on the particular traffic generated for this. Thus, the documentation describes some general states, but the customization depends on the case. It will be best if you share a sample load test to work on.

When it comes to training sessions, Test Studio offers a load testing package - you can explore all learning options here. The load testing one is listed under the Standard Training Programs section. 

Regards,
Elena

Mario
Top achievements
Rank 1
commented on 16 Dec 2022, 08:52 PM

Hi Elena,

I reviewed the documentation and there is nowhere explaining how Post Data parameterization works. Let's say I called an endpoint that returns a GUID ( e.g. "MyGUID") and I need to send that GUID in another POST request as part of the following json payload:

{

 "id": 1,

  "code": "a1",

 "locations": [

       {

           "guid": "MyGUID",

            "name": "MyLocation"       

}]

}

 I know other load test tools like Jmeter uses variable substitution, e.g. ${MyGUID}.  How can I accomplish this in Test Studio?

Thanks,

Mario

Elena
Telerik team
commented on 21 Dec 2022, 04:13 PM

Hi Mario, 

I have to admit that the Json POST data cannot be partially replaced. If you set a dynamic target to send any value to the POST data for the shared sample request, the Json string will be replaced with that value only. 

The only option remains to data drive the load test and that specific dynamic target with the complete Json string modified where needed. But you need to consider that this approach is somewhat limited as the data cannot be dynamically generated and is only taken from the predefined values in the data source.

On a side note I want to add that there is a feature request in our public portal about adding support for parsing the JSON post data, which will allow you cover that scenario out-of-the-box. The public item is here and you can Follow it to get notifications on any updates in its status.

I hope the provided information is helpful for you. Let me know in case you have any further questions on the topic.

Regards,
Elena

Tags
General Discussions
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Elena
Telerik team
Alexandra
Top achievements
Rank 1
Benjamin
Top achievements
Rank 1
Share this question
or