Tuesday 9 December 2014

Baseline and Benchmark Testing

Baseline Testing: is a process of testing an application with one or set of test scripts to obtain some metrics(Test Results), and these metrics(Test Results) acts as baseline for future iterations of tests with similar or different configurations.

  • Generally baseline tests are conducted with low user loads(1, 5, 10).
  • Baseline test results acts as reference for future iterations of tests.
  • 90% of issues can be found upon proper baseline testing.


Benchmark Testing: is a process of testing an application with one or set of test scripts and comparing test results with previous test results or industry standards.

  • Generally benchmark tests are conducted at moderate/high user loads(200, 500..etc).


Thursday 27 November 2014

Creating dynamic post parameters using Jmeter

If post data(Name - Value pair) of  a request changes dynamically, then you need to construct the same from the response of previous requests. To do that in jmeter add "Beanshell PreProcessor /JSR223 PrePocessor" as a child to the corresponding request and use following code.


sampler.addArgument("Name", "Value");


Eg:





Thursday 20 November 2014

Random Co-relation in Web http/html Load Runner

Use following LR function to extract all the elements from the response

web_reg_save_param_ex("ParamName=cseatPref",
                                         "LB=name=\"seatPref\" value=\"""RB=\"",
                                         "Ordinal=ALL"LAST);

lr_save_string(lr_paramarr_random("cseatPref"), "cSeatPref_Value");

//lr_paramarr_random() function selects a random value from all extracted values
//lr_save_string() function saves value to a new variable

Replace seat preference value with {cSeatPref_Value} as following

web_submit_data("reservations.pl",
        "Action=http://127.0.0.1:1080/cgi-bin/reservations.pl",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/cgi-bin/reservations.pl?page=welcome",
        "Snapshot=t4.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=advanceDiscount", "Value=0", ENDITEM,
        "Name=depart", "Value={cDep_City}", ENDITEM,
        "Name=departDate", "Value={Dep_date}", ENDITEM,
        "Name=arrive", "Value={cAri_City}", ENDITEM,
        "Name=returnDate", "Value={Arri_date}", ENDITEM,
        "Name=numPassengers", "Value=1", ENDITEM, 

      "Name=seatPref", "Value={cSeatPref_Value}", ENDITEM,
      "Name=seatType", "Value={c_SeatType}", ENDITEM,      
        LAST);

Tuesday 18 November 2014

HTML vs. URL based scripting Load Runner

Load Runner has two types of recording options


  • HTML based scripting
  • URL based scripting

HTML:

  • It records/captures a user scenario similar to how a user interacts with an application, it can be called as browser context recording.
  • It will not send any explicit requests to static resources (.css, .js, .png...etc) or dependent requests, but downloads them automatically along with main request, unlike the URL based scripting
Script Type 1: A script describing user actions (eg: web_link, web_submit_form)

  • web_link, web_submit_form..etc are context sensitive functions and they depend on previous operations.
  • It works at HTML level(i.e DOM elements level)
     Eg:





As shown above web_image function("Search Flight Button") works only when the DOM elements (i.e <IMG> and its attributes) are loaded upon successful completion of previous operations.

Script Type 2: A script containing explicit URLs  only (eg: web_url, web_submit_data)
  • web_url, web_submit_data..etc are context less functions and they are independent of previous operations.
  • It works at HTTP level (i.e Request - Response based) 
     Eg: 

Observe that "search flight button" is recorded as web_url function, it sends an explicit request(i.e using URL attribute) when user clicks 'Flight' button, so it is independent of previous operations.

URL:


  • It will send explicit requests to static resources (.css, .js, .png...etc) and dependent requests along with main request.(refer below screenshot)
  • Its a context-less recording unlike the HTML based scripting.
  • It works at HTTP level (i.e Request - Response based).
Script Type 1: Create concurrent groups for resources after their HTML page

  • Records URLs and their resources in concurrent groups, a concurrent group represents links and resources that are loaded on a page at the same time.
      Eg: 



Observe that for a 'Search Flight Button' action, it records dependent and static resources requests       explicitly(web_concurrent requests) along with main request. (i.e all the web_concurrent group requests above belongs to "Search Flight Button" action).

Script Type 2: Use Web Custom Requests only


  • It records all requests as web_custom requests
  • The web_custom_request function is an action function that allows you to create a custom HTTP request using any method or body.
     Eg: 





Note: What kind of recording options to be selected depends on kind of application and how you want to emulate the scenario, but generally "HTML" with "Script Type 2: A script containing explicit URLs  only (eg: web_url, web_submit_data)" is preferred. 

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

Friday 1 August 2014

Adaptive bitrate streaming

Adaptive bitrate streaming is a technique used in streaming multimedia over computer networks. While in the past most video streaming technologies utilized streaming protocols such RTP with RTSP, today's adaptive streaming technologies are almost exclusively based on HTTP and designed to work efficiently over large distributed HTTP networks such as the Internet.
It works by detecting a user's bandwidth and CPU capacity in real time and adjusting the quality of a video stream accordingly. It requires the use of an encoder which can encode a single source video at multiple bit rates. The player client switches between streaming the different encodings depending on available resources. "The result: very little buffering, fast start time and a good experience for both high-end and low-end connections.

More specifically, and as the implementations in use today are, Adaptive bitrate streaming is method of video streaming over HTTP where the source content is encoded at multiple bit rates, then each of the different bit rate streams are segmented into small multi-second parts. The streaming client is made aware of the available streams at differing bit rates, and segments of the streams by a manifest file. When starting, the client requests the segments from the lowest bit rate stream. If the client finds the download speed is greater than the bit rate of the segment downloaded, then it will request the next higher bit rate segments. Later, if the client finds the download speed for a segment is lower than the bit rate for the segment, and therefore the network throughput has deteriorated, then it will request a lower bit rate segment. The segment size can vary depending on the particular implementation, but they are typically between two (2) and ten (10) seconds.


Traditional HTTP and Progressive Download

Ø  Traditional HTTP: Early experiments with delivering video via HTTP were less than satisfactory for a number of reasons, not the least of which was the limited bandwidth available in the 28/56Kbps modems of the day. The first video files posted on the web were delivered via download and play, which mean they had to be fully downloaded before playback began.


Ø  Progressive Download: Progressive Download is the most widely used video delivery method by far (in part because it's what YouTube uses). It's also easiest to implement: just put a video on your webserver and point your player to the URL. Once a user hits play, the player immediately starts downloading the file. The player will start video playback as soon as it has enough data to do so, but it will continue to download until it has received the whole file (hence the progressive) 



In most cases (Flash needs a small server module), it is possible to seek in a player to a not-yet- downloaded part of the video. At that point, the player re-downloads the video, starting at the seek offset instead of at the beginning. We call that feature pseudo-streaming.

What is Streaming media?


·         Streaming media is video or audio content sent in compressed form over the Internet and played immediately, rather than being saved to the hard drive.

With streaming media, a user does not have to wait to download a file to play it. Because the media is sent in a continuous stream of data it can play as it arrives. Users can pause, rewind or fast-forward, just as they could with a downloaded file, unless the content is being streamed live.

RTMP/RTSP Streaming:  This method uses specialized webservers that only deliver the frames of a video the user is currently watching. No data is downloaded in advance and data a user has seen is immediately discarded.
·         RTMP can do live streaming, so people can watch your video while it is being recorded.
·         RTMP can do dynamic streaming, where the video quality (i.e. adaptive bitrate) automatically adjusts to changes in bandwidth.
·         Players can seek to later parts in a video, which is particularly useful for files > 10 minutes.
·         Players maintain a tiny buffer, instead of downloading a video during playback, saving bandwidth.



Disadvantages
·         RTMP uses different protocols and ports than HTTP, which makes it vulnerable to getting blocked by (corporate) firewalls. This issue can be prevented by streaming in RTMPT (tunneling over HTTP), which comes at a server performance cost. 

·         RTMP data is streamed to the player, which means the bandwidth of the connection must be larger than the data-rate of the video. If the connection drops for a couple of seconds, the stream will stutter. This issue can largely be prevented by using dynamic streams that include a low-quality file.

Tuesday 29 July 2014

What is Performance Testing?

A process that determines the behavior of an application in terms of Speed, Stability, Scalability and finds bottlenecks(if any)

Speed: How many seconds does an application takes to respond.
Stability: How application behaves under varying load.
Scalability: Can an application withstand, if load(Number of users or transactions) is increased in future.


Different types of Performance Testing