Tuesday, June 1, 2010

Traceroute in Windows.

What is Traceroute in Windows ?

The traceroute utility checks how many "hops" (transfers through other computers on a network) it takes for your computer to contact another computer. You can use traceroute if you know the other computer's IP address, web site address, or name (e.g., 192.193.246.50, www.citibank.co.in).

Traceroute works by increasing the "time-to-live" value of each successive batch of packets sent. The first three packets sent have a time-to-live (TTL) value of one (implying that they are not forwarded by the next router and make only a single hop). The next three packets have a TTL value of 2, and so on. When a packet passes through a host, normally the host decrements the TTL value by one, and forwards the packet to the next host. When a packet with a TTL of one reaches a host, the host discards the packet and sends an ICMP time exceeded (type 11) packet to the sender, or an echo reply (type 0) if its IP address matches the IP address that the packet was originally sent to. The traceroute utility uses these returning packets to produce a list of hosts that the packets have traversed in transit to the destination. The three timestamp values returned for each host along the path are the delay (aka latency) values typically in milliseconds (ms) for each packet in the batch.

If a packet does not return within the expected timeout window, a star (asterisk) is traditionally printed. Traceroute may not list the real hosts. It indicates that the first host is at one hop, the second host at two hops, etc. IP does not guarantee that all the packets take the same route. Also note that if the host at hop number N does not reply, the hop will be skipped in the output.


At the command prompt, if you enter tracert www.citibank.co.in , you should see something similar to the following screenshot.

To reach "www.citibank.co.in" packet took  17 hops(routers).

The first column, the hop count, represents the number of stops your information has made along the route to attempt to contact the other computer. The next three columns are the round-trip times in milliseconds for three different attempts to reach the destination. The last column is the name of the host that responded to the request.

Hop 1 - 10.0.0.1 - My wireless router IP.
Hop 2 - 192.168.1.1 - My ISP(Airtel Broadband) local IP.
Hop 3 to 6 - My ISP(Airtel Broadband) IP.
...
Hop 17 - Citigroup IP.

You can also use pathping -n www.citibank.co.in

For better understanding of host details look into following sites
http://network-tools.com/
IP or Server Details.





----

Performance Testing - Three Tips.

Performance Testing - Three Tips.


Testing database-backed applications for performance can be a daunting task. The worst-case scenario: Performance testing efforts drain engineering resources and yet somehow nasty surprises still manage to pop up in production.
These three tips can help you get the most out of your application performance testing efforts.
  1. Set clear performance metrics and targets with input from business stakeholders. Ideally this should be part of the system requirements and user acceptance testing. Otherwise, without obvious targets to hit, performance testing becomes an open-ended slog that may still leave end users dissatisfied with system performance if their expectations have not been accounted for. 
  2. Don't forget the database. For Web-based transactional systems, in particular, the most common metrics are number of concurrent user sessions and response time. Applications also are frequently load-tested to check the impact of ramping up the number of concurrent sessions. However, a single user with the entire system to himself can still experience vastly different performance, depending on the amount of data already in the database. One single user transaction can be lightning fast if it's inserting into an empty table, but it degrades as the table grows to thousands or millions of records. So, performance requirements should also include metrics for expected data sizing, and this sizing should be incorporated in the test environment.  
  3. Don't over design for performance. Some consideration needs to be given to scalability when sizing the initial architecture and making hardware purchases, of course, but there's only so much you can optimize on a system that hasn't been built yet. Get feedback from real users to figure out which parts of the system are most frequently used so you don't waste time optimizing rarely used features. Also, performance tweaks often carry some tradeoffs, such as readability and maintainability, so you need some baseline performance metrics to make good decisions. Don't make big design sacrifices for small optimizations.  

Performance Testing ?

What is performance testing ?

Performance testing is the process of determining the speed or effectiveness of a computer, network, software program or device. This process can involve quantitative tests done in a lab, such as measuring the response time or the number of MIPS (millions of instructions per second) at which a system functions. Qualitative attributes such as reliability, scalability and interoperability may also be evaluated. Performance testing is often done in conjunction with stress testing.
Performance testing can verify that a system meets the specifications claimed by its manufacturer or vendor. The process can compare two or more devices or programs in terms of parameters such as speed, data transfer rate, bandwidth, throughput, efficiency or reliability.
Performance testing can also be used as a diagnostic aid in locating communications bottlenecks. Often a system will work much better if a problem is resolved at a single point or in a single component. For example, even the fastest computer will function poorly on today's Web if the connection occurs at only 40 to 50 Kbps (kilobits per second).
Slow data transfer rate may be inherent in hardware but can also result from software-related problems, such as:
Effective performance testing can quickly identify the nature or location of a software-related performance problem.

Performance Testing - On LAN and over the Internet (WAN).

What is cloud load testing?


---

Friday, May 28, 2010

Performance Testing - On LAN and over the Internet(WAN).

Performance Testing - On LAN and over the Internet (WAN).

Generally we have performance test setup, where application servers and load injectors(generators) residing on the same LAN. We perform the tests and compare the response time reports with the SLA(Service Level Agreement) and declare test is PASSED.
When the same application is deployed on the data-center(Production Environment) and remote clients(real users) start accessing the application, they would notice difference in response time, that is not matching with the SLA. 

Why are clients accessing the same application observing high response time,which is running on similar hardware, that is TESTED & PASSED by the performance testing team ?

Why in many cases applications fail to perform to expected levels, despite load testing prior to roll-out?

We have been focusing on identifying software and hardware bottleneck, not considering the real world conditions like network impact, end user bandwidth etc.

There is difference between testing the application on LAN and over the internet.

Following factors effect the application response time when the request travel through internet.
1. Pack Loss - In internet terminology, every communication is sent as data packets.
A packet is a sequence of bytes and consists of a header followed by a body. The header describes the packet's destination and, optionally, the routers to use for forwarding until it arrives at its final destination.
Due to noise, some of the packets are lost or distorted. 
2. Packet Latency - All the packets will not travel the same path for a specific destination, internet nodes will select the shortest destination route based on number of factors,  if some of the packets are delayed, construction of the response would get delayed, in-turn response time.
Understand, how many hosts(routers) packet need to travel to reach destination server.
3. Packet Effects - Dynamic IP packet routing effects, including out-of-order packets, duplicated packets,
fragmentation phenomena, and TTL Effects (Time-to-live, decrement counter. Field in the packet header to count number of routers packet passed through) .
4. Link Faults - Possible damages to bit streams and possible disconnections.
5. Congestion - Sharp spikes in internet traffic, which may result in high latency or packet loss, or both.
6. Outgoing and Incoming Bandwidth - If your application throughput is not matching with the network, it would create congestion and increase response time.


Why is this effecting the server performance?
When data packets are lost, request  would be incomplete, so the application server has to resend the lost packets again with extra effort on the CPU. The stress on the servers increases, since more resources are needed to support remote end-users. Sessions are open longer, OS resources are occupied for more time and more concurrent threads are needed.

Without incorporating the above factors(WAN effects) into a load test, memory usage, thread usage, connection pool utilization, network stack, and other critical server resources can be significantly understated.


Select this link to understand internet line quality. 


Now, how to conduct TRUE performance test by taking above factors into consideration ?


Approach 1:  Install load generators at client location, where real users are accessing the application. This is a tedious process, clients network may choke during load test and security related issues my exist.

Approach 2: Perform test on your LAN by emulating the above factors. To create above factors locally, we need to use WAN Emulators.This can be achieved by using SHUNRA Virtual Enterprise Suite, it can record the above said factors from a remote user (or) real user and emulate the same in the LAN. Shunra provide plug-in software for Loadrunner. 

Approach 3: Generating load from cloud. What is cloud load testing? 
There are companies that can simulate load for any number of users from any part of the globe using cloud testing services (such as Amazon EC2)

For more information look into Cloud Load Testing.

Approach 3: Estimate impact of the network - Separately estimate the impact of the network on an application being deployed and manually factor that into result reports and deployment readiness findings.
This provides partial insight into the impact of the network, but totally ignores the interrelationships that network performance has on the application logic.Whenever the application logic or infrastructure configuration changes, there is an ongoing risk of encountering an unanticipated adverse impact and unhappy users.

Approach 4: Generate load from your premises in such a way that you are hitting the data center or production environment through internet. But purchasing or leasing hi-capacity internet lines just for conducting load test is very costly. If your internet connection capacity is less then the application throughput, your results will be incorrect.

Approach 5:  By using third party load generation services like Gomez  and Keynote. 


Gomez network exist in 168+ countries and 2,500+ ISP's. It consist of 500+ combinations of browsers and OS, 150+ commercial data centers, 5,000+ mobile supported devices and 1,50,000+ commercial grade desktops through which it is possible to generate enormous real user load. Internet giants like Google, Yahoo, FaceBook, LinkedIn... use these services. I feel it is ultimate in load testing for predicting true results. 

Attaching Gomez Network Screen shot.


Attaching Gomez Recorder screen shot, that records user actions on the page (similar to Loadrunner Click & Script protocol)

Attaching Gomez node selection (Load Generator) screen shot by Country|City|ISP.
Attaching Gomez results screen shot by City|ISP



Before analyzing results, always make sure that bandwidth is not the bottleneck. 



While performing tests over internet always compare internet bandwidth with the application throughput of all the virtual users. For example, if you are running test with 100 virtual users and consolidated throughput is 20Mbps, make sure your internet bandwidth is more than 20Mbps. If your application throughput and bandwidth don't match, there would be packet congestion, high response time is record, here it is not the problem with the application server but with the network.

While conducting performance test, response time should increase when more users are added, only when server CPU or other counters touch maximum limit, if this not the case, there would be some issue in the network or load generators.

Following posts are also related to performance testing.

Performance Testing Configuration or Setup
Performance related issues between browser and server
Performance Testing - TTFB, TTLB
Browser wars & End user performance, content display impact
Analyze Browser - JavaScript, AJAX, Rendering Details





---

Performance Testing - Validate server response.

Performance Testing - Validate server response.

For every request sent by client, server respond by sending the response.
In any performance testing tool following are the ways through which response can be validated.
In some tools these validations are performed by writing code, others by using GUI.

1. Check response status code. HTTP status code list.
2. Check response duration, whether the duration satisfy the SLA.
3. Check response size to make sure entire content is delivered by the server, measured in bytes (Greater than or equal to x bytes).
4. Verify response content. Content consist HTML, script...., not possible to verify the enter content. Place checkpoints on messages, id's, conformation text...



-----

Performance : Load : Stress Testing

Performance : Load : Stress Testing

Performance testing is an empirical technical investigation conducted to provide stakeholders with information about the quality of the product or service under test with regard to speed, scalability and/or stability characteristics. It is also the superset of other classes of performance-related testing such as load and stress testing.
A load test is a performance test focused on determining or validating performance characteristics of the product under test when subjected to workload models and load volumes anticipated during production operations.
A stress test is a performance test focused on determining or validating performance characteristics of the product under test when subjected to workload models and load volumes beyond those anticipated during production operations. Stress tests may also include tests focused on determining or validating performance characteristics of the product under test when subjected to workload models and load volumes while the product is subjected to other stressful conditions, such as limited memory, insufficient disk space or server failure.




-----

Tuesday, May 25, 2010

Loadrunner - Web(HTTP/HTML) Vs WEB,AJAX(Click & Script) protocol

Loadrunner - Difference between Web(HTTP/HTML) and WEB,AJAX(Click & Script) protocol in terms of virtual user

Web (HTTP/HTML) protocol script consist of series of requests written in C functions. Loadrunner start processing the requests one by one, once request is completed after receiving the response, it just forget what happened and proceed with the next request, so it consume less memory and don't process any web page code. Single web page consist of multiple requests and responses. Need to correlate the entire dynamic content,

Where as click & script protocol virtual user is a hidden browser like HtmlUnit, it works similar to the real browser by executing the web page code, so correlation is not required . By using very limited object properties, HP could implement QTP technology into this protocol. User can also access page DOM using java script similar to .Object in QTP. Naturally it consume more memory and create more load on load injectors. No correlation is required for the dynamic content, it is similar to the QTP scripts running in C style. If there are grid items and similar objects need to handle objects Html ID's.

Major issues with this protocol - Some GUI objects are not recognized, load generator hardware requirements, memory and CPU usage is unpredictable, when used with application having heavy AJAX and third party controls. 

If the application is using heavy AJAX and third party controls, it may consume lot of memory and CPU usage. Always monitor load generator memory and CPU usage, it should not go beyond 80%.
In these situation, we do have following issues when virtual users are running as "thread".
Some of the virtual users may fail with the following error message
Action.c(360): Error: C interpreter run time error: Action.c (360):  Error -- memory violation : Exception ACCESS_VIOLATION received.
Function Specific error
Action.c(360): Notify: CCI trace: Action.c(360): web_browser(0x02081b03 "Java_Script", 0x0208214f "ACTION", 0x02081292 "EvalJavaScript=igtbl_getRowById('ctl00xc...", 0x02082111 "LAST")
In-order to overcome above error, run the virtual user as "process" instead of "thread", now virtual users are stable and each is assigned separate memory.
Loadrunner create virtual user using mmdrv.exe process, if virtual users are running as process, virtual user count and mmdrv.exe process in the task manager count will be same.
Install load injectors with Windows 2003 64bit to accommodate more memory.

How to handle objects not identified by AJAX protocol.





---

Test Broadband or Internet speed and line quality.

Test Broadband or Internet speed and line quality.

Every one would be curious in understanding speed and quality of the internet that you are using.

Speed of the connection is measured in Upload and Download speed.
First we will understand unit of measurement for internet speed.

1 Mbps(megabits per second) = 1000 Kbps(kilobits per second) = 125 KBps(kilobytes per second)

Always pay attention to (b)Bits and (B)Bytes.
Generally service providers(Airtel, Tata Communications, Youtele) measure the speed in  Mbps or Kbps.
When you are downloading the file from the internet, most of the browsers measure the speed in KBps.
Attaching screen shot, where data is getting downloaded at 143 KBps, downloading at the speed of 1.144 Mbps.

Select this link to understand internet speed unit conversions.

Speed over the internet vary greatly from one location to another. Speed of contacting a server in Washington DC and a server in Tokyo would be different, so while calculating the speed, you need to select the nearest server and perform the speed test in order to get accurate results.

Speed Test Mini - Quick way of checking the internet speed. 

Speed Test Mini from www.WhatIsMyIP.com

I have used speedtest.net to calculate the speed, which has the facility to select the servers across the globe. It is free, you can test your connection now. Select "Begin Test" OR select a server in the globe and  select "Begin Test"

You can directly select the location from the screen or if you want to run the test repeatedly, under setting link, make sure you have selected correct "Preferred Server" and "Unit of speed measurement".
Attaching screen shot of the results.

There is "World Results" link on the top of the page that will provide global statics.
These reports will help you understand which internet service provider (ISP) is providing highest band width in your city (I have selected Hyderabad). Attaching the screen shot.


Line Quality can be measured using following items.


Ping - Amount of time taken by packet of data to travel from a computer to another computer and back. Time is measured in Milli seconds, less then 100 is acceptable.

Packet Loss - In internet terminology every communication is sent in terms of packets. Due to noise some packets are lost.

Packet Latency -Delay while receiving the data packets at receiver end.

Jitter - Time difference(variance) while measuring successive ping tests. Zero is good,

I have used pingtest.net to calculate the line quality, it is free you can test your connection now.


You can directly select the location from the screen or if you want to run the test repeatedly, under setting link, make sure you have selected correct "Preferred Server".
Attaching screen shot of the results.


Above concepts are useful in conducting application performance test over the internet, I will explain those in future posts.


---

Friday, April 23, 2010

QTP - Hybrid FrameWork - Part II

QTP - Hybrid FrameWork - Part I
 

In part - I, I have explained about core framework architecture and keywords design.
In this post I am planning to explain the design by taking Mercury Tours.

Test Case Generator - It is an excel file containing macros and two work sheets "KeyList" and "KeyWord".
"KeyList" sheet is the place where "KeyWords" are created.
How to design KeyWords ?
Attaching the "KeyList" screen shot.

I use following naming convention by using Camel Case format for all the Keywords to increase the readability.
Let me explain by taking a KeyWords from the above screen shot.

MtWelcomeMercuryToursPUserNamePasswordEnter
Mt - Mercury Tours (All the Keywords for mercury site will use this prefix)
WelcomeMercuryToursP - Welcome Mercury Tours Page (Page Title displayed on the browser)
UserNamePasswordEnter - To fill User name(Parameter 1) and Password(Parameter 2) fields.

MtWelcomeMercuryToursPSignInBtnSelect
Mt - Mercury Tours (All the Keywords for mercury site will use this prefix)
WelcomeMercuryToursP - Welcome Mercury Tours Page (Page Title displayed on the browser)
SignInBtnSelect - Select Sign In Button

MtBookAFlightPPassengerDetailsEnter
Mt - Mercury Tours (All the Keywords for mercury site will use this prefix)
BookAFlightP - Book A Flight Page (Page Title displayed on the browser)
PassengerDetailsEnter - To fill First name (P1), Last Name(P2), Meal Type (P3)

Following points to be considered while designing the Key words
1. Each key word should be self explanatory. Don't not bother about the length, you are not typing it, just selecting from the drop-down.
2. Granularity of the Key word.
3. No two keywords should perform the same task or having similar methods for an object.

Major issues with Key Word Driven Framework
1. If user type incorrect key word, your test may fail as it can't resolve the Key word.
2. It would be difficult to remember the input parameters for each key word. Some have one or more and others don't have.

To overcome the above mentioned issues this excel file was created.

Each key word can have none or one or more number of parameters. Each parameter is classified as Mandate(m) or Optional(o) and its name is provided in the corresponding cell as comments (as "User name" in the above screen shot.

All these keywords are listed as drop down in the "Keyword" sheet. Attaching the screen shot.



While creating the test case, user need to select the key words as per the test steps mentioned in the manual test case. Any one can create automation test case as each key word is self-explanatory. Attaching the screen shot.

You can also create key words to capture content from the screen. Like flight conformation details in the mercury tours, attaching the screen shot.

Core framework libraries will fetch each key word from the above sheet and pass it to the "Driver Script Case Structure" function. Attaching screen shots.



(fun - All functions start with this prefix)
Each keyword is calling corresponding page functions. Page function consist of a single page objects methods which are divided into groups as per the KeyWord granularity.

As the function is calling another function to actually execute methods on the web page (In the above screen shot Function 1 calling Function2), it is named as "Dual Function Hybrid Framework" 

Page function logic for processing the keyWords.
1. Check for page synchronization. (It doesn't make sense to perform any method if the page is not downloaded successfully)
2. Declare the objects using DP.
3. Execute methods based on the keyword selected by using iKeyWordMethodsSelect. Core framework libraries will automatically pass the excel sheet input parameters into this function.

It is designed in such a way that QTP engineers need to concentrate on the web page objects, methods, they need not worry about the background logic. Core framework libraries automatically fetch and update data from corresponding sheets, this complex process is completely encapsulated. This will reduce the errors and increase the automation project efficiency. This design will not through any runtime errors even if browser not loaded successfully or objects missing from the screen, this error handling process is written separately. Never complicate the QTP code by inserting multiple validations, keep in mid you are testing the application, not the QTP framework or VB code.

Attaching few page function screen shots along with the corresponding web pages.














Re-usability(100%), Maintainability, Modularity, Ability to configure, Ease of use, Stability, Flexibility, Ease of code design are the important factors considered during design.
I have explained the main design, actual framework is more complex (Implementation of Response time calculation, Register methods, Object highlighting, beep on click...)

It also calculate average page response time of all the pages and generate a report in an excel format. Attaching the screen shot of average time and page count.



Evolution of this framework took 3 years, nearly spent 3 months just for optimizing the code.
Please let me know, If I had missed any functionality that has been implemented in any of your frameworks.
I think, this can help you in designing your own framework as per your project requirements.
Good Luck !

I have received many comments regarding the function "garrBroPag((fungarrBroPagFindRowIndex(1,1,))+1,6))" . I have provided explanations below (read my comments). For more clarity, I am attaching the excel screen shot.






----

Monday, April 12, 2010

QTP - Display real time test status.

 QTP - Display real time test status.
 
When your test is getting executed, it would be always better to understand the health of the application, how many test cases are getting PASSED and FAILED. We can take immediate action if more number of test cases are getting failed.

To display these messages, we need to use msgbox, but there is a problem with MsgBox, user need to select OK every time it appear on the screen, so we can't use this.
We need a pop-up that close automatically after x seconds, if user have not selected any button. This is the kind of pop-up we require for displaying the real time status.

This kind of pop-up can be created using "Wscript.Shell"

Set goShell = CreateObject("Wscript.Shell")
iUserInput=goShell.popup ("Pop-up message", 03, "Pop-up Title")
Above code will display the pop-up for 3 seconds and close it automatically.

You can design the pop-up message content as per the requirements, I have created the pop-up in great detail, as my tests are getting executed in different locations and have number of settings.Attaching screen shot of Hybrid Framework real time status message.




Attaching the function pertaining to the above pop-up message. I have used number of variables, which keep on updating after each test case execution completion, this design will not have any impact on the performance of your test.


Function funDisplayTestExecuationStatus()
        Set goShell = CreateObject("Wscript.Shell")
        Set goShellApp = CreateObject("Shell.Application")
        'goShellApp.MinimizeAll
        
        Dim sMsg

        iProcessedByQTP = giTotalTestCasesIgnored+cint(giTotalTestCasesPass) + cint(giTotalTestCasesFail)+cint(giTotalTestCasesBadInputs)
        sMsg = "Test Execution Place or System IP  :" '& Environment("envsPlace") & vbcr & vbcr
        sMsg =sMsg & "Test Start time  :" & gdtTestStartTime & vbcr        
'        sMsg =sMsg & "Current      time :" & funGetTimeStamp() & vbcr & vbcr
        sMsg =sMsg & "Current     time  :" & Now() & vbcr
        sMsg =sMsg & gsTimeZone & vbcr & vbcr        
        sMsg =sMsg & "Test Execution  Mode  :" & gsTypeOfExecuationMode & vbcr    
        sMsg = sMsg & "Last Processed Test Case ID  : " & gsTestCaseIdControl & vbcr
        sMsg = sMsg & "############################################################" & vbcr        
        sMsg = sMsg & "Test Cases Processed By QTP / Total  : " & iProcessedByQTP  & " / " & giControlFileRows-1 & vbcr & vbcr
        sMsg = sMsg & "Total Test Cases Executed : " & cint(giTotalTestCasesPass) + cint(giTotalTestCasesFail)+cint(giTotalTestCasesBadInputs) & vbcr
        sMsg = sMsg & "---------------------------------------------------" & vbcr
        sMsg = sMsg & "Total Test Cases PASS : " & giTotalTestCasesPass & vbcr
        sMsg = sMsg & "Total Test Cases FAIL : " & giTotalTestCasesFail & vbcr
        sMsg = sMsg & "Total Test Cases BAD INPUTS : " & giTotalTestCasesBadInputs & vbcr & vbcr
        sMsg = sMsg & "Total Test Cases Ignored : " & giTotalTestCasesIgnored & vbcr
        sMsg = sMsg & "---------------------------------------------------" & vbcr
        sMsg = sMsg & "Total Test Cases PASS : " & giTotalTestCasesIgnoredPass & vbcr
        sMsg = sMsg & "Total Test Cases FAIL : " & giTotalTestCasesIgnoredFail & vbcr
        sMsg = sMsg & "Total Test Cases BAD INPUTS : " & giTotalTestCasesIgnoredBadInputs & vbcr
        sMsg = sMsg & "Total Test Cases EMPTY STATUS : " & giTotalTestCasesIgnoredEmpty & vbcr
        sMsg = sMsg & "Total Test Cases UNKNOWN STATUS : " & giTotalTestCasesIgnoredUnKnownStatus & vbcr & vbcr
        sMsg = sMsg & "Control File Name        : " & gsControlFileName & vbcr
        sMsg = sMsg & "Selected Folder Name : " & gsSelectedFolder & vbcr & vbcr
        sMsg = sMsg & "Execute Flag Mode       : " & gsExecuteFlagStartUp & vbcr 
        sMsg = sMsg & "Execution Status Mode : " & gsExecutionStatusStartUp & vbcr
        sMsg = sMsg & "Execute Specific Test Case IDs : " & gsExecuteSpecificTestCaseIds & vbcr & vbcr        
        sMsg = sMsg & "Exception Exit Counter : " & giExceptionsCounterStartUp & vbcr
        sMsg = sMsg & "Test Report Pop-Up Delay(Sec)  : " & giPopUpDelay & vbcr
        sMsg = sMsg & "Test Report Pop-Up Display : " & gsPopUpDisplay & vbcr
        sMsg = sMsg & "Object Highlighting : " & gsObjectHighlight & vbcr
        sMsg = sMsg & "Web Page Synchronization time out (Sec) : " & giWebPageSync & vbcr   
        sMsg = sMsg & "Silent Mode : " & gsSilentMode & vbcr           
        sMsg = sMsg & "Beep Mode : " & gsBeepMode & vbcr       
        sMsg = sMsg & "Email Notification : " & gsEmailNotification & vbcr
        sMsg = sMsg & "############################################################" & vbcr        
        sMsg = sMsg & "Calculate Avg Response Time Flag : " & gsAvgResponseTimeFlag & vbcr & vbcr
        sMsg = sMsg & "Test Cases Processed By QTP / Total  : " & cInt(giProcessedByQTPResponceTime) + cint(giIgnoredFailByQTPResponceTime) + cint(giIgnoredByQTPResponceTime) + cint(giProcessedByQTPResponceTimeNot) & " / " & giControlFileRows-1 & vbcr
        sMsg = sMsg & "--------------------------------------------------------------------------------" & vbcr
        sMsg = sMsg & "Total Test Cases, Response Time Recorded  : " & giProcessedByQTPResponceTime & vbcr 
        sMsg = sMsg & "Total Test Cases PASS, Response Time Not Considered  : " & giProcessedByQTPResponceTimeNot & vbcr 
        sMsg = sMsg & "Total Test Cases Fail, Response Time Ignored : " & giIgnoredFailByQTPResponceTime & vbcr         
        sMsg = sMsg & "Total Test Cases, Resposce Time Ignored     : " & giIgnoredByQTPResponceTime & vbcr & vbcr          
        sMsg = sMsg & "Press OK to STOP Execution ..."

        giExitFlag = goShell.popup (sMsg, 09, "Test Report (Real Time)")
        
End Function

For more details look into Hybrid Framework.




----

Friday, April 9, 2010

Improving site performance.

Improving site performance.

1. Enabling compression- Web server send the data in compressed format.
Attaching screen shot showing the same web response in normal and compressed format, large variation in response size.


2. Tuning stored procedures (SP), run the profiler on a single user, capture SP calls and identify which are taking more CPU time.

3. Caching.

4. Load balancing .





----

QTP - Check page synchronization, when page contain AJAX calls

QTP - Check page synchronization, when page contain AJAX calls

 AJAX (Asynchronous java and XML) is preferred solution for creating fluid applications with advance user interactivity. Traditionally browser use GET and PUT method to refresh entire page for every interaction with the server, this would create load on server and network. By using AJAX, browser and server exchange small amounts of data in (XML or JASON format) asynchronously in the background through XMLHttpRequest object with out reloading the whole page for every user action. Javascript code use the data received from the server and update HTML in browser DOM (Document object model) which contain all the elements of the browser session.

Generally we use .sync to check whether the page got downloaded successfully.
If page contains AJAX calls, .sync will not help us determine whether the page got downloaded successfully.
We need to use different techniques to conform whether the page got downloaded successfully.

It is always a best practice to implement loader icon for AJAX calls, this will help us understand when the request got completed. Insist developers to install loader icons where content is displayed based on AJAX call, this will also help user understand visually some content need to be downloaded.

Capture the element id of the loader icon. By looking at the page source code we can easily find the id or developers can help you in finding the element id.

In order to check whether the loader icon appearing or disappearing on the screen, we need to access the element style object. Style object has many properties, but now we are looking into Display property.

Different values associated with the display property are None, Block....

Object.style.display= none - Element will not be displayed
Object.style.display= block - Element will be displayed
Now you need to check these properties in page DOM.

DOM define standard way of accessing and manipulating HTML content.
We can access page DOM through QTP using .Object  

Same method is used by developers to make loader icon appear/disappear, they assign the values directly, where as we check the value.


Attaching sample code to check page synchronization having AJAX calls.
1. (objElement.style.display = "block" )TRUE, loader icon exist still data is loading.
2. I have used timers, it will wait for 50 seconds only. Some thing gone wrong if it take more time.

Set oBrow = Browser("title:=Search Results").Page("title:=Search Results")
Set objElement = oBrow.object.getElementById("ctl00_cr_UpdateProgress1")
'Print objElement.style.display
MercuryTimers("Timer1").Reset
MercuryTimers("Timer1").Start
While ((objElement.style.display = "block" ) AND MercuryTimers("Timer1").ElapsedTime < 50000)
        Set oBrow = Browser("title:=Search Results").Page("title:=Search Results")
'        Print objElement.style.display
        Wait(2)
Wend
MercuryTimers("Timer1").Stop
If MercuryTimers("Timer1").ElapsedTime >= 50000 Then
        gsExecutionStatusTestCase = conF
        gsStatusMessageTestCase = gsStatusMessageTestCase &  "Issue with the page loading, exceeded the time limit.  "  &  " # "
        Exit Function
End If                        




----

Thursday, April 8, 2010

QTP - Rename file names, copy folders and delete files

QTP - Rename file names, copy folders and delete files

When test is scheduled to run daily, results generated in today's test will be erased by tomorrows test. In order to preserve the results, script should automatically copy the result folder to a new location, rename the files with current time stamp and delete the old files, so that new test can be started.

For more details follow this link Schedule framework or test using AOM script.






----

QTP - Capture screen shot.

QTP - Capture screen shot.

During test execution, if any of the test cases got failed, it is always a best practice to capture the screen shot. This will help us to resolve the problem easily.

Following are the difficulties faced while capturing the screen shot using QTP.
1. Name to be assigned for each screen shot.
2. Where to store the screen shot files.
3. How to notify the user this particular screen shot belongs to a specific particular test case.

Attaching screen shot function that can be called when required.
1. Assign current time stamp as screen shot name.
2. Store the files in the specified folder. I have used global variable (gsFolderPath).
3. Mention the screen shot name generated in the step 1 in the test case using global variable (gsStatusMessageTestCase).


Function ScreenShot()
        Dim sDateTimeNow, sFilePath
        sDateTimeNow = funUnique()
        sFilePath = gsFolderPath & "ScreenShots\" & "ScreenShot_" &  funUnique() & ".png"
        Desktop.CaptureBitmap sFilePath, True
        gsStatusMessageTestCase = gsStatusMessageTestCase & " SCREEN SHOT ID " & sDateTimeNow & " # "
End Function

Function funUnique()
        funUnique = "QTP_" & funGetTimeStamp() & "_" & Environment("envsPlace")
End Function
Attaching screen shots folder screen shot.


Attaching test case screen shot, displaying the application screen shot details at the failed step.




Follow this link for actual implementation in the framework.



----

QTP - Generate unique name or ID

QTP - Generate unique name or ID

Many times we require unique names or id for creating file names....
I prefer creating unique names by using month, date, year, hour, minute and second (Oct_27_2009_09_04_53).
This will help us to track when it is created, easily readable format.
You can further add tags to classify the names into different types (QTP_Oct_27_2009_09_04_53).

Attaching the function to generate ids as stated above.

Function funGetTimeStamp()
        sDateTIme = Now()
        
        iDate = Datepart("d",sDateTime)
        iLen = Len(iDate)
        If iLen = 1 Then
                iDate = "0" & iDate
        End If
        
        sMonth=  mid(MonthName(Datepart("m",sDateTime)),1,3)
        
        iYear = Datepart("yyyy",sDateTime)
        
        iHour = Datepart("h",sDateTime)
        iLen = Len(iHour)
        If iLen = 1 Then
                iHour = "0" & iHour
        End If
        
        iMinute = Datepart("n",sDateTime)
        iLen = Len(iMinute)
        If iLen = 1 Then
                iMinute = "0" & iMinute
        End If
        
        iSec = Datepart("s",sDateTime)
        iLen = Len(iSec)
        If iLen = 1 Then
                iSec = "0" & iSec
        End If
        
        
        funGetTimeStamp =  sMonth & "_" &  iDate & "_" & iYear & "_" & iHour & "_" & iMinute & "_" & iSec 
    
End Function




-----

QTP - How to handle different messages generated in the test or framework

QTP - How to handle different messages generated in the test or framework


During test execution based on the requirements different messages are generated. All the messages need to be captured and printed in the log file at the end of test execution.


Attaching sample log file screen shot.


To capture the messages I have created the function funMessages(sMessages), this function can store any number of messages. Once the test is completed we can dump the data into log files.


This function will capture the messages with time stamp, created two global variables gsMessagesCounter, gsMessages (array).

Function funMessages(sMessages)
        gsMessagesCounter = gsMessagesCounter + 1
        gsMessages(gsMessagesCounter) = Now() & "  -  " & sMessages
End Function


Sample code to write the above captured data into a log file

Set oFS=createobject ("scripting.filesystemobject")
Set oNotepad = oFS.createtextfile(gsTestSummaryFilePath)

oNotepad.writeline("System Generated Messages Log")          
oNotepad.writeline("-----------------------------------------------")    
For iCounter = 1 to gsMessagesCounter
        oNotepad.writeline gsMessages(iCounter)    
Next

oNotepad.Close

Set oFS = Nothing
Set oNotepad = Nothing   

Above mentioned code can capture any number of messages with time stamp and safely dump on the log file.




----

QTP - Find system IP

QTP - Find system IP

If your test is getting executed from different location, it is always a good practice to capture the system IP, so that we can distinguish the results clearly.  

Attaching sample code.

strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress > ''"
Set colItems      = goWMIService.ExecQuery( strQuery, "WQL", 48 )
For Each objItem In colItems
    If IsArray( objItem.IPAddress ) Then
        If UBound( objItem.IPAddress ) = 0 Then
            strIP = objItem.IPAddress(0)
        Else
            strIP = Join( objItem.IPAddress, "," )
        End If
    End If
Next
Set colItems      = Nothing
Print strIP

In the following article, system will detect the location name based on the IP address. If no matching location is found based on the IP address, it would treat IP address as location Schedule framework or test using AOM script.




----

QTP - Available physical memory.

QTP - Available physical memory.

If your framework or test is getting executed for more than one hour, it would be better to monitor the available physical memory. This will help us to detect memory leak.

It is a good practice to destroy objects after associated task got completed.

Attaching function that capture available physical memory. I have used function funMessages(sMessages) that would take care of all the messages and print in the log file automatically or we can use print sMessages statement.

Function funAvailablePhysicalMemory()
        set colOS = goWMIService.InstancesOf("Win32_OperatingSystem")
        for each objOS in colOS
               sMessages =  "Available Physical Memory: " & _
                             round(objOS.FreePhysicalMemory / 1024) & " MB"
        next
        Call funMessages(sMessages)      
        set colOS = Nothing
End Function 
 



----

QTP - How to play sound

QTP - How to play sound

Reason for implementing this feature in Hybrid Framework. - One of the developer told me that you are not calculating page response time correctly there is flaw in page synchronization code. In order to prove that I am correct, I have implemented this feature. When system select any action on the control it will generate a beep, once page sync is complete, it will generate different beep. After showing the same to the developer, he agreed that my page response time code is correct.

Attaching the beep function, replace the path of the wave files.


Function funBeep(iBeepNumber)
        strSoundFile = "C:\Automation FrameWork\Config\Blip.wav"
        strSoundFile1 = "C:\Automation FrameWork\Config\notify.wav"
        If gsBeepMode = "ON"  Then
                Select Case iBeepNumber
                        Case 1 : strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34) : goShell.Run strCommand, 0, False
                        Case 2 : strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile1 & chr(34) : goShell.Run strCommand, 0, False
                End Select
        End If
End Function



----

Wednesday, April 7, 2010

NeoLoad - Load testing tool

NeoLoad - Load testing tool

Link to NeoLoad website

One of the best load testing tool that I have seen in commercial and open source tool market for WEB 2.0.
It support AJAX, Flex and cheaper when compared with top commercial tools.

You can download the trial version and play with it.

Salient features of this tool.

1. Scriptless – All GUI driven which means 1) less mistakes 2) easier to read/understand 3) less of learning curve. Javascript can be used for additional functionality.
2. Monitors are agentless and easy to hook up.
3. Lightweight virtual users – you can generate more load with less hardware.
4. Handling of dynamic parameters (including Flex framework parameters) is both automated and GUI assisted.
5. Automatically handles all cookies that are set in the http header – no correlation step needed.
6. Written in java (both the Console and LG’s) so the product is scalable by nature (by adjusting heap sizes).
7. Organization intuitive – each project is a web application and you can store All scripts in one project.
8. Powerful Comparison report feature which quickly allows a tester to see the differences between runs after a tuning process.
9. Populations of users which have a restricted Bandwidth (ex. Connected to internet via modem).
10. Graphing section allows you to easily identify saturation points within your environment.
11. Can generate the load from the Cloud (through a partnership).
12. Provides excellent and reactive Support.
13. Software size around 100MB (some of the commercial tools size around 2GB)
14. Support IE, Firefox and Netscape.
15. Can maintain multiple connection with the server (IE maintain 2 connections).

I really liked the tool Fork action, handling dynamic parameters, light weigh virtual users, comparison report and ability to create new graphs.







----

QTP - How to capture System Information.

QTP - How to capture System Information.

Some time we may require to capture system information of the PC on which test is executed.

Host Name: QTP-TEST
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Build 2600
OS Manufacturer: Microsoft Corporation
OS Configuration: Workstation
OS Build Type: Multiprocessor Free
Registered Owner:
Registered Organization:
Product ID:
Original Install Date: 10/15/2009 3:04:57 PM
System Up Time: 10/21/2009 3:08:08 AM
Windows Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
BootDevice: \Device\HarddiskVolume2
System Locale: 0409
Total Physical Memory: 2005 MB
Available Physical Memory: 1245 MB
Page File: Max Size: 2048 MB
Page File: Available: 2006 MB
System Manufacturer: Dell Inc.
System Model: OptiPlex 755                
System Type: X86-based PC
Domain: WORKGROUP
Processor(s): 2 Processor(s) Installed.
    [1]: x86 Family 6 Model 15 Stepping 11 ~2327Mhz
    [2]: x86 Family 6 Model 15 Stepping 11 ~2327Mhz
BIOS Version: DELL   - d

Attaching sample code to capture above information, I capture this information to a log file so I am sending data to notepad object.



        Set oFS=createobject ("scripting.filesystemobject")
        Set oNotepad = oFS.createtextfile(gsTestSummaryFilePath)

        set dicProductType = CreateObject("Scripting.Dictionary")
        dicProductType.Add 1, "Workstation"
        dicProductType.Add 2, "Domain Controller"
        dicProductType.Add 3, "Standalone Server"
        
        set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime")
        set colOS = goWMIService.InstancesOf("Win32_OperatingSystem")
        for each objOS in colOS
           oNotepad.writeline "Host Name: " & objOS.CSName
           oNotepad.writeline "OS Name: " & objOS.Caption
           oNotepad.writeline "OS Version: " & objOS.Version & " Build " & objOS.BuildNumber
           oNotepad.writeline "OS Manufacturer: " & objOS.Manufacturer
           oNotepad.writeline "OS Configuration: " & dicProductType.Item(objOS.ProductType)
           oNotepad.writeline "OS Build Type: " & objOS.BuildType
           oNotepad.writeline "Registered Owner: " & objOS.RegisteredUser
           oNotepad.writeline "Registered Organization: " & objOS.Organization
           oNotepad.writeline "Product ID: " & objOS.SerialNumber
           objWMIDateTime.Value = objOS.InstallDate
           oNotepad.writeline "Original Install Date: " & objWMIDateTime.GetVarDate
           objWMIDateTime.Value = objOS.LastBootUpTime
           oNotepad.writeline "System Up Time: " & objWMIDateTime.GetVarDate
           oNotepad.writeline "Windows Directory: " & objOS.WindowsDirectory
           oNotepad.writeline "System Directory: " & objOS.SystemDirectory
           oNotepad.writeline "BootDevice: " & objOS.BootDevice
           oNotepad.writeline "System Locale: " & objOS.Locale
'           oNotepad.writeline "Time Zone: " & "GMT" & objOS.CurrentTimezone
           oNotepad.writeline "Total Physical Memory: " & _
                        round(objOS.TotalVisibleMemorySize / 1024) & " MB"
           oNotepad.writeline "Available Physical Memory: " & _
                         round(objOS.FreePhysicalMemory / 1024) & " MB"
           oNotepad.writeline "Page File: Max Size: " & _
                         round(objOS.TotalVirtualMemorySize / 1024) & " MB"
           oNotepad.writeline "Page File: Available: " & _
                         round(objOS.FreeVirtualMemory / 1024) & " MB"
        next
        
        set colCS = goWMIService.InstancesOf("Win32_ComputerSystem")
        for each objCS in colCS
           oNotepad.writeline "System Manufacturer: " & objCS.Manufacturer
           oNotepad.writeline "System Model: " & objCS.Model
           oNotepad.writeline "System Type: " & objCS.SystemType
           oNotepad.writeline "Domain: " & objCS.Domain
           oNotepad.writeline "Processor(s): " & objCS.NumberofProcessors & _
                        " Processor(s) Installed."
        next
        
        intCount = 0
        set colProcs = goWMIService.InstancesOf("Win32_Processor")
        for each objProc in colProcs
           intCount = intCount + 1
           oNotepad.writeline vbTab & "[" & intcount & "]: " & _
                        objProc.Caption & " ~" & objProc.MaxClockSpeed & "Mhz"
        next
        
        set colBIOS = goWMIService.InstancesOf("Win32_BIOS")
        for each objBIOS in colBIOS
           oNotepad.writeline "BIOS Version: " & objBIOS.Version
        next
        
        Set dicProductType = Nothing
        Set objWMIDateTime = Nothing
        Set colOS = Nothing
        Set colCS = Nothing
        Set colProcs = Nothing
        Set colProcs = Nothing
        Set colBIOS = Nothing


        oNotepad.Close



----

Tuesday, April 6, 2010

Loadrunner - Rendezvous point.

Loadrunner - Rendezvous point.

Every one is aware of what is Rendezvous point, once controller detect Rendezvous point in the selected script, it will enable Scenario | Rendezvous in the menu bar.

User can select this option and perform following operations

1. Enable/Disable Rendezvous point.
2. Disable virtual users.
3. Setting Policies.

Attaching pop-up screen shot.






---

Fiddler - HTTP(S) traffic recorder.

Fiddler - HTTP(S) traffic recorder.

 

Link to Fiddler


You can use this application to understand browser request and server response. Fiddler is a freeware and can debug traffic from any application. Author has provided video tutorials on different features available on this tool. Most of the performance testing tools use similar methodology for creating performance testing scripts.

I suggest every one (especially performance testing engineers) to use this application to understand request and response at root level.  

If your application is https, enable https option.

Attaching Fiddler screen shots.









---