Performancing Metrics

Performance blog: LoadRunner
Showing posts with label LoadRunner. Show all posts
Showing posts with label LoadRunner. Show all posts

Wednesday, March 7, 2012

Performance testing IPAD/Mobile applicatins




Recently customers are requesting for performance testing IPAD/Mobile applications and I came across such a requirement recently. The challenge is to simulate the traffic and the typical approach to capture traffic using tools like LoadRunner may not work in this case due to the reasons below.

·         Tools like LoadRunner can’t be installed in IPAD/smart phones to record the flow and capture the communication.

·         Network capturing tools like Wireshark and Fiddler can’t be installed in IPAD.
The approach is to route the traffic from IPAD to a hub/router and capturing the communication using network monitoring tools like wireshark.

1)      Hub takes packets sent from one port and transmits (repeats) them to every other port on the device. For example, if a computer on port 1 of a 4-port hub needs to send data to a computer on port 2, the hub sends those packets to ports 1, 2, 3, and 4.  When computer sends data, all computers connected to the hub receive it.  Connect a computer to the hub which has Wireshark or fiddler installed to capture the communication.

2)      Second approach is to connect to a router and allow traffic to go through the proxy.
The below link has the approach followed by my team to capture communication using wireless router and fiddler
Finally download the BPC toolkit available in my blog to convert fiddler output to LoadRunner script.
 
Note: HP developed some Mobile apps protocol to test Mobile applications which takes Wireshark network trace as an input to create a script. Purchasing license for this protocol is not required if the above approach is followed

@2011, copyright Vamsidhar Tokala

Saturday, April 23, 2011

White Paper - Java RMI Communication with LoadRunner

Java RMI

Java RMI Communication with LoadRunner

       Vamsidhar Tokala


This paper provides tips and tricks for HP LoadRunner JAVA RMI configuration, scripting, and execution. This guide is intended to help testers to understand the concepts of Java RMI and to use HP LoadRunner for Java RMI Scripting using Java Record and Replay protocol.

Introduction


LoadRunner is one of the very few tools available in the market which supports Java RMI protocol.  Information and the expertise available in the public domain is very limited for this protocol and developing test scripts for applications that use RMI involves Java programming, and requires understanding of the Java classes involved in client/server communications.  This article will enable testers with a solid background to address the challenges ahead.

Java RMI


JAVA RMI is distributed object protocol for communication between distributed objects.  It provides infrastructure services such as error, exceptional handling, parameter passing and security context. Client stubs and server skeletons are generated automatically and act as an interface between the application and the rest of the RMI system.

When a client invokes a call to a business object, it needs to get a remote object reference (Stub) to the remote object (skeleton), which intercepts the call and invokes the corresponding method. Remote objects works with container to execute resource management strategies such as instance pooling and provide support for transaction persistence and security

The way client gets a remote reference to an object is by first looking up home interface of the object via JNDI(Java Naming And Directory Interface) and then invoke create method defined in the home interface. If the object client wants to call already exists, then client can invoke one of the find methods defined in the home interface after the JNDI lookup. Server typically provides a naming server for the clients to look up objects deployed on it.

When a client invokes a method call of an object of an application deployed in the server, client actually invokes a corresponding method call on a local proxy (Stub) of the object deployed in server. Local proxy serializes the parameters of the call and sends them to server side proxy (Skeleton). Skeleton collaborates with the container to provide middle ware services such as concurrency control, connection pooling. Once the call is processed, results will be returned to Skeleton, stub and then to client eventually.

RMI Communication with LoadRunner


LoadRunner will act as a client stub during RMI communication with the server. It acts like a proxy of the object on the server side. It sends the method call to the Skeleton, which is present on the server side.

When remote calls from separate clients are placed (executing in different JVMs) each call will run in a separate thread. However, if you make concurrent calls from the same client then calls will execute on the same server thread.

Configure LoadRunner’s Java RMI recorder


In order to allow LoadRunner to capture RMI communication with the application ensure the following is done

1.        Install JDK. JRE alone is not sufficient for LoadRunner to record the RMI communication
2.        Identify the jar files required for the application to run.  Do the following steps to determine the same
·         Manually access the application through browser/batch file.
·         Go to Control Panel – java – Temporary internet files – Settings - Select View applications - Show JNLP Descriptor

3.        Download all the jar files listed in the jnlp file to a local folder from the application server (Refer JNLP section to look at a sample file). Alternatively look in the Java console for all JARs downloaded to the cache, and copy these to a local directory.(When an application lunches from the browser a copy of all the jar will get downloaded to a temporary directory in local machine.)

4.        Get all the application properties and parameters in JNLP file (see below for a sample format)

5.        Create the Java security policy file - d:\all.policy - with contents:

grant {
permission java.security.AllPermission;
};

The java.security.AllPermission is a permission that implies all other permissions. Granting AllPermission should be done with extreme care. Thus, it grants code the ability to run with security disabled. Extreme caution should be taken before granting such permission to code. This permission should be used only during testing.

6.        Configure class path   in the environment variables for all the jar files in the local folder plus
\bin
classes
\classes\srv
\jre\lib\rt.jar

b) Set %PATH% to point to the JDK and verify this with java -version

7.        Create a batch file with the information available from JNLP file as shown below

-Djava.security.policy=d:\all.policy
-DUSE_JAAS="false" -Dclient_master.properties="/retek/client_master.properties"
-Xms256M -Xmx256M
-Djava.naming.provider.url="opmn:ormi://XXX:6007:XXX-rpm/rpm12"
-DNAMING_URL="opmn:ormi://XXX:6007:XXX-rpm/rpm12"
-Djava.naming.factory.initial="oracle.j2ee.rmi.RMIInitialContextFactory"
-DNAMING_FACTORY="oracle.j2ee.rmi.RMIInitialContextFactory"
com.retek.rpm.gui.security.RpmUIClient

8.        Run the batch file in the local machine. It should invoke the application with out any issues.  In case of any issues while lunching the application using batch file, relook at all the steps from 1 to 8.

9.        LoadRunner has predefined hooks for Java RMI called rmi.hooks which is present Dat folder of LoadRunner installation directory.  The LoadRunner recorder uses these hooks to capture all Java classes as they are loaded into the Java Virtual Machine (JVM). When ever a hooks method is called, the same will be recorded into LoadRunner Script.  
To enable hooks, just remove ‘;’ character present is rmi.hooks file located at \dat & \classes directories.

Customized hooks for any classes or methods specific to the application can also be created with a filename called user.hooks and place it under LoadRunner/classes directory. 

10.     Under LoadRunner recording options: Configure the class path as in step 6 and add each of the jar files in the same order as in JNLP file (which is very important) in LoadRunner recording options.

11.     Compile and run the empty Java script with out errors.

12.     Record the application either with the java application by specifying the application parameters defined in the batch file or by selection the application type as batch file. LoadRunner launches the application and captures the methods and classes defined in the hooks file.

Script Parameterization

1.        Typical LoadRunner functions like vuser_init(); vuser_end() will not have any impact in the script. So after the script is recorded move the login part of the application code to init () function and logout to end () and the rest in action () function of the script.

·         init() method will be called once in the beginning of the run
·         action() method will be called once per each iteration
·         end() method will be called once at the end of the run
2.        Parameters defined in the script should assign to  java objects  as shown below for different data types
·         String promotionEventDescription = "";
·         com.retek.platform.util.type.RDate promotionEventStartDate =     new com.retek.platform.util.type.RDate ("", "MM/dd/yyyy"); //application specific date object
·         long departmentId = Long.parseLong("");//long
·         String departmentDisplayId = ""; //string

Serialization and De serialization

During the recording process LoadRunner automatically serializes the objects. Serialized objects are flattened into bytes and subsequently inflated in the future.  LoadRunner saves the objects into binary files with sequentially numbered and saved under LoadRunner Vuser directory. First file will be named as 1 and the second file as 2 and so on...

These classes captured in the script are serialized and deserialized during replay.  The below example code is generated by VuGen

 _object_array83 = new java.lang.Object[] {_clientcontext1, _tslcascadesearchcriteriaimpl1};  // IDLSequence
_string22 = "com.retek.rpm.app.item.service.TslCascadeSearchCriteriaImpl __CURRENT_OBJECT = {" +
  "}";
 _class10 = (java.lang.Class)lr.deserialize(_string22,21);  // RMIComponent
 _class_array27 = new java.lang.Class[] {_class1, _class10};  // IDLSequence
_object27 = _rpmcommandexecutionserviceremote27.executeCommand("com.retek.rpm.app.item.service.TslCascadeAppService", "findItems", (java.lang.Object[])_object_array83, (java.lang.Class[])_class_array27);

)

Forms of deserialization

There are two forms of deserialization used in LoadRunner.
lr.deserialize (int, boolean)
First form uses the int argument and it takes the Sequence number of the serialized object of the file saved under LoadRunner Vuser directory. If the boolean flag for the second argument is true, it uses LoadRunner's serialization method. If it is false, it uses Java's standard serialization method.
LoadRunner only unfolds objects when you are using LoadRunner's mechanism, (lr.deserialize(int, true)) and when the size of the object is smaller than the limit specified in the recording options. In cases where, for complication purposes, the object cannot be made sense out of or is larger than the size limit, LoadRunner automatically folds the object into serialbytexx.dat; sometimes it uses Java's standard mechanism, and therefore, it does not unfold the objects inside the script.
  lr.deserialize(String, int)
The second form records the serialized object inside the script source as a string and uses that as the object to be deserialized. In the below example _string15 will be used as an object to be deserialized
_rpmcommandexecutionserviceremote23 = _rpmcommandexecutionserviceremotehome45.create();
       
 _string15 = "com.retek.platform.bo.IdentifiableReference __CURRENT_OBJECT = {" +
              "com.retek.platform.bo.ObjectId objectId = {" +
                    "java.lang.Long value = {" +
                          "super = {" +
                          "}" +
                          "long value = #1#" +
                    "}" +
              "}" +
              "java.lang.String referencedClassName = #com.retek.rpm.domain.zonestructure.bo.ZoneGroupImpl#" +
              "java.lang.Long version = {" +
                    "super = {" +
                    "}" +
                    "long value = #0#" +
              "}" +
        "}";
 _identifiablereference1 = (com.retek.platform.bo.IdentifiableReference)lr.deserialize(_string15,14);  // RMIComponent

Having the larger serialized object inside the script source as a string is not recommended unless correlation is needed to the object. The bigger the Java serialized object, the more memory the JVM will need for VuGen to record it as unfolded. Thus, the recording may simply crash if "Object Size limit" is set to be too high in the recording options.

To increase/decrease the object size for serialization can be set through Recording options -Serialization tab - Limit Object Size

Correlation

Correlation for the serialized objects inside the script is straight forward. In the below example, the below value 14548 is replaced by a variable

_string32_StringBuffer.append("java.util.ArrayList __CURRENT_OBJECT = {" +
"}" +
                                            "com.retek.platform.bo.IdentifiableReference promotionReference = {" +
                                                  "com.retek.platform.bo.ObjectId objectId = {" +
                                                        "java.lang.Long value = {" +
                                                              "super = {" +
                                                              "}" +
                                                              //"long value = #14548#" +
                                                              "long value = ##" +
                                                        "}" +
                                                  "}" +

Object Inspection


In case you need to inspect an object from the script then import pf-joi-full.jar in LoadRunner and add following lines:

_clientcontext1 = com.retek.platform.service.ClientContext.getInstance();
        org.pf.joi.Inspector.inspect(_clientcontext1);

This will popup a window of JOI (Java Object Inspector) and you will see all members and data of the object

References

Enterprise Java Bean Response Time analysis – Santoshan Kumaran, Te-kai Liu
http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136424.html
http://download.oracle.com/javase/1.4.2/docs/guide/security/permissions.html
http://grids.ucs.indiana.edu/ptliupages/projects/HPJava/theses/slim/dissertation/dissertation/node11.html

Thursday, September 2, 2010

Debugging SAP scripts using SAPGUI Spy in LoadRunner

SAPGUI Spy tool comes with LoadRunner installation and be can used to identify each of the SAP GUI Client objects. It will help to understand the properties of the objects while creating and debugging the SAP LoadRunner scripts.


LoadRunner stores the properties of the objects used in the script in lr_strings.h header file

Usage of the tool is explained using the following Code snippet

The below is a sample code which  presses 'Yes' button in a pop up window. and the script failed to press the button during execution.



sapgui_select_active_window("wnd[1]");

sapgui_press_button("Yes",

btnSPOP1,

BEGIN_OPTIONAL,

"AdditionalInfo=sapgui1036",

END_OPTIONAL);;



Property for button btnSPOP1 is defined in lr_strings.h as below

const char* btnSPOP1=

"usr/btnSPOP-OPTION1";



Property of the btnSPOP1 button is replaced with the below property in lr_strings.h after verifying the using SAPGUI Spy tool as shown the snapshot below


const char* btnSPOP1=

"/app/con[0]/ses[0]/wnd[1]/usr/btnSPOP-OPTION1";

SAP GUI


 
 
 
 
 
 
 
 
 
 
Tool can be found under the following path
Additional Components\SAP_Tools\SapGuiSpy

Monday, August 16, 2010

File Transfer Errors during initialization in LoadRunner Controller

File Transfer Errors are very common during initialization of load test with LoadRunner. It can be because of following reasons.


1. There may be situations where some of the runtime files of the script are not included by the controller while transferring files to different load generators (may be a bug in controller). It may not transfer all the files required for the script to run successfully. Under those situations if the scripts give compilation errors in different load generators other than local host then manually add the missing files using Add button shown in the snapshot below.

Controller Group Information

 
 
 
 
 
 
 
 
 
 
 
2. If the Length of the script name is too large then LoadRunner will throw error messages like below


Error: Mercury File Transfer error: Cannot create file C:\Documents and Settings\autodesk-admin\Local Settings\Temp\brr_mYv.195\netdir\C\Performance_Test\QAAutomation\Performance\LR\Stage\700ExodusSFDC\CallCenter\CC_SFDC_CreateGSSRequest_fromContactScreen_Attachment\CC_SFDC_CreateGSSRequest_fromContactScreen_Attachment.prm. Reason : Check the file path for illegal characters or length.

To double check if the length is the issue, go the LoadGenerator and try to add the file in the specified path. You may get the error as below

Error Copying File

Wednesday, July 14, 2010

How to determine the speed of network during a load test using LoadRunner

Sometimes problems in the Network can impact load test results. It is important to monitor the rate at which data is received from the server in a Network.


LoadRunner can help you in determining the bandwidth used during a load test. Web Page Diagnostics Graphs in LoadRunner provides drill down analysis across different layers.

Network bandwidth by a Component = Component Size/ Component Receive Time

Component Receive Time is the Time to transfer between the first byte to the last byte arrives from the server and Component Size is the size of component downloaded from the server.

In the below Example Network speed during the test is 263.249/1.132 = 232 KB/sec. This speed may slight vary from component to component and also based on Load Generators used for the test

Web page diagnostics

Thursday, May 6, 2010

Testing RESTful Web Services using LoadRunner

Brief overview of RESTful web services

REST defines a set of architectural principles by which you can design Web services that focus on a system's resources, including how resource states are addressed and transferred over HTTP by a wide range of clients written in different languages. If measured by the number of Web services that use it. REST has had such a large impact on the Web that it has mostly displaced SOAP- and WSDL-based interface design because it's a considerably simpler style to use.

From the standpoint of client applications addressing resources, the URIs determine how intuitive the REST Web service is going to be and whether the service is going to be used in ways that the designers can anticipate. A third RESTful Web service characteristic is all about the URIs.


REST Web service URIs should be intuitive to the point where they are easy to guess. Think of a URI as a kind of self-documenting interface that requires little, if any, explanation or reference for a developer to understand what it points to and to derive related resources. To this end, the structure of a URI should be straightforward, predictable, and easily understood.

One way to achieve this level of usability is to define directory structure-like URIs. This type of URI is hierarchical, rooted at a single path, and branching from it are subpaths that expose the service's main areas. According to this definition, a URI is not merely a slash-delimited string, but rather a tree with subordinate and superordinate branches connected at nodes. For example, in a discussion threading service that gathers topics ranging from Java to paper, you might define a structured set of URIs like this:

http://www.myservice.org/discussion/topics/{topic}

(Refer this article written by Alex Rodriguez on RESTful webservices for more information)

Sumilating RESTful web Services using LoadRunner


REST Services can be scripted using web_custom_request by adding appropriate headers using web_add_header function before the web_custom_request.

An example for REST services script is given below.


/*********************************

web_add_header ("X-ELS-APIKey","11111");

web_add_header ("X-Forwarded-For","12.5.28.133");

web_add_header ("Accept","text/xml");

web_custom_request("web_custom_request",

"URL=http://host:8080/content/abstract/*********",

"Method=POST",

"TargetFrame=",

"EncType=text/xml; charset=iso-8859-1",

"Resource=0",

"Referer=",

"Mode=HTTP",

"Body=",

LAST);

*****************************/

If you want to verify the response manually, you need to set up the header values first in your browser.

Please find below the steps for setting up the header using mozilla firefox browser.

  • Open firefox. Click "Add-ons" from tools menu
  • Click "get Add-ons" tab.
  • Type "HTTP header" in the text box for search all add-ons and enter.
  • In search results, click on "Add to firefox" for "Modify Headers 0.6.6" and install. Now you can see "Modify Headers 0.6.6" in the extension tab.
  • Click on "Modify Headers 0.6.6" from the "Extensions" tab and select the check box for "Always on" and "Open modify header in a new tab" and close.
  • Now click "Modify headers" from the firefox tools menu and add the appropriate header name and value for your request.

Now launch the URL in the firefox browser and verify the response manually.

Also refer RESTClient  addon available for firefox to test RESTful services

Wednesday, April 28, 2010

SAP BPC ToolKit for LoadRunner

This attached guide describes the process of using LoadRunner with SAP BusinessObjects Planning and Consolidation in detail.

DownLoad SAP BPC ToolKIT from the link below
http://docs.google.com/leaf?id=0BzOftuUbGkRvZGIzOTJhZTctNzQ3Ny00MmZhLTllY2EtNDY5Y2JjZDA5Yjk3&hl=en

Download LoadRunner Guide to test SAP BPC Application
docs.google.com/fileview?id=0BzOftuUbGkRvYzE4NjFjMzAtN2JlMi00YmVjLThkMDgtNDg4ZmRlN2NjZjJm&hl=en

Friday, April 23, 2010

Client Side certificates with LoadRunner

Many applications make use of the SSL extension to the HTTP protocol that adds an encryption layer to the HTTP stack. If performance test tool can't handle SSL then you won't be able to record any transactions.
One way of increasing security is to make use of client certificates, which can be installed into the application

client before access is permitted to an application. The certificates are provided in a number of formats (typically pfx or p12) and must be made available to your performance testing tool for successful capture and replay.
Please follow the steps below to import, export the certificate in the format recommended by LoadRunner.
 
Import Client Certificate in Browser

1. Click Start, click Control Panel, double-click Internet Options, and then click the Content tab

2. Click Certificates.

        a)The Certificates dialog box opens.
3. Click the Personal tab, and then click Import.

        a)The Certificate Import Wizard opens.
        b)On the Welcome page, click Next.

4. On the File to Import page, click Browse, select your certificate (if necessary, select your certificate type in Files of Type drop-down menu), and then click Next.

5. On the Password page, type the certificate’s password, select Mark this key as exportable, and then click Next.

6. On the Certificate Store page, select Place all certificates in the following store, browse to the Personal certificate store (if it’s not already selected), and then click Next.

7. On the Completing the Certificate Import Wizard page, click Finish.

8. Verify that the imported certificate appears in the Personal tab of the Certificates dialog box.

Export a private key

1. Under Internet Options, and then click the Content tab.

2. Click Certificates.

       a)The Certificates dialog box opens.
3. In the Certificates dialog box, click the Personal tab, select the certificate to export, and then click Export.

       a)The Certificate Export Wizard opens.
       b)On the Welcome page, click Next.

4. On the Export Private Key page, select Yes, export the private key, and then click Next.

5. On the Export File Format page, choose Personal Information Exchange – PKCS #12 (.PFX), select Include all certificates in the certification path if possible, clear the other check boxes, and then click Next.

6. On the Password page, type and retype the certificate’s password, and then click Next.

7. On the File to Export page, type the path and name of the file to export, and then click Next.

     a)The wizard will add the .pfx extension automatically.

8. On the Completing the Certificate Export Wizard page, click Finish.


Convert .PFX to .PEM format using OpenSSL

1. Download latest version of OpenSSL from OpenSSl Website

    a. http://www.openssl.org/source/

2. Convert PFX format to PEM format using the command below

a. OPENSSL PKCS12 –in <> -out <>

b. Enter the password given while exporting the certificate

c. Enter any PEM pass phase :e:g 2222

d. Reconfirm the pass phase by typing the same number again.

Open SSL
Note: SSL utility available in LoadRunner 9.5 may crash or may not work as intended. It is better to download the utility from OpenSSL website
 
WebServices Security in LoadRunner

Transport Level Security

Secure Sockets Layer (SSL) is a common transport layer approach that is used to provide encryption to message layer security. If your web service URL begins with https, SSL is automatically used.

  •  First copy the created .pem file using OpenSSL utility into LoadRunner Script folder
  • Set up the transport level security using the following function in LoadRunner
 web_set_certificate_ex("CertFilePath=testpem1111.pem",

"CertFormat=PEM",
"KeyFilePath=testpem1111.pem",
"KeyFormat=PEM",
"Password=2222", // PEM pass phase
LAST);

Note: if a web service doesn’t uses https URL then this function is not required in VuGen

Legacy Based Security

If in addition to SSL you are using message-level security (for example a username) then you must configure the security for the message separately using the Legacy/Scenario based security model (web_service_set_security) function.

When a SOAP message sends a request, those security credentials, known as security tokens, are placed in the SOAP message. When the Web server receives the SOAP request, it does not need to send additional requests to verify the integrity of the sender. The server verifies that the credentials are authentic before letting the Web Service execute the application. By not having to go back to the source of the credentials, this significantly improves the application’s scalability

VuGen allows you to create security tokens for your script. You can create multiple tokens and set their properties. After creating a token, you use it to sign or encrypt a SOAP message. When you add a security token to a SOAP message, it is added to the SOAP message in the form of an XML element in the WS-Security SOAP header.

a. LoadRunner supports different types of security tokens. The available tokens are

Username and Password, X.509 Certificate,Kerberos Ticket, Kerberos2 Ticket, Security Context Token, andDerived Token.

The information you need to provide differs for each token

b. This following is an example of legacy based security Model using User Name and Password token in LoadRunner

web_service_set_security(
SECURITY_TOKEN, "Type=USERNAME","LogicalName=DP", "UserName=XXXXXX", "Password=XXXXX", "PasswordOptions=SendPlainText", "Add=True",
LAST);

c. X.509 Certificate: When you add an X.509 token to the Vuser script, you specify the Logical Name, Store Name, Key identifier type, Key identifier value, and Store Location arguments.

These inputs to this function can be obtained by downloading Microsoft WSE X509 certificate tool from Microsoft website


web_service_set_security(
SECURITY_TOKEN, "Type=X509", "LogicalName=MyStore", "StoreName=My",
"IDType=SubjectName", "IDValue=C=US, S=CA, L=San Rafael, O=Inc., OU=IT, CN=IT Internal", "StoreLocation=CurrentUser", "Add=True",
MESSAGE_SIGNATURE, "UseToken=MyStore",
LAST);

Scenario based Security Model

LoadRunner also supports Scenario based Security Model for WCF Services which is out of scope of this post

Wednesday, March 3, 2010

Sending Emails using Blat utility in LoadRunner

If there is any requirement where you may have to send hundreds of emails to the server then one option is to use a web email client to simulate the load but it has following limitations

1. Your own corporate/personal Email id need to be used in LoadRunner Script but it may fill up the mail box

2. Password credentials need to be made visible in the script.

Other option is to use Blat utility which is a third party freeware utility. It sends the contents of a file in an e-mail message using the SMTP protocol.

Download the attached blat.dll utility and create a sample script as shown below.


Action()

{
command_line_Send = (char *)malloc(1024 * sizeof(char));

if(CheckLoadBlatDLL != 0) //if return code not zero then DLL not loaded!!Reload it
{
    lr_output_message("BLAT Emailing DLL Not Loaded Successfully !!! Reloading the DLL");
    CheckLoadBlatDLL = lr_load_dll("blat.dll");
}
f1=fopen(lr_eval_string("C:\\SR_{vuser_id}.txt"), "wb+" );
fprintf(f1,lr_eval_string("Email Performace Testing {TimeStamp}"));
fclose(f1);

//Initialize all the command line parameters for Blat tool

strcpy(DestEmailID,lr_eval_string("{EmailId} ")); // Destination Email ID
strcpy(Subject,lr_eval_string("\"Email PerfTesting{TimeStamp}\" ")); // EmailID Subject
strcpy(SMTPServer,lr_eval_string("{SMTPServer}")); //Your Corporate SMTP Server
strcpy(FromEmailID,lr_eval_string("{FromEmailID} "));// Source Email Id
strcpy(AttachFile,"C:\\attach.pdf "); // Any attachment
strcpy(BodyText,lr_eval_string("C:\\SampleBody{vuser_id}.txt "));// Email Body
lr_output_message("The Destination EmailId is :%s",lr_eval_string("{EmailId}"));

//Verify whether DLL Loaded successfully

if (CheckLoadBlatDLL == 0) //if return code not zero then not DLL not loaded
{
    lr_output_message("BLAT Emailing DLL Loaded Successfully ");
    // Build the Command line for sending Emails
    strcpy( command_line_Send, BodyText);
    // strcat( command_line_Send, "-attach ");
    //strcat( command_line_Send, AttachFile);
    strcat( command_line_Send, "-to ");
    strcat( command_line_Send, DestEmailID);
    strcat( command_line_Send, "-f ");
    strcat( command_line_Send, FromEmailID);
    strcat( command_line_Send, "-s ");
    strcat( command_line_Send, Subject);
    strcat( command_line_Send, "-server ");
    strcat( command_line_Send, SMTPServer);
    lr_output_message("Parameters for Send Command : %s", command_line_Send);
    temp_error_code = Send(command_line_Send);
    lr_output_message("Return code of Send command %d " , temp_error_code);
  //Check successful message sending.
   if (temp_error_code == 0) {
      lr_output_message("Email Sent Successfully ");
   }
  if(temp_error_code != 0){
  switch( temp_error_code ){
  case 1:
   //Command Line Bad Argument
   //Unable to open SMTP socket
   //Command unable to write to socket
   //Server does not like To: address
   // Mail server error accepting message data
   lr_error_message("ERROR : Check the command Line Argument Format");
   break;
  case 2:
   //The server actively denied our connection.
   //The mail server doesn't like the sender name.
   lr_error_message("ERROR : Email Server Denied connection or File does not exist");
   break;
   }//end SWITCH
 }//end IF
}else{
  lr_output_message("Unable to Load the Blat DLL - Check whether DLL exists at the specified location ");
}
free(command_line_Send);
return 0;
}

Tuesday, January 12, 2010

SOAP Over JMS using Publisher - Subscriber Communication

Publish-Subscribe. Each message is sent from one publisher to many subscribers through a designated topic. The subscribers only receive messages sent after they have subscribed.
 
A sample script to Publish and Subcribe JMS messages to TIBCO using LoadRunner

Action()

{
//Sample Queue Name - TIBQ1.SAP.SyncOrder.ADSKOrder
jms_subscribe_topic("subcribe_step", "subscription_1", "TIBQ1.SAP.SyncOrder.ADSKOrder");

// Publishes messages to a specific topic
jms_publish_message_topic("Publish",

"\r\n \r\n "",

"7051170660\r\n "\r\n \r\n "

"2009-01-08

" 000000000025835109\r\n "

" \r\n

"TIBQ1.SAP.SyncOrder.ADSKOrder");

//Receives published messages to a specific topic on a subscription
jms_receive_message_topic("receive_step", "subscription_1", "TIBQ1.SAP.SyncOrder.ADSKOrder");

//Received messages are saved in the JMS_message parameter
lr_output_message(lr_eval_string("message : \n{JMS_message}\n"));

return 0;

}

JMS RuntimeSettings
JMS Runtime Settings

Friday, January 8, 2010

Integrating Sitescope Monitor with Controller

To integrate a SiteScope server that needs authentication, modify the modify the LR installation folder\dat\monitors\xmlmonitorshared.ini file as follows:
1. Locate the [SiteScope] section in the file.
2. Append &account=administrator, or if you want to log in using other user (e.g., XXX), append &account=XXX, to the MetricListURL.


Note:
The user XXX must have the right permissions in SiteScope and may be different from the user name. The SiteScope server should be accessed as

http://sitescope:8888/SiteScope?account=XXX.
3. Add "QueryLoginInfo=1" at the end of the section.
With this, you should be able to see a login window when adding measurements.

Tuesday, December 29, 2009

How to start rstatd Demon process in Solaris 10

The following command will help you in starting rstatd Demon process

bash-3.2$ /usr/lib/netsvc/rstat/rpc.rstatd start

Verify the process is up or not using the following command
-bash-3.2$ rup tib(HostName)
tibq2 up 261 days, 14:14, load average: 5.73, 9.21, 10.74

Wednesday, December 16, 2009

Tuesday, December 8, 2009

Extracting LoadRunner Error messages based on Scripts

Sample C# code to fetch the LoadRunner Error messages based on Scripts using MS Access mdb file

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;


namespace LR_transaction
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        private void button1_Click(object sender, EventArgs e)
        {
      
            //Create the database connection 
  
            OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\abc.mdb");

            //create the command object and store the sql query 
 
            OleDbCommand aCommand = new OleDbCommand("select [ErrorMessage].[Error Message] from ErrorMessage where [ErrorMessage].[Error Id] in(select [Error_Meter].[Error Id] from Error_Meter where [Error_Meter].[Script Id] in (select [Script].[Script ID] from Script))", aConnection);          
            try
            {
                aConnection.Open();

                //create the datareader object to connect to table 
                OleDbDataReader aReader = aCommand.ExecuteReader();
                Console.WriteLine("This is the returned data from the table");

                //Iterate throuth the database 
                while (aReader.Read())
                {
                       MessageBox.Show(aReader.GetString(0));
                               
                }
              
                //close the reader 
                aReader.Close();
    
                //close the connection Its important. 
                aConnection.Close();
                Console.Read();

            }

            //Some usual exception handling
            catch (OleDbException ex)
            {
                Console.WriteLine("Error: {0}", ex.Errors[0].Message);
            }
        }
 

     }
}

Wednesday, December 2, 2009

Simulating SOAP messages via JMS in LoadRunner using Web Services Protocol

Web services facilitate application to application communication for building integrated systems of web application components and HTTP is the most standard transport protocol used for the communication but it will be difficult to send messages from one subsystem to many using HTTP. Sending SOAP messages via JMS is a viable and a simple option for such requirements.


JMS is a J2EE standard for sending messages, either text or Java objects, between Java clients.


There are two scenarios for communication:


Point-to-Point. JMS implements point-to-point messaging by defining a message queue as the target for a message. Multiple senders send messages to a message queue, and the receiver gets the message from the queue.


Publish-Subscribe. Each message is sent from one publisher to many subscribers through a designated topic. The subscribers only receive messages sent after they have subscribed.


LoadRunner supports both the communication but I will focus sending SOAP over JMS point-to-point communication using LoadRunner in this post.


Vugen supports point to point by allowing you to send and receive JMS messages to and from a queue.


Please follow the steps to simulate JMS traffic to TIBCO in LoadRunner


       1.    Install JDK and set the class path accordingly

       2.    Download TIBCOjms.jar file from the application support team and set the class path of the jar in VUGEN- Runtime settings – Classpath

       3.    Request your application team to provide the following details and update in  Runtime settings

a.    JNDI Initial Context Factory - com.tibco.tibjms.naming.TibjmsInitialContextFactory (For Tibco)

b.    JNDI Provider URL

c.     JNDI Context Factory

d.    Credentials(userid/Password)


       4.    Create a Sample script to verify the connection


Action{

char text[100];

strcpy(text,"Sample Message to be Send to TIBCO");

lr_output_message("%s text is ", text);

//sending message

jms_send_message_queue("Sending message",text, "QueueName");

return 0;

}

JMS Runtime Settings for Point-to-Point
JMS Runtime Settings