Problem statement: Your performance regression scenario contains 20 different Loadrunner scripts. You run this scenario a number of times in a given release.For simplicity, let’s assume that all scripts are developed using web services protocol. There may or may not be any changes to the scripts but version of the service endpoint changes a lot of times. For example, from version R200 to version R300
From http://ServerName:Port/R200/CustomerDataManagement.svc
To http://ServerName:Port/R300/CustomerDataManagement.svc
How to modify all the endpoints to have latest version, possibly without opening the scripts?
Solution 1: One trivial solution which would come to everyone’s mind is to create a parameter, say pEndpointVersion, and use that in the URL as shown below
http://ServerName:Port/{pEndpointVersion}/CustomerDataManagement.svc
Drawback: You will have to update the parameter value every time the endpoint version changes. Thus, you will have to download, open and update the parameter in all the scripts. This activity is very time consuming especially when it comes to VUGEN 11.52 as we all know how slow it is for opening scripts. Have a look a solution 2.
Solution 2 (preferred): In your script, go to RunTime Settings(RTS) under ‘Additional Attributes’, add a new argument name and a argument value. For example: argument name ‘EndpointVersion’ with argument value ‘R300’.
Then use the statement lr_get_attrib_string(“<Argument Name>“) to retrieve the argument value. In our example, use lr_get_attrib_string(“EndpointVersion“) to retrieve the value ‘R300’.
You can output the value like this
lr_output_message("*******version: %s", lr_eval_string(lr_get_attrib_string("EndpointVersion")));
OR save it into a parameter via lr_save_string() and access it anywhere in the script using the parameter name. For example,
lr_save_string(lr_get_attrib_string(("EndpointVersion")),"rVersion");
The endpoint will look like http://ServerName:Port/{rVersion}/CustomerDataManagement.svc
Example:
lr_output_message("*******version: %s", lr_eval_string(lr_get_attrib_string("EndpointVersion")));
lr_save_string(lr_get_attrib_string(("EndpointVersion")),"rVersion");
Output
Action.c(25): *******version: R300
Action.c(27): Notify: Saving Parameter “rVersion = R300”.
Benefit: If the endpoint version changes, you can modify the RunTime Settings (RTS) for all the scripts in the scenario in Performance Center itself. You don’t need to open and update it in individual scripts. If all the scripts use same RTS, then it’s even easier. Just modify RTS of one script and duplicate the RTS to rest of the scripts. Following screenshot shows the location of ‘Duplicate Runtime Settings’ option in Performance Center.
In Truclient protocol script, the function is LR.getLRAttr(“<attrib_name>”);
Refer for details: VUGEN help > VuGen > Protocols > Ajax TruClient Protocol > Enhancing Ajax TruClient Scripts > Ajax TruClient Functions
Hope it helps to someone!
No comments:
Post a Comment