LoadRunner Tutorial Using Correlation to Troubleshoot Errors When Executing LoadRunner Scripts
2 Use correlation in LoadRunner to solve the user login problem. After you ve done all your homework and determined user scenarios and load profiles, you fire up your performance tool and begin to simulate those scenarios. If using LoadRunner, when you record a session and then execute it, you have probably encountered errors such as The same user can not login twice. or One user can only poll once. When this happens, this basically blocks your performance test and stops you from moving forward. These errors occur because a server cannot accept the same user executing the same action twice because many applications are designed to have precise statistics from each individual user, so if one user logs in 10 times (as you may try to simulate in a load test), the results do not conform with what the application expects and error messages are returned. Everyone encounters these types of problems and there are numerous ways to troubleshoot them. One such method is using correlation. What is Correlation? Firstly, what is correlation? As mentioned earlier, the server cannot or does not want to process the same user executing the same action consecutively. The same user has static data associated with that particular transaction and is hard-coded as a parameter of the transaction. Correlation is a process that converts the static data (or static session ID of the virtual user) to dynamic data and sends it to a server. This changes the session ID so that the server believes it is a new user. The screenshot in Figure 1 shows the correlation function when executing LoadRunner. The second column shows parameters of the recording snapshot while the third column shows the replayed snapshot. By comparing the difference between second and third columns, we can determine which parameters need correlation. Once we find this, then we need to determine
3 which correlation method. There are two common methods for correlation: auto correlation and manual correlation. Using Auto Correlation For auto correlation, you need to click the Correlation Options link to set rules as Figure 1. Figure 1: Correlation in LoadRunner After setting these rules, you can select which parameter or sessionid to correlate. Looking at Figure 1, there are four columns. The last column is indicates where the parameters occurred. You can click the Correlate button to get the exact list of differences as shown in Figure 2. The Text in Recording Snapshot and Text in Replay Snapshot columns show items such as different website address, different session ID, different IP address, etc.
4 Figure 2: Exact list for correlation Using Manual Correlation Manual correlation is more difficult than auto correlation and requires several steps. 1. First. You need to record two times using the same process and the same testing data. Then use the two recorded scripts with the Windiff tool to find the difference. Windiff is an embedded tool in LoadRunner which can be launched from Tools > Compare with Vuser. Upon finishing recording the script for the second time, you can see the execution scripts as shown below in Figure 3. All codes are test scripts with the yellow bolded background indicating the difference so that the user can track each difference. Figure 3: Manual correlation- result of windiff tool
5 2. After that, you can find the parameters in the Recording Log by using Ctrl+F. For example, you can find the sessionid by searching for the key words: session. To determine where to insert the function, you need to run the script again with all logs enabled and then compare with the different lines for these 2 logs, as shown in Figure 3 where the yellow lines indicate the differences and tell you the exact location of the difference as well as the different content (such as www.abc.com with www.cba.com ). 3. Then you need to define the left and right boundary in order to find the location where the lines are different. It should be a string format and cover all or most codes if possible. For instance, you find the different words are session 1134 end session and session1245 end session the left boundary would be session and the right boundary would be end session. The whole function should be formatted as shown below. web_reg_save_param( UserSession, LB= input type=hidden name=usersession value=, RB=>, LAST) 4. The last step is to use UserSession instead of hard-code. For example, Name=userSession, Value={UserSession}, ENDITEM, instead of Name=userSession, Value=123, ENDITEM, (use parameter instead of a real value) For more information, you can find details about this function from: Help > Function reference > Contexts > Web and Wireless Vuser Functions > Correlation Functions Manual correlation is more difficult than auto correlation but in some situations we need to do this in order to troubleshoot and get better data for analysis. Auto correlation can show the difference between the 2 log files (We also need to run the script 2 times as in manual correlation.), but some differences may be displayed as a long encrypted string (i.e: 71238734) and you won t be able to interpret the exact meaning or what it represents. On the other hand, with manual correlation you know the whole session structure as how the client transfers the data with the server and how many times the client and server communicated. For example, you can get the code as User IP address= 71238734 (note that 71238734 is encrypted and not a real IP address) using manual correlation, and then set a different IP for different users and successfully emulate many different users from different IP addresses visiting the server at the same time. Summary As mentioned earlier, most applications are designed in order to have precise statistics from each user, so simulating users needs to be done in the same way as the application expects which means that each user needs an individual ID. In LoadRunner, correlation can be used to solve this problem. Other performance and load testing tools have similar methods, but the basic concepts of parameterization are similar. Of course generating the load from multiple users is just one piece of the process. Determining user scenarios of what the users are doing, load profiles, and many other elements are all part of the performance testing process. XBOSoft Inc. 640 Rocca Ave. South San Francisco, CA 94080 +1 408-350-0508 w