Good loadrunner script should record all the important events during execution - success messages, check point messages, acknowledgment numbers; so that we can merge all the virtual users logs and generate a single merged log file as per the requirement.
This merged log file can be compared with the database entries, if required.
Especially recording should happen on failed transactions, so that we can show these transactions to developers.
Attaching sample log merging script, need to customize as per the requirements (which messages to pick).
Below script will search for the specified strings in the all the log files generated by the virtual users (all the files in a particular folder having any name) and consolidate it in a single file.
For advanced filtering of data, use special character as delimiter (pipe or # symbol) between group of words while generating log messages in the loadrunner, so that we export to an excel file and apply filters.
'Merge the log files
'Update line number 16 17 19 accordingly
'Enter directory path of the log folder
sDirectory = "C:\Documents and Settings\bharathm\Desktop\log\"
iRecords = 0
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FolderExists(sDirectory) Then
Set oNotepad = oFSO.createtextfile(sDirectory & "MergedRecords.txt")
Set objFolder = oFSO.GetFolder(sDirectory)
Set colFiles = objFolder.Files
For Each objFile in colFiles
'Wscript.Echo objFile
Set oFile = oFSO.OpenTextFile(objFile, 1)
Do While Not oFile.AtEndOfStream
sText = oFile.ReadLine
If instr(1,sText,"Action.c(796)") > 0 Then
If instr(1,sText,"Success") > 0 Then
iLen = len(sText)
sText1 = Mid(sText,15,iLen-15)
'WScript.Echo sText1
oNotepad.writeline(sText1)
iRecords = iRecords + 1
End If
End If
Loop
oFile.Close
Next
oNotepad.writeline("#############################################")
oNotepad.writeline("Total number of records merged: " & iRecords)
oNotepad.Close
WScript.Echo "Log merging Completed...verify the new file"
Else
WScript.Echo "No folder exist."
End If
Loadrunner - Good scripting guidelines
----
No comments:
Post a Comment