Friday 31 October 2014

Dynamic Item data Load Runner

I want to construct following Itemdata (Name-Value Pair)

"txtEditBookmarkDescription_Row26=LoadTest_7925&txtEditBookmarkDescription_Row26=LoadTest_7925&txtEditBookmarkDescription_Row26=LoadTest_7925&txtEditBookmarkDescription_Row26=LoadTest_7925"

cAllBKNamesis a variable consists of all Names extracted from the response using web_reg_save_param_ex and ordinal is All
cAllBKIDs: is a variable consists of all Values extracted from the response using  web_reg_save_param_ex and ordinal is All

Code:

        char *ItemData;                 //Final String consists of concatenated Name-Value Pairs 
        int count, i, size=0;           //Count : number of Name-Value Pairs to be concatenated
        char *str1, *str2;              //Temporary strings

count = atoi(lr_eval_string("{cAllBKNames_count}"));
        lr_output_message("%d",count);

        for(i = 1; i <= count; i++)
          {
       
                str1=lr_eval_string(lr_paramarr_idx("cAllBKNames",i));
                str2=lr_eval_string(lr_paramarr_idx("cAllBKIDs",i));
                size = size + sizeof("&") + strlen(str1) + strlen("=") + strlen(str2);  // Calculating final size   
          }


  ItemData = (char*)calloc(size, sizeof(char));  // Allocating dynamic memory based on size of  final string                                                                                    
        //Building actual string to ItemData variable

        for(i=0; i< count; i++)
{
str1=lr_eval_string(lr_paramarr_idx("cAllBKNames",i));
                 str2=lr_eval_string(lr_paramarr_idx("cAllBKIDs",i));                
                 strcat(ItemData,str1);
strcat(ItemData,"=");
strcat(ItemData,str2);
strcat(ItemData,"&");
}

lr_output_message("%s", ItemData);

free(ItemData);

Convert Current Date and Time to Unix Time Stamp (Epoch)

What is Unix/Epoch time?
The 
Unix time-stamp(epoch time) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT).

C# Code for Unix Time-stamp in milliseconds

public static string Unix_TimeStamp()
{
return (Math.Truncate((DateTime.UtcNow-new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds).ToString());
}

Unix Time-stamp in milliseconds for Jmeter

${__javaScript(new Date().getTime())}




Tuesday 21 October 2014

Co-relation and Parameterization

Co-relation: is a process of capturing(extracting) dynamic data from the response of a request and passing it to next/subsequent requests.

Note: The process of co-relation is different in different tools.


Parameterization: is a process of passing static(known) data to a request(s). Generally, values to be passed/parameterized are saved in a file(.csv).

eg:  Usernames and passwords...etc


What values need to be co-related and what values need to be parameterized?

It depends on

1. Dynamic/static data?

2. Volume of data need to be parameterized?
3. Complexity involved in co-relation

eg: Consider an eCommerce application with following transactions


1. Log in to the eCommerce application with Username and Password(Parameterization)
2. Select a random product out of l lac products(Co-relation)
3. Add to cart

Now, you want to load test above test case/test script with 1000 users

Step 1: 

Log in to the eCommerce application with Username and Password

To do that you need 1000 usernames and corresponding passwords before starting a load test, in this case you have to put all usernames and passwords in a file(.csv) and pass to corresponding request. This is called Parameterization

Step 2:

Select a random product out of l lac products

To select a random product from l lac products, its not feasible to put all 1 lac products in a file and pass it to corresponding request, because it creates lot of overhead, instead write a co-relation rule to select a random product from available 1 lac products.

Additional Info

If an application is a .net based application then there will be page state variables such as View State, Event Validation, Event Target..etc these values will change for every page in this case you need to co-relate these values.

If an application has select box with 4 values(IT, CSC, ECE, Mech) and they constant for every user, then parameterization is feasible here instead of co-relation.


Note: What values need to be co-related and what values need parameterized are majorly depends on the application context, Co-relation will have more overhead on a load test when compared with Parameterization.








Friday 17 October 2014

Different types of Video Delivery Methods

Types of Performance Testing





























  


Load Testing

a) To verify application behavior under normal and peak load conditions.
b) It enables you to identify Response times, Throughput and Resource utilization.
c) To identify your application’s breaking point, assuming that the breaking point occurs below the peak load condition.
d) Load Testing an application over an extended period of time is Endurance Testing.


Load Testing


Stress Testing

a) To determine or validate an application’s behavior when it is pushed beyond normal or peak load conditions.
b) The goal of stress testing is to reveal application bugs that surface only under high load conditions. These bugs can include such things as synchronization issues, race conditions, and memory leaks.
c) Spike testing is a subset of stress testing, done by suddenly increasing the number of or load generated by, users by a very large amount and observing the behavior of the system.


Stress Testing
Capacity Testing

a) To determine how many users and/or transactions a given system will support and still meet performance goals.
—b) To accommodate future loads, you need to know how many additional resources (such as processor capacity, memory usage, disk capacity, or network bandwidth) are required.



Capacity Testing
  



Monday 13 October 2014

Co-relation in TRUclient Ajax Load Runner



When you want to randomly select an option from the list (i.e an option from <select> tag), TRUclient automatically records it as select statement and you just need to set Ordinal value to 0(random), 1(First occurrence)....etc

But, when you want to randomly extract inner-html of  SPAN/Div elements use below code

Step 1: Insert a Evaluate JavaScript component from tool box after the step from whose response you want extract innerHTML




Step 2:  Insert below code into Argument section of Evaluate JavaScript Component




var x = document.querySelectorAll("Span[id^=\"agcDiscountType_Row\"]"); //Storing all span elements with "id" starting with "agcDiscountType_Row" in X;
var index = Math.floor((Math.random()*(x.length))+1);  //Selecting a random number from total number of Span elements
var req = document.querySelector("Span[id=\"agcDiscountType_Row"+index.toString()+"\"]"); //Selecting a random Span element
window.alert("Span[id=\"agcDiscountType_Row"+index+"\"]"); 
var value = req.innerHTML; //Extracting innerHTML of randomly selected Span Element
window.alert(value); 

Parameterization in TRUclient Ajax Load Runner

Step 1: Record your Test Script/User Flow

Step 2: Create a file/string parameter in Parameter List of your Load Test Script(refer Load Runner Parameterization)

Step 3: Expand the step which you want to parameterize and refer screenshot below to parameterize

Tru Client Parametrization



pUsername is the name of the parameter created in your parameter list