The LoadRunner Blog

Monday, April 16, 2007

Tackling Load Balancing and Redirects

Chid posted this on SQA Forums.com

-------------------------------

Okay, Here is a typical problem that I faced in scripting an application. The recorded and correlated code was something like this:


web_submit_data("GotoURL",
"Action=https://www.uat.com/123.cfm",
"Method=POST",
"RecContentType=text/html",
"Referer=https://www.uat.com/LCSvlt",
"Snapshot=t9.inf",
"Mode=HTTP",
ITEMDATA,
"Name=RETURN_URL", "Value={PrmRETURL}", ENDITEM,
"Name=INPUT_DATA", "Value={PrmINPUTDATA}", ENDITEM,
"Name=SIG_DATA", "Value={PrmSIGDATA}", ENDITEM,
LAST);

web_url("Firm-Wide Poll",
"URL=https://www2.uat.com/firmwidepoll/login.cfm",
"Resource=0",
"RecContentType=text/html",
"Referer=https://www2.uat.com/home/home.cfm",
"Snapshot=t12.inf",
"Mode=HTTP",
LAST);

Now the problem was after the first step, the user gets redirected to a URL designated by the load balancer - which is designated with a url starting with www and a numerical digit. So while the user was redirect to www2.uat.com the first time, the second time he logs in , he is redirected to www3.uat.com - invoking the older URl at this stage makes the script fail.

Did i hear someone say "wrsp .. stupid?"

Yup but wrsp didnt work - because the response from the redirected URL had header and body responses in relative urls.. you know "../logout.cfm" rather than "www2.uat.com/logout.cfm"..

so yes, the plain old vanilla wrsp did not work. Okay should I escalate this to the Lead developers? Will they make any changes in the UAT? Should I raise this in my next meeting.. Wait, lets check the friggin resources on the net first.

Then a search of the loadrunner group yahoo archives came up with a suggestion. One of the attributes of the wrsp function is IgnoreRedirections . Now the default is set to YES - signifying that LR will search the final response and not the responses in between. So you just set the attribute to NO, and LR will search the redirect response first and capture the value out of it. So finally, here is the working code :


web_reg_save_param ("RedirectURL", "LB=www", "RB=.uat.com", "IgnoreRedirections=No", LAST);


web_submit_data("GotoURL",
"Action=https://www.uat.com/123.cfm",
"Method=POST",
"RecContentType=text/html",
"Referer=https://www.uat.com/LCSvlt",
"Snapshot=t9.inf",
"Mode=HTTP",
ITEMDATA,
"Name=RETURN_URL", "Value={PrmRETURL}", ENDITEM,
"Name=INPUT_DATA", "Value={PrmINPUTDATA}", ENDITEM,
"Name=SIG_DATA", "Value={PrmSIGDATA}", ENDITEM,
LAST);

web_url("Firm-Wide Poll",
"URL=https://www{RedirectURL}.uat.com/firmwidepoll/login.cfm",
"Resource=0",
"RecContentType=text/html",
"Referer=https://www{RedirectURL}.uat.com/home/home.cfm",
"Snapshot=t12.inf",
"Mode=HTTP",
LAST);

Labels: , , ,

1 Comments:

  • Hi VJP,

    Thanks for popping my site and the comment. I found your site very interesting with scripts provided (that I lacked heehee). Its a very useful site for me when I get into trouble with my scripting, thanks! :D

    Regards
    Hs
    http://loadrunnertnt.blogspot.com

    By Blogger Hs, at 10:08 AM  

Post a Comment

<< Home