Thursday, November 4, 2010

Generate UUID / GUID in LR

Sometimes in a request it is needed to send some basic encoded strings like UUID or GUID as part of the request. In loadrunner you can generate UUID using the function lr_generate_uuid();

GUID forms a different pattern and it can be generated by the code mentioned on the site: 

Wednesday, August 25, 2010

Changing Transaction Order in Analysis Report

By default the transaction names in the analysis file comes in alphabetical order but if there is requirement to change the order in which the transactions were executed during a test then you can  perform some tweaks to do so.


Solution:
  • Open the "AnalysisSummary.asc" file placed at the location /bin/dat in wordpad or textpad
  • Go to Section "Line22_Field0" in the file and scroll down to section "JoinedSelectString="
  • Add the below Query in that
    SELECT [Event_map].[Event Name] AS [Event Name],[Minimum],[Average],[Maximum],StdVal,[Table2].[Value] AS [90 Percent], Round([PassedT].[CountAll],0) AS Pass, Round([FailedT].[CountAll],0) AS Fail, Round([StoppedT].[CountAll],0) AS Stop FROM (((((Event_map LEFT JOIN [Table1] ON [Table1].[Event Name] = [Event_map].[Event Name]) LEFT JOIN (SELECT * FROM [Table0] WHERE [Transaction End Status] = 'Pass') AS PassedT ON [Event_map].[Event Name] = [PassedT].[Event Name]) LEFT JOIN (SELECT * FROM [Table0] WHERE [Transaction End Status] = 'Fail') AS FailedT ON [Event_map].[Event Name] = [FailedT].[Event Name]) LEFT JOIN (SELECT * FROM [Table0] WHERE [Transaction End Status] = 'Stop') AS StoppedT ON [Event_map].[Event Name] = [StoppedT].[Event Name]) LEFT JOIN [Table2] ON [Event_map].[Event Name] = [Table2].[Event Name]) LEFT JOIN [TempForSummaryRep0] ON [Event_map].[Event Name] = [TempForSummaryRep0].[Event Name] WHERE [Event_map].[Event Type] = 'Transaction' and ([Table2].[Percent] = 90 OR [Table2].[Percent] Is Null) GROUP BY [Event_map].[Event Name],[Event_map].[Event ID], [Minimum],[Average],[Maximum],StdVal, Round([PassedT].[CountAll],0), Round([FailedT].[CountAll],0), Round([StoppedT].[CountAll],0),[Table2].[Value] ORDER BY [Event_map].[Event ID]
  • Save the File and Open the analysis 
This will get reflected in your transaction Name order.

Friday, August 13, 2010

Create Custom Scripts for DB Queries / Stored Procs

If there is requirement to run queries or stored procs on database and measure the timings it; you can create a custom script either in Java or in .Net protocol and write some code to achieve this.

Solution:
The below solution was tried and tested for SQL Server, Oracle and Sybase Databases using .Net protocol in LR.
  • Open a new .Net protocol script in Vugen. 
  • Go to Recording Options and choose the recording language to VB .Net. 
  • Launch browser to record. Once it is launched properly stop recording. This will generate a blank script with reference to VB .Net libraries otherwise it will open a blank script with C# libraries.
  • The use the VB .Net code to create your connection and query the DB. Sample code is given below:
***************
Dim retvalue As String = ""
Dim Count As String
Dim reader As OleDbDataReader
Dim myconnectionstr As String = "Provider=OraOLEDB.Oracle;Data Source=Database_Name;User Id=XYZ;Password="& lr.decrypt(lr.eval_string("{Password_1}")) &";OLEDB.NET=True;"
Dim objConnection As New OleDbConnection(myconnectionstr)
'  Query sample
Dim strSQL As String = "select * from table_Name"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
objConnection.Open()
lr.start_transaction ("Query")
reader = objCommand.ExecuteReader()
if reader.HasRows then
      lr.end_transaction ("Query", LR.PASS)
   else
      lr.end_transaction ("Query", LR.FAIL)
      Msgbox("The Query has returned 0 rows")
end if 
MsgBox(reader.HasRows)
If (reader.Read) Then
retvalue = reader(3).ToString
End If
reader.Close()
MsgBox(retvalue)
objConnection.Close()
objConnection = Nothing
reader = Nothing
objCommand = Nothing
************************
Pre-requisites: Machine should have .Net Framework and Database client drivers

You can create correct connection strings (depending upon the database) by referencing the below site:


Vusers Gets Stalled in Exiting Status

While stopping the test Vusers go to "Gradual Exiting" status but get stalled there for a long time. Even stopping the test makes the users to go to "Exiting" Status but seem to be there for ever.

Solution:
Immediate resolution: 
If you are sure that the test is complete and stopping the vuser forcefully won't affect your results then safest way is to do a Stop Now. In case that button is disabled then disconnect the Load Injector from the scenario. This will make the user to error-out. Re-connect the LG and re-collate the test results (in case it didn't collate properly).
There are 2 ways to change this value; one is to change the config file or using a function in your script.

Next thing you need to do is to restart the controller machine and register the controller dlls; this can be done by running the batch file "register_controller.bat"
placed at: "LoadRunner Install Dir\bin"
Log-off and re-login to the machine. 

This case can get worsen if you are using CITRIX protocol and you manually tried to stop a vuser who was performing the below two functions at that time:
"ctrx_sync_on_bitmap_change" and "ctrx_sync_on_bitmap"

In case of you have large number of Vusers in your scenario then mention a limit on number of vusers that can stopped at given time also how you stop them. The setting for ramp-down limit is given in the LG properties:

  • Go to "Run-Time Quota" tab of LG details page and select the check-box for limiting the number of vusers that can be stopped and provide appropriate value in it.

For setting on how to stop the vusers:

  • Open Tools -> Options in Controller and go to "Run-Time Settings" tab
  • Select the appropriate option while stopping the vusers in the second option (depends on your scenario).

Tuesday, February 9, 2010

How to verify file downloaded properly in web scripts

There will be many occurrences where you need to validate whether the script is downloading proper file as part of the request (in web script) or not.

The simple way is to check the size of the download content, if that matches with the size of file then you can confirm that correct file is downloaded properly.

For this you can use the following function to check the download size:

web_get_int_property (HTTP_INFO_DOWNLOAD_SIZE);

PS: Place this request after you made call to your main request.

Issue in replay due to redirections

This summary is not available. Please click here to view the post.