Sunday, 6 November 2016

Difference Between HTML And URL Mode In Loadrunner

What is the difference between HTML and URL Mode?

HTML Mode:

HTML Mode is the default recording mode available in Loadrunner for Web (HTTP/HTML) scripts. When you record an application in HTML mode it will not record all the resources, but it will keep in extras as shown below and when the same script is executed it will parse all the urls one by one in extras and It will take some time to parse all the urls. Please find an example of HTML Mode below for Bing.com.

Bing.com in HTML Mode:

web_url("www.bing.com",
        "URL=http://www.bing.com/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t1.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=/s/a/bing_p_lg.ico""Referer="ENDITEM,
        "Url=/sa/8_01_1_3345848/notifications.js"ENDITEM,
        "Url=/sa/8_01_1_3345848/homepageImgViewer_c.js"ENDITEM,
        "Url=/fd/sa/9_00_0_3325577/rmsloaderdelayed.js"ENDITEM,
        "Url=/rms/AutoSugBlue/jc/f209ebd2/5c8aa5b3.js?bu=rms+answers+AutoSuggest+Modules%24Service.source%2cApi.source%2cDataProviders%24GenericDataProvider.source%2cAutoSuggestCanvas_r.source%2cAutoSuggestLayoutBlue_r.source%2cAutoSuggestSearchForm_r.source%2cAutoSuggestSpelling_r.source%2cAutoSuggestHighConfGhosting_r.source%2cAutoSuggestInit_r.source"ENDITEM,
        "Url=/s/as/8_01_1_3345848/Identity/WindowsLiveConnect_c.js"ENDITEM,
        LAST);

URL Mode:

In URL mode each and every resource is recorded explicitly. For example, when you look into a bing.com it will have images, css files, etc. The vugen will create a new web function for every resource separately and this leads to lot of code in your script and complex correlations. We use URL mode when we need  a better control over the resources of which files need to be downloaded or not. We can comment the script accordingly.

When you look into the same script in URL Mode it will create lots of steps as shown below for Bing.com

Bing.com in URL Mode:

web_url("www.bing.com",
        "URL=http://www.bing.com/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t1.inf",
        "Mode=HTTP",
        LAST);

    web_concurrent_start(NULL);

    web_url("bing_p_lg.ico",
        "URL=http://www.bing.com/s/a/bing_p_lg.ico",
        "Resource=1",
        "RecContentType=image/x-icon",
        "Referer=",
        "Snapshot=t2.inf",
        LAST);

    web_url("notifications.js",
        "URL=http://www.bing.com/sa/8_01_1_3345848/notifications.js",
        "Resource=1",
        "RecContentType=application/x-javascript",
        "Referer=http://www.bing.com/",
        "Snapshot=t3.inf",
        LAST);

    web_url("homepageImgViewer_c.js",
        "URL=http://www.bing.com/sa/8_01_1_3345848/homepageImgViewer_c.js",
        "Resource=1",
        "RecContentType=application/x-javascript",
        "Referer=http://www.bing.com/",
        "Snapshot=t4.inf",
        LAST);

    web_url("rmsloaderdelayed.js",
        "URL=http://www.bing.com/fd/sa/9_00_0_3325577/rmsloaderdelayed.js",
        "Resource=1",
        "RecContentType=application/x-javascript",
        "Referer=http://www.bing.com/",
        "Snapshot=t5.inf",
        LAST);

    web_url("5c8aa5b3.js",
        "URL=http://www.bing.com/rms/AutoSugBlue/jc/f209ebd2/5c8aa5b3.js?bu=rms+answers+AutoSuggest+Modules%24Service.source%2cApi.source%2cDataProviders%24GenericDataProvider.source%2cAutoSuggestCanvas_r.source%2cAutoSuggestLayoutBlue_r.source%2cAutoSuggestSearchForm_r.source%2cAutoSuggestSpelling_r.source%2cAutoSuggestHighConfGhosting_r.source%2cAutoSuggestInit_r.source",
        "Resource=1",
        "RecContentType=application/x-javascript",
        "Referer=http://www.bing.com/",
        "Snapshot=t6.inf",
        LAST);

    web_url("WindowsLiveConnect_c.js",
        "URL=http://www.bing.com/s/as/8_01_1_3345848/Identity/WindowsLiveConnect_c.js",
        "Resource=1",
        "RecContentType=application/x-javascript",
        "Referer=http://www.bing.com/",
        "Snapshot=t7.inf",
        LAST);

Flex Protocol In Loadrunner - Recording

Overview of Flex Protocol:

What is Flex:
Flex emulates a client and server application method. Flex uses different technologies to develop Rich Internet Applications using Flash Player. Adobe Flex is a powerful framework, using we can develop powerful interactive applications. These flex applications are set of MXML and some other files combinely play the script on the flash player or also called swf files.

Examples: Share market graphs, that change dynamically over the internet. Usually, these type of applications are developed using Adobe Flex.


Recording: We usually record this application with multi protocol web and flex protocol. 


Correlation in Flex Protocol: For regular web functions we use the web_reg_save_param function for correlation. For flex we use lr_xml_get_values and lr_xml_find functions to capture the values from the response. The name itself indicates that we are capturing xml values from the response.


The main value which we do correlation in Flex protocol is DSID.

Once you record the script in Flex protocol search for the DSID in the script, the one which comes first is where the dynamic DSID value generated. Sometimes the script generates DSID multiple times. So, we need be careful while doing correlation.

We need to use lr_xml_get_value function to correlate this value. If you are new to this function, go to response of that request and go through the xml path and find the DSID value in XML path, right click and click on save parameter. It will automatically create lr_xml_get_values.

A typical DSID value looks like this "8129988E-DC65-8CF6-B808-98760876GE98".

Please find the attached screenshot for your reference.


Jar Files in Flex Protocol: You need to use some common jar files for flex protocol in Loadrunner 11.4 and earlier versions. From Loadrunner 11.5 there is no need to use jars. The common jars are.

Flex-messaging-core. jar

Flex-messaging-common. jar
Flex-messaging-opt. jar
Flex-messaging-proxy. jar
Flex-messaging-remoting. jar

Make sure to map the jars in the correct path and upload in the controller. If you do changes to the path make sure they are updated in your run time settings as well. You can also update the jar paths in.usr file in vugen.


Issues and how to fix them: The Java version plays a vital role during the scripting part. Make sure you use the same Java version for all your scripting part and the execution part. If we use different Java version the xml paths will change, validation and the correlations will fail.


How to set Java path and Jars: You can set your Java path and jars in runtime settings of the script.

Use of Lr_continue on error()function


By Using  lr_continue_on_error:

By using lr_continue_on_error function we can include a portion of the script instead of whole script. We need to enclose the requests that we are getting error in between lr_continue_on_error(1) and lr_continue_on_error(0)

lr_continue_on_error(1); web_url("Google", "URL=http://www.google.com/", "TargetFrame=", "TargetBrowser=Google ", "Resource=0", "RecContentType=text/html", "Snapshot=t1.inf", "Mode=HTML", LAST ); lr_continue_on_error(0);

Thursday, 6 October 2016

Test Plan-APPLICATION WISE REQUIREMENT GATHRING

APPLICATION WISE REQUIREMENT GATHRING
     Types of application and its architecture? (Application wise requirement gathering)
       Application:
·         What is the application type?  ( E.g. Desktop, Web or Mobile App,thick client or any other)
·         In what Technology/platform the application is developed?
(E.g. J2EE, .Net, PHP, Silverlight, Ruby, SAP, Siebel, Any other)
·         Architecture diagram: Different layers of servers (2-tier/3 tier)
·         Details of types /no’s of servers available for the applications
• Application Servers (how many)? Existing capacity (CPU, memory, disk space etc.)
• Web Servers (how many) Existing capacity (CPU, memory, disk space etc.)
• Database Servers (how many) Existing capacity (CPU, memory, disk space etc.)
• Others (Please specify) (how many) Existing capacity (CPU, memory, disk space etc.)

·         Is environment under test (EUT) identical to production?
·          Will the EUT be dedicated for performance testing during the testing period?
·          Will cache memory be turned off on servers during testing?
·         Do we have monitoring tools installed to check health of servers
·         Admin rights on servers
·         Who are the persons responsible for supporting and monitoring all components under test? (Provide list of names, contact no, and include off -hour numbers, if applicable.)
• Developers
• System Administrators
• Network Administrators
• DBA’s others
-        
·         How servers communicate with each other
·         About server Load balancing/(active passive)
·         What is the communication protocol between the client and server? 
(HTTP, HTTPS, FTP, TCP/IP, Telnet, Siebel etc.)
·                     How is the application accessed? Can we obtain immediate access to the application for test feasibility purposes? Is application  is having [A] User Interface or [B] batch job processing or [C] Other
[A] If Is application accessible through browser or interface
         - Is application runs on specific browser/version?
         - Is application needs to access from citrix?
          - Is there a Login and password requirement?
          - How does the application functional knowledge training is conducted?
          - How to navigate the application
          - Necessary credentials required to access the application?
          - What is the current test window? (Any specific window available for performance test?)
          - What is the test requirement/objective in terms of load and/or performance?
          - Any specific requirements on location wise load?
          - For how many users its needs to be run? Please create test users in that case.
          - Any preference on performance tools? (e.g. HP loadrunner)
          - Who is going to provide performance testing tool? (BMW/Cognizant)
          -  Do we need to execute test from different locations which hits to same servers? (Load generator agents needs to installed at those locations)
          - What is the peak load time on production server?
          - On peak load time, roughly how many users are accessing the system?
          - Any SLAs on transactions response time?

          [B] Batch Job processing (EPA or ETL)
          - What is the type of applications?
          - How to access this application (how to trigger the file execution of job execution)
          - What are components needs to check? How to check? How to access?
          - Are we going process file in terms of size (e.g. size 2 GB) or # of records (1 million records)?
          - Are we going to check how much time taken to process above file and records?
          - Do we have specific tool or logs wherein we can check the processing time taken by business logic?
          - Do we have UI involved on this?

          - As per understanding we will execute files (with separate size or records) and check the processing time of those separately and server resources as base line. Right?

Friday, 16 September 2016

LoadRunner - Selecting random value using lr_paramarr_random function


In performance testing, it is really important to simulate a realistic user path through an application. For example, randomly select an image link from a gallery or select a share from a share list. In such situations, you can use the LoadRunnerlr_paramarr_random function to select a random value from a captured parameter array. Similarly, you can also write a code to do the same.

Before you use the above function, you will need to use web_reg_save_paramfunction to capture all the ordinal values. This can be achieved by passing "ORD=ALL" into the function.

The following code demonstrates the use of lr_paramarr_random function. The code saves link Ids using  web_reg_save_param function and then useslr_paramarr_random function to randomly select an Id value. The value is passed as a parameter in web_text_link function to navigate to the appropriate webpage.

Action()
{

 //Capture all the Link IDs
 web_reg_save_param("LinkID","LB=id=\"","RB=\" href=\"default.aspx?content=business_","ORD=ALL",LAST);

 lr_start_transaction("VU01_01_Homepage");
 web_browser("website", 
  DESCRIPTION, 
  ACTION, 
  "Navigate={WebsiteUrl}", 
  LAST);

 lr_end_transaction("VU01_01_Homepage",LR_AUTO);

 lr_think_time(10);


 //Save a randomly selected ID to a Parameter
 lr_save_string(lr_paramarr_random("LinkID"),"RandomLink"); 

 //Printout the randomly selected parameter
 lr_output_message("%s",lr_eval_string("{RandomLink}"));

 //Navigate to the appropriate webpage associated to the ID
 lr_start_transaction("VU01_02_RandomLink");

 web_text_link("Links", 
  "Snapshot=t2.inf", 
  DESCRIPTION, 
  "Id={RandomLink}",
  ACTION, 
  "UserAction=Click", 
  LAST);

 lr_end_transaction("VU01_02_RandomLink",LR_AUTO);
 
 web_browser("Sync", 
  "Snapshot=t3.inf", 
  DESCRIPTION, 
  ACTION, 
  "Sync", 
  LAST);

 return 0;
}
Following is a screenshot of replay log, displaying the random id's selected for each iteration. It also displays the values captured using web_reg_save_param function. 

Wednesday, 14 September 2016

MQ scripting vugen code for pushing message in Queue


            //Message Injection loop
            for(i=0;i<injectionRate;i++)
            {

                if (numberOfMsgsInjected==totalMessages)
                                break;
                try
                {
                text.delete(0,text.length());
                //appending the xml message.
                text.append(lr.eval_string("<Items MessageType=\"ADJUSTMENT\"><Item AdjustmentType=\"ADJUSTMENT\" Availability=\"TRACK\" ItemID=\"[ItemID]\" OrganizationCode=\"DEFAULT\" ProductClass=\"GOOD\" Quantity=\"10\" RemoveInventoryNodeControl=\"Y\" ShipNode=\"[BrandID]\" SupplyType=\"ONHAND\" UnitOfMeasure=\"EACH\"></Item></Items>"));

                //Convert to String 
                String str = text.toString();
                System.out.println(str);
       
                //Creating Message Queue
                MQMessage XMLMessage = new MQMessage();

                //Setting Message format
                XMLMessage.format = "MQSTR";
                //UTF encoding Supports
                XMLMessage.writeString(str)
               
                System.out.println("string" + XMLMessage);                  
                  // specify the message options...
            
                  MQPutMessageOptions pmo = new MQPutMessageOptions();    // same as MQPMO_DEFAULT
            
                 // put the message on the queue
            
                  qName.put(XMLMessage,pmo);
                  numberOfMsgsInjected = numberOfMsgsInjected + 1;
                   lr.start_transaction("MessageSend");
                  System.out.println("msg sent ...");
                  lr.end_transaction("MessageSend",lr.PASS);
                               
                }

                catch(Exception e)
                {
                System.out.println("error here");
                e.printStackTrace();
                System.exit(0);
                }

            }

            //Getting the time stamp in millisecond after message injection.
            timeInMillis2 = System.currentTimeMillis();
           
        //Calculating the message injection rate
        double timespend = (double)(timeInMillis2 - timeInMillis1);
        double injectionIntervalMillisec = multiplyingFactor * injectionInterval * 1000;
        try
        {

            if(injectionIntervalMillisec > timespend)
            {
           
            Thread.sleep((long)(injectionIntervalMillisec-timespend));
            
            }
        }
            catch (Exception e)
            {}

        if (numberOfMsgsInjected==totalMessages)
         {

            lr.exit(lr.EXIT_VUSER,lr.PASS);
         }

    return 0;
    }//end of action

 /**
 * LoadRunner method to terminate the established  connection
 * with middleware.
 */

    public int end() throws Exception
    {
        // Close the queue...
        qName.close();

        // Disconnect from the queue manager 
        qMgr.disconnect();
        return 0;
    }//end of end

}

Friday, 9 September 2016

Validation check in web services protocol using lr_XML_get_values()

The function lr_xml_get_values executes queries on the string xml_input. The results of each query are stored in the parameter Result.

#include "as_web.h"

/* The XML Data */
char *xml_input=
"<acme_org>"
     " <accounts_dept>"
          "<employee>"
               " <name>Kevin Sharp</name>"
               "<cubicle>227</cubicle>"
               "<extension>2145</extension>"
          "</employee>"
     "</accounts_dept>"
     "<engineering_dept>"
          "<employee>"
               "<name>John Smith</name>"
               "<cubicle>372</cubicle>"
               "<extension>2970</extension>"
          "</employee>"
          "<employee level=\"manager\">"
               "<name>Sue Jones</name>"
               "<extension>2375</extension>"
          "</employee>"
     "</engineering_dept>"
"</acme_org>";

Action() {
    int query_number = 1;
// Save data as parameter
    lr_save_string(xml_input, "XML_Input_Param");
    /* Query 1: Find the first employee's name
        (To find the names of all employees
        see Multiple Query Matching)    */
    lr_xml_get_values("XML={XML_Input_Param}",
        "ValueParam=Result",
        "Query=/acme_org/*/employee/name",
        LAST );
    /* Query 2: Find the first extension number one
        or more levels deep */
    lr_xml_get_values("XML={XML_Input_Param}",
        "ValueParam=Result",
        "Query=//extension",
        LAST );
    /* Query 3: Find the name of the manager
        of the engineering department. */
    lr_xml_get_values("XML={XML_Input_Param}",
        "ValueParam=Result",
"Query=/acme_org/engineering_dept/employee[@level=\"manager\"]/name",
        LAST );
    /* Query 4: Find the name of an employee
    whose extension number is 2970 */
    lr_xml_get_values("XML={XML_Input_Param}",
        "ValueParam=Result",
        "Query=/acme_org/*/employee[extension=\"2970\"]/name",
        LAST );
    return 0;
}
Output from Execution Log Window:
Action.c(33): Saving Parameter "Result = Kevin Sharp"
Action.c(33): "lr_xml_get_values" was successful, 1 match processed
Action.c(37): Saving Parameter "Result = 2145"
Action.c(37): "lr_xml_get_values" was successful, 1 match processed
Action.c(41): Saving Parameter "Result = Sue Jones"
Action.c(41): "lr_xml_get_values" was successful, 1 match processed
Action.c(46): Saving Parameter "Result = John Smith"
Action.c(46): "lr_xml_get_values" was successful, 1 match processed