Monday, 25 May 2015

ITSM BMC Scripting ARS 8.1 with HP Load Runner

 I recently worked in ITSM BMC project scripts for the BMC Remedy Action Request System 8.1. This blog contains some of the things that I learnt.
BMC people doesn't recommend using HP Loadrunner for scripting their application because they have their own tool and they say its impossible to script ARS with Vugen. Even HP doesn't support this but believe me its very easy.
So in our project we didn't have any ADM support and neither from HP guys.



First thing which is very important to keep in mind for this is your test data length should be equal. Ask from your data provider team to give such data which is equal in length.
For example Username=1186612 and Password=Justin
So for second username=1175512 and Password=Justin
 As you are running a Performance test and will be requiring a lot of User ID's So Username should be of same length like in this example its seven and password should be same for all the virtual Users as password comes in encrypted format .

Recording and Script Generation

Remedy ARS has both a Win32 client and a web-based client. The Win32 client communicates with the server using a proprietary protocol that is not supported by VuGen. Traffic can be recorded using the Windows Sockets vuser type, but the data is in an unintelligible binary format (just because you can record an application with Winsock doesn’t mean you should try to create a script using it).
Record by URL mode and go to advance options and set web_custom_requests only. Dont select concurrent group options as for some transaction it will record nothing.
Note that it might be possible to configure VuGen to record ARS by using the VuGen protocol development kit, and referring to the ARS API documentation, but time limitations prevented me from experimenting with this.
When recording, you must either use URL mode (so that each HTTP request is a separate function call), or change your recording settings to treat the MIME type “text/plain” as a non-resource (Recording Options > HTTP Properties > Advanced > Non-Resources). This will ensure that the calls to BackChannel are not recorded as EXTRARES.
VuGen 11.5 when generating code for the BackChannel requests. These appear as a web_custom_request with “Method=GET”, and have a body with values in it.

Backchannel Requests

You may have already guessed that BackChannel requests are kind of important for ARS. These requests are sent behind the scenes to fetch data to display in the GUI and to update data on the server. This means that you will be scripting “blind” as VuGen will not show you what any pages look like in either the Tree View or the Test Results window.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Lookup of Incident # INC00000126798
web_custom_request("BackChannel_15", 
    "URL=https://remedy-ars.example.com/arsys/BackChannel/?param=416%2FGetEntryList%2F22%2Fremedy-ars.example.com31%2FHPD%3AIncident%20Management%20Console22%2Fremedy-ars.example.com13%2FHPD%3AHelp%20Desk0%2F30%2F4%5C1%5C1%5C1000000161%5C99%5C302085700%5C13%2F1%2F9%2F30208570020%2F1%2F15%2FINC0000012679875%2F1%2F1%2F41%2F21%2F3212%2F17%2F9%2F24000100510%2F100000000110%2F10000057919%2F20000000510%2F100000000010%2F100000005610%2F100000016410%2F100000015110%2F100000008010%2F10000002179%2F20000000310%2F100000056010%2F10000057859%2F20000000492000000049%2F24000100310%2F10000000999%2F240001002", 
    "Method=GET", 
    "TargetFrame=", 
    "Resource=0", 
    "RecContentType=text/plain", 
    "Referer=https://remedy-ars.example.com/arsys/forms/remedy-ars.example.com/HPD%3AIncident+Management+Console/Default+User+View+%28Support%29/?cacheid=70246b58", 
    "Snapshot=t22.inf", 
    "Mode=HTML", 
    "EncType=text/plain; charset=UTF-8", 
    LAST);
/*
URL decoded request:
https://remedy-ars.example.com/arsys/BackChannel/?param=416/GetEntryList/22/remedy-ars.example.com31/HPD:Incident Management Console22/remedy-ars.example.com13/HPD:Help Desk0/30/4\1\1\1000000161\99\302085700\13/1/9/30208570020/1/15/INC0000012679875/1/1/41/21/3212/17/9/24000100510/100000000110/10000057919/20000000510/100000000010/100000005610/100000016410/100000015110/100000008010/10000002179/20000000310/100000056010/10000057859/20000000492000000049/24000100310/10000000999/240001002
 
JSON response:
this.result={n:1,f:[{t:0},{t:4,v:"JDS"},{t:4,v:"PPL000000132801"},{t:4,v:"Network Management 


In body there will be lot of PPL000000132801 and IDHAGG6782THEVB requests and Incident IDs starting from INC000000012347

Coreleate Incident ID and IDH ID its a must.

After script generation do one thing Ctrl+H  replace "web_custom_request("BackChannel"  with "web_reg_find("Text=this.result", LAST);web_custom_request("BackChannel" it will put

web_reg_find("Text=this.result", LAST); Function before each backchannel request and will help you to know if response is coming from the server or not.

Timestamp

There will be lot of timestamp in your script having 10 digits and 13 digits.
Coreelate it as following type:

// Example in C
// Timestamp in seconds
lr_save_int(time(NULL), "pTimestamp_1"); // 12499508091249950809 // Timestamp in milliseconds
web_save_timestamp_param("pTimestamp_2"); // 1249950434718
And one more thing while updating Incidents,Problems in application there will be backchannel's having Body containing combination of 13 digit and Incident ID of 15 digits.
Corelate this timestamp as
web_save_timestamp_param("pTimestamp_2"); // 1249950434718
Its very important, please do take care of this.
If you have any issue provide me your comments.























Upload external files in load runner scripting


How to upload files in Scripting Load Runner(Vugen)

How to upload any file from local location or from a sharepoint path in virtual user generator:

 There are several options that do the same work:
 
Running test locally :
If you are running script on your machine then. I suggest placing file in “C:\temp” before recording.
Run the test using same local machines. Test will pass since script and upload file both located in the same machine during recording and test execution.
Keep in mind to replace "\" symbol with "\\" as this is c character .To avoid confusion go to load runner there is option to convert code into c language. For example "“C:\temp” in c language will be “C:\\temp”  single backslash with double backslashes in the script. Here is the sample script:
web_submit_data("AddAttachment.aspx",
 "Action=https://learningshared.com/AddAttachment.aspx",
 "Method=POST",
 "EncType=multipart/form-data",
 "RecContentType=text/html",
 "Snapshot=t7.inf",
 "Mode=HTML",
 ITEMDATA,
     "Name=__VIEWSTATE", "Value={ViewState_Value_1}", ENDITEM,
     "Name=__EVENTVALIDATION", "Value={EVENTVALIDATION_1}", ENDITEM,
     "Name=FileUpload1", "Value=C:\\Temp\\uploaded_file.pdf", "File=yes", ENDITEM,
     "Name=Button1", "Value=Upload", ENDITEM,
 LAST);

Running test with any network load generator: This method is similar to the first method. Provide address of share location from where you want performance center to pick up your files and execute a network share location with read & write access. Place files those need to be uploaded.
Make sure to replace single backslash with double backslashes in the script. Here is the sample script:
 

web_submit_data("AddAttachment.aspx",
 "Action=https://learningshared.com/AddAttachment.aspx",
 "Method=POST",
 "EncType=multipart/form-data",
 "RecContentType=text/html",
 "Snapshot=t7.inf",
 "Mode=HTML",
 ITEMDATA,
     "Name=__VIEWSTATE", "Value={ViewState_Value_1}", ENDITEM,
     "Name=__EVENTVALIDATION", "Value={EVENTVALIDATION_1}", ENDITEM,
     "Name=FileUpload1", "Value=\\\\Global_shared_network_location\\projectspace\\uploaded_file.pdf", "File=yes", ENDITEM,
     "Name=Button1", "Value=Upload", ENDITEM,
 LAST);

 Attach upload file with scripts:
  • This method is similar to the first method. Record the script with a local file.
  • Add all the files (to be uploaded) to scripts by clicking “Add Files to Scripts…” menu from “Files -> Add Files to Scripts…”
  • Now clear file location and just leave the file name. These scripts should run from any load generators in the network or can be run from Performance center ALM too.
web_submit_data("AddAttachment.aspx",
 "Action=https://learningshared.com/AddAttachment.aspx",
 "Method=POST",
 "EncType=multipart/form-data",
 "RecContentType=text/html",
 "Snapshot=t7.inf",
 "Mode=HTML",

ITEMDATA, "Name=__VIEWSTATE", "Value={ViewState_Value_1}", ENDITEM, "Name=__EVENTVALIDATION", "Value={EVENTVALIDATION_1}", ENDITEM, "Name=FileUpload1", "Value=uploaded_file.pdf", "File=yes", ENDITEM, "Name=Button1", "Value=Upload", ENDITEM, LAST);