Friday, February 26, 2010

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

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. 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.

Where as click & script protocol virtual user is a hidden browser, 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.

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%. Some time Vusers run very slowly after couple of iterations, not meeting the script expectation.
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.


QTP - Send email with attachments

QTP - How to send email with attachments without installing MS Outlook.

Good framework should automatically send the test results to all the stakeholders, once the test is complete.
Best approach would be using CDO object, it is not required to install MS Outlook on the PC where test is getting executed.

Attaching email notification function with error logic that can validate whether email sent successfully.

Note: Replace the variable names with your program variable names or constants.
Function funSendEmail()
        If gsEmailNotification = "ON" Then

                Const cdoSendUsingPickup = 1
                Const cdoSendUsingPort = 2
                Const cdoAnonymous = 0
                ' Use basic (clear-text) authentication.
                Const cdoBasic = 1
                ' Use NTLM authentication
                Const cdoNTLM = 2 'NTLM
                ' Create the message object.
                Set objMessage = CreateObject("CDO.Message")
                'Set the from address this would be your email address.
                objMessage.From = gsEmailListFrom
                ' Set the TO Address separate multiple address with a comma
                objMessage.To = gsEmailListTo
                objMessage.Cc = gsEmailListCc                
                ' Set the Subject.
                objMessage.Subject = gsEmailSubject & " - " & Environment("envsPlace")
                ' Now for the Message Options Part.
                ' Use standared text for the body.
                objMessage.TextBody =  gsEmailBody
                ' Or you could use HTML as:
                ' objMessage.HTMLBody = strHTML
                ' ATTACHMENT : Add an attachment Can be any valid url

                Set fso = CreateObject("Scripting.FileSystemObject")
'                Test Log
'                Set folder = fso.GetFolder(gsFolderPath & "ExecutionLog")
'                Set files = folder.Files
'                For each folderIdx In files
'                        objMessage.AddAttachment(folderIdx)
'                Next

'                Control file
'                TestCase File                
                Set folder = fso.GetFolder(gsFolderPath & "AutomationTestCases")
                Set files = folder.Files
                For each folderIdx In files

'                Response Time xls file
                If  gsResponseTimeXlsPath = Empty Then
                End If

                Set folder = Nothing
                Set folder = Nothing
                Set files = Nothing
                ' This section provides the configuration information for the SMTP server.
                ' Specifie the method used to send messages.
                objMessage.Configuration.Fields.Item _
                ("") = _
                ' The name (DNS) or IP address of the machine
                ' hosting the SMTP service through which
                ' messages are to be sent.
                objMessage.Configuration.Fields.Item _
                ("") = _
                ' Specify the authentication mechanism
                ' to use.
                objMessage.Configuration.Fields.Item _
                ("") = _
                ' The username for authenticating to an SMTP server using basic (clear-text) authentication
                objMessage.Configuration.Fields.Item _
                ("") = _
                ' The password used to authenticate
                ' to an SMTP server using authentication
                objMessage.Configuration.Fields.Item _
                ("") = _
                ' The port on which the SMTP service
                ' specified by the smtpserver field is
                ' listening for connections (typically 25)
                objMessage.Configuration.Fields.Item _
                ("") = _
                'Use SSL for the connection (False or True)
                objMessage.Configuration.Fields.Item _
                ("") = _
                ' Set the number of seconds to wait for a valid socket to be established with the SMTP service before timing out.
                objMessage.Configuration.Fields.Item _
                ("") = _
                ' Update configuration
                ' Use to show the message.
'                 MsgBox objMessage.GetStream.ReadText

                On Error Resume Next

                ' Send the message.

'                Setting global message list to empty as we are appending the existing file
                If  err.number = 0 Then
                        sMessages =  "Email sent Successfully "
                        sMessages =  "***Email NOT sent Successfully"
                End If

                Call funMessages(sMessages)
                On Error Goto 0
'                This will delete the test log and recreate again (Text file append is not working, generating write permission error) 
                Call funCreateTestLog()      
                Set objMessage = Nothing
        End If
End Function