You are on page 1of 35

What is a LoadRunner? LoadRunner is just a simple tool which is used to load the system.

Let us take an example, that your customer came to you with an issue that his website is very slow during peak hours of the business. Now to understand what has went wrong we need to monitor the application under peak hours. No customer will allow you to see his production environment since thats the bread earner for him and he dont want to take risk. Now you have to simulate the same environment in your test environment. Ok, you got the servers, applications, everything ready. Now the actual question comes... Do I need about 100 people who access my website (which is running under test environment) and do the regular routine to simulate the same situation that customer is facing. Then this is the foolish thing that you can do!!! Now comes the importance of LoadRunner. This is excellent tool, using which we can mimic or simulate the actual load in our test environment. Below we will now see how it all can be done. Where to download LoadRunner? LoadRunner can be downloaded with a free trial version of 10 days from hp web site(check in Google) With this you can enjoy the LoadRunner for 10 days. For learning this should be more than enough. TIP: During Installation dont install Controller part as this is the one which is licensed and rest all is free. After you learn complete LoadRunner scripting and rest of the concepts, you can install this part alone and learn the controller. LoadRunner Architecture Let us see the main parts of the LoadRunner and how each works. Above picture itself should have told you half of the storyThe main Components of LoadRunner are

VUser Generator Controller Analyzer VUser Generator This Component is used to create the actual LoadRunner script. What is LoadRunner Script? This is just script written using C (Even you can write using Java also but for now lets stick to C). This script contains some code which actual does exactly what an end user (Who uses the application) does. For example, you can write a script which actually opens the website and click some buttons. This is not used only for web applications, even you can write a script which does a SOAP call(for testing web services), or sending a request to real term emulator based applications (Eg: DOS based applications), or the application can be a win32 application (applications installed in your system).Ok from now let us stick to web applications as I feel most of us use LoadRunner for testing web based applications only. How does the VUser Generator works internally? The browser sends the request using HTTP (Hyper text transfer protocol) protocol to server and the server sends the response back to the browser as shown below Now when we use VUser Generator and record the user actions, VUGen will sit in between the browser and the server and it will capture all the data that is passing throw. I mean, it will record each request that is sent and the response that it got as shown below

Now it will create a method for each request that is sent. Let us see more details about these methods in further document. Then when you say run the script, it will resend all those requests by calling those methods. Thats itSo simple logic. What does V stands for in VUser Gen? Yes many people even dont know what it stands for but still use it many times. So V means virtual. We are trying to create a Virtual User who does exactly same as the real user. That is the reason we call this tool as Virtual User Generator. Creating an LR Script Below steps may change bit from version to version, but still the overall concept remains same. The below steps are using LoadRunner Part-1: Getting Started Open the VUser Generator Some main menu click on File > New You will get a New Virtual User Wizard. Under this wizard, you can observe 4 things on the left side. 1.New Single Protocol Script. 2.New Multiple Protocols Script. 3.New Script Recent Protocol 4.SOA test Generator. Which protocol to use when?

If we are testing the application using only one protocol then we use first option. For example if we are testing web application, then generally we need only one protocol that is Web (HTML/HTTP). In this case we will select first one. If we need to communicate with the application with more than one protocol then we go for second option. Very rarely this option is used. Third one is simple. It will just list out all the recently used protocols. Just like history. Fourth one used while testing SOA based application. Best example would be testing web services. Select the protocol to use. For now I will stick to the Web (HTML/HTTP) protocol as we are creating script for web application. Part-2: Basic parts of VUser Script Once you select the protocol and click ok, you will enter a new screen where by default Start Recording wizard will be there. For a moment press cancel to close this wizard. Even if it doesnt come its fine. You can observe 4 main default parts of the script in the left pane. vuser_init - vuser_init would contain all the clicks / transactions / operations which are required at first and which will be done only once. Action - Action contains the part of the scenario which is repeated many time. vuser_end - vuser_end contains the last part of the scenario which is again done only once. globals.h All the variable and methods which are used globally across init, action and end. For example, if you are testing yahoo mail. Let us take the Customer have given the scenario as follows 1.Opening the 2.Performing the Login 3.Check you inbox for new mails. 4.Click on any one mail and open it. 5. Again perform the above 3rd and 4th step for some time.6 . C l i c k l o g o u t In the above business scenario, We are going to do first 2 steps only once in the whole cycle and repeat the 3rd and 4th for some time (may be for some duration and for some number of times). Now once you are done with this you have perform the last 6th step (Again only once). So this is how you need to design your Script. globals.h

This is very less used option but very useful option. This is a header file contains all global variables and global method which can be accessed in all the 3 places (init, action, end).Let us take simple example; think you want to write a log throughout the script after each step in a formatted way as shown below Do some transaction Print ------------------ Print your message Print ----------------- Now your LR script will be filled with the statement only. Rather than this way we can create a method by name log It() and place in globals.h as logIT(String msg) { Print ------------------Print msg Print ----------------- } Now simply call this method everywhere rather than writing the whole formatting code Part-3: Recording Option - Which Protocol to select? First thing is to find which protocol you need to select before you go for actual recording. It all depends on application that you use and the way you access it. For example, if the application is deployed in some server and accessed through web client(Browser), then you need to select web/HTTP protocol. The main reason for this is that the browser uses HTTP protocol for connecting to the application. Now if the same application is connected through your mobile or palmtop then you have to use WAP protocol. RTE protocol: If the application is terminal based. Example will be application that you generally see in old banks consoles, government offices. It will be something DOS based applications where only keyboard can be used to use application. SOAP Protocol: Sometimes you need to test the application which is web services enabled. Then you go for it. LoadRunner supports huge set of protocols. In rest of our discussions we will use only HTTP protocol as this is more commonly used. NOTE:

VUser Scripts written using different protocol generates different code. If you learn on protocol then it may not that tough to learn another. Recording Options: These are some of the settings or recording configurations that you need to do before starting the recording. Many people just select default one and start recording and some people even dont know this exists. In fact these options will make our life easier if you use it properly. Open this wizard by selecting Recording Options under tools or just by pressingCtrl+F7.Main Screens that you see in this wizard are as below I will cover only important and most commonly used one. General : Script: To select which language you want to write LR script. Default is C. You can leave this default as C is very easy to understand. Protocol: Again select which protocol to use. If by mistake many protocols come according to your selection that you did at first, you can deselect them now. Recording: HTML based script or URL based script. I will discuss this in detail below as this is very important. Network Port Mapping: Used to direct traffic via a specific server: Port combination to the desired communication protocol. This is very advanced and I have never seen people using it so we can safely neglect this for now with default thing. HTTP Properties: Advanced : Discussed below in details. Correlation: Adding and Configuring correlation rules. I will come to this in detail under correlation topic which is very important. Recording level: When to HTML based, URL based script and GUI based script? What is the difference between HTML based script, URL based script? These are the very common question asked by many people. And this is most confusing thing. Let me make very clear and easy to learn it.

HTML Based: Using this recording mode LR will generate script by performing certain user actions on only HTML context. This mode recognizes the user inputs either in the form of data or in the form of forms. For each action that we perform on the application, LR will generate a function called web_url. Along with this 4 more functions will generated depending on actions we perform. Those are web_submit_data () web_submit_form ()web_link ()web_image () URL based: This recording mode will be used on Non-HTML resources like Bitmap, Jpeg, gif, java scripts..., In this mode LR will generate the function web_url for each and every step that we perform on the application. This mode recognizes the user input data only in the form of data submitted function. Some more functions will generates such as web_submit_data ()web_concurrent_start ()web_concurrent_end () NOTE: Correlations are bit messy and difficult in case of HTML based mode. I know its bit confusing; Lets take an example and learn it in more detail. These concepts are very important, as the whole Performance Numbers that you give or you get will depend on these settings. So as a performance Engineer you have to be more perfect in selecting this mode. Lets take an example and learn. Scenario: Step -1: Open the Google page Step -2: Type Hello in the text box and press search. Now basically we want to measure the performance of Google page. Here performance is the time (Technically speaking response time) of home page and search button. Now we all know this is web based application and hence set the protocol as web/HTTP. Now let us see what is recorded when each recording option is selected. Load runner Transaction: It can be just a simple user action or group of actions. No fix rule to say on this. It all depends what you want to measure. If a customer says, I click on the button a and then on button b and he wants to treat this as one transaction. Then it is. It all depends what you or customer want to measure. For now according to me we have 2 transactions. Each is one step performed as said above. HTML Based recording: Script Type: A Script Containing Explicit URLs only (e.g.: web_url,web_submit_data) Non HTML Generated elements:

Record in a separate steps and use concurrent groups

You might also like