Thursday 8 December 2016

Difference between Application server and Web server ?

A Web server exclusively handles HTTP requests, whereas an application server serves business logic to application programs through any number of protocols.

The Web server:
A Web server handles the HTTP protocol. When the Web server receives an HTTP request, it responds with an HTTP response, such as sending back an HTML page. To process a request, a Web server may respond with a static HTML page or image, send a redirect, or delegate the dynamic response generation to some other program such as CGI scripts, JSPs (JavaServer Pages), servlets, ASPs (Active Server Pages), server-side JavaScripts, or some other server-side technology. Whatever their purpose, such server-side programs generate a response, most often in HTML, for viewing in a Web browser. 


Understand that a Web server's delegation model is fairly simple. When a request comes into the Web server, the Web server simply passes the request to the program best able to handle it. The Web server doesn't provide any functionality beyond simply providing an environment in which the server-side program can execute and pass back the generated responses. The server-side program usually provides for itself such functions as transaction processing, database connectivity, and messaging. 
While a Web server may not itself support transactions or database connection pooling, it may employ various strategies for fault tolerance and scalability such as load balancing, caching, and clustering—features oftentimes erroneously assigned as features reserved only for application servers. 

The application server:
As for the application server, an application server exposes business logic to client applications through various protocols, possibly including HTTP. While a Web server mainly deals with sending HTML for display in a Web browser, an application server provides access to business logic for use by client application programs. The application program can use this logic just as it would call a method on an object (or a function in the procedural world). 

Such application server clients can include GUIs (graphical user interface) running on a PC, a Web server, or even other application servers. The information traveling back and forth between an application server and its client is not restricted to simple display markup. Instead, the information is program logic. Since the logic takes the form of data and method calls and not static HTML, the client can employ the exposed business logic however it wants.

In most cases, the server exposes this business logic through a component API, such as the EJB (Enterprise JavaBean) component model found on J2EE (Java 2 Platform, Enterprise Edition) application servers. Moreover, the application server manages its own resources. Such gate-keeping duties include security, transaction processing, resource pooling, and messaging. Like a Web server, an application server may also employ various scalability and fault-tolerance techniques.

Lets see the below example:
As an example, consider an online store that provides real-time pricing and availability information. Most likely, the site will provide a form with which you can choose a product. When you submit your query, the site performs a lookup and returns the results embedded within an HTML page. The site may implement this functionality in numerous ways. I'll show you one scenario that doesn't use an application server and another that does. Seeing how these scenarios differ will help you to see the application server's function. 

Scenario 1: Web server without an application server
In the first scenario, a Web server alone provides the online store's functionality. The Web server takes your request, then passes it to a server-side program able to handle the request. The server-side program looks up the pricing information from a database or a flat file. Once retrieved, the server-side program uses the information to formulate the HTML response, then the Web server sends it back to your Web browser.
To summarize, a Web server simply processes HTTP requests by responding with HTML pages.

Scenario 2: Web server with an application server
Scenario 2 resembles Scenario 1 in that the Web server still delegates the response generation to a script. However, you can now put the business logic for the pricing lookup onto an application server. With that change, instead of the script knowing how to look up the data and formulate a response, the script can simply call the application server's lookup service. The script can then use the service's result when the script generates its HTML response. 
In this scenario, the application server serves the business logic for looking up a product's pricing information. That functionality doesn't say anything about display or how the client must use the information. Instead, the client and application server send data back and forth. When a client calls the application server's lookup service, the service simply looks up the information and returns it to the client. 
By separating the pricing logic from the HTML response-generating code, the pricing logic becomes far more reusable between applications. A second client, such as a cash register, could also call the same service as a clerk checks out a customer. In contrast, in Scenario 1 the pricing lookup service is not reusable because the information is embedded within the HTML page. To summarize, in Scenario 2's model, the Web server handles HTTP requests by replying with an HTML page while the application server serves application logic by processing pricing and availability requests.
Note:Recently, XML Web services have blurred the line between application servers and Web servers. By passing an XML payload to a Web server, the Web server can now process the data and respond much as application servers have in the past.
Additionally, most application servers also contain a Web server, meaning you can consider a Web server a subset of an application server. While application servers contain Web server functionality, developers rarely deploy application servers in that capacity. Instead, when needed, they often deploy standalone Web servers in tandem with application servers. Such a separation of functionality aids performance (simple Web requests won't impact application server performance), deployment configuration (dedicated Web servers, clustering, and so on), and allows for best-of-breed product selection.

Saturday 3 December 2016

How to handle java script generated Session ID in Vugen using Load runner

A session id (GUID) is generated on client side via a javascript and sent to the server. This cannot be correlated because it doesn’t come from the server.

You will need to figure this out from the page source. In my case, the sessionID is assigned a value of window.SessionId where window.SessionID = NewGuid()


The body of NewGuid() is -


function NewGuid() {

-------

-Creates a new pseudo GUID.
------

var guid = ‘xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx’.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == ‘x’ ? r : (r & 0×3 | 0×8);
return v.toString(16);
});
return guid;

}



This generates a session ID like : 3f58555c-d6f4-4b1e-ac2a-b89f5d173944

then Use web_js_run() function.

Save the above javascript code with .js extension in the script folder.
Add the script under Extra files via Add Files option
Go to RunTimeSettings -Preferences-Options-Web Javascript header-Enable running javascript code == change the value to Yes
Write the following function.the the result is stored in param1

Flex Protocol Scripting in LR

Introduction

Adobe Flex is a software development kit released by Adobe Systems for the development and deployment of cross-platform rich Internet applications based on the Adobe Flash platform. Flex applications can be written using Adobe Flex Builderor by using the freely available Flex compiler from Adobe.
Developers use two core languages to create Flex applications. The first core language is MXML, the Macromedia Flex Mark-up Language, which includes a rich set of XML tags that allows developers to layout user interfaces. Some MXML constructs allow you to call remote objects, store data returned in a model, and customize your own look and feel to MXML components.
The second core language for Flex development is Action Script 2.0, which is similar to JavaScript. Action Script elements are coded inside MXML pages has robust event handling capabilities to allow the application to respond to dynamic user interactions. Unlike JavaScript, since Action Script runs inside the Flash plug-in there is no need to rewrite several versions of the same code to support different browsers.
The Flex server is responsible for translating the MXML and Action Script components into Flash byte code in the form of .SWF files. The SWF file is executed on the client in the Flash runtime environment. The Flex server provides other services such as caching, concurrency, and handling remote object requests. 


Flex Protocol with LR

VuGen allows you to create Vusers that emulate the protocol suite provided with the Flex 2 SDK.

RIAs are lightweight online programs that provide users with more dynamic control than with a standard web page. Like Web applications built with AJAX, Flex applications are more responsive, because the application does not need to load a new Web page every time the user takes action. However, unlike working with AJAX, Flex is independent of browser implementations such as JavaScript or CSS. The framework runs on Adobe's cross-platform Flash Player. 

Pre-requisite
  •     Load Runner 11.0 support the flex with the patch3
  •     JRE 6.0 
  •     Adobe flash player 10 and higher

Environment Variables

Verify for the following environment variables in Windows Operating system.

The environment variables can be reached by following the below steps:

1.    Right-click “My Computer”. Go to properties.
2.    Go to Advanced Tab
3.    Click on the Environment Variables button

Click on the “Ne“button under System variables and enter the below values:

Variable name: HP_FLEX_JAVA_LOG_FILE
Variable value: C:\flex.log

Variable name: VUGEN_PATH
Variable value: C:\Program Files\HP\Virtual User Generator\

Variable name: ANALYSIS_PATH
Variable value: C:\Program Files\HP\LoadRunner\

* The HP_FLEX_JAVA_LOG_FILE is used to generate the log file which will help us to identify the classes involved in a particular transaction.
This log file will be very useful for debugging. Ensure that there are no errors in the flex log file after recording.


Recording Options

The following recording options need to be considered before recording in flex protocol:

·         Go to Tools à Recording Options in LoadRunner.

·         Under Script Check the check box against “Generate recorded event logs”. This setting helps to generate the log files for debugging

·         Under Protocols tab select all three check boxes viz.,

o    Action Message Format (AMF)
o    Flex
o    Web(HTTP/HTML)

·         Under Recording, select HTML based script.

·         Select HTML Advanced button and select “A script that contains explicit URLs only (e.g.web_url, web_submit_data)”  and “Record in separate steps and use concurrent grops” for Non HTML – generated elements
·         Under Code generation select Encode AMF3 using external parser.And provide the below jar files location under Value column.

o    flex-messaging-common.jar
o    flex-messaging-core.jar
o    (Any application specific jars.The jars are dependent on the transaction and should be verified before recording every transaction)  

·         Under Port-Mapping, click on Options. Under Advanced Port Mapping Settings à Change Log level to Advanced Debug. - This setting would enable to generate flex log in C:\ drive.
  
·         The Advanced tab under HTTP properties is the standard one. 

·         Under Correlation tab, uncheck the “Enable correlation during recording” check box.
 


Post Recording Verification

After recording verify following:

1.    A file by name “flex. log” should be generated in C:\ drive.

2.    flex_amf_call should be generated with readable XML’s and not the binary format for all requests.


Correlation in Flex Scripts

Flex applications often contain dynamic data, data that changes each time you run the script. For example, the object name may change from run to run.

When you record a Vuser script, VuGen records a set of data and argument values. When you replay the script, however, the server may reject these arguments and issue an error. This error could be the result of dynamic data that is outdated and no longer accepted by the server.
To overcome this, you apply correlation to your script:

➤ Save the server response in preparation for extracting the required values.
➤ Extract the required values from the server response.
➤ Save the values to a parameter.
➤ Use those parameters as input to your Flex requests.

These errors are not always obvious, and you may only detect them by carefully examining Vuser log files. If you encounter an error when running your Vuser, examine the script at the point where the error occurred. Often, correlation will solve the problem by enabling you to use the results of one statement as input for another.
To perform correlation:

Locate the step in your script that failed due to dynamic values that need correlation.

Use the Replay Log to assist you in finding the problematic step.





Identify the server response with the correct value in one of the previous steps.

Double-Click the error in the Replay log to go to the step with the error. Examine the preceding steps in Tree View and look for the value in the Server Response tab.


3 Save the entire server response to a parameter.

Before you extract the value, the entire server response should be saved to a parameter as follows:

➤ Right-click the step node (in the left Action pane) corresponding to the server response containing the value and select Properties.
➤ In the Flex Call Properties dialog box, type a Response parameter name.
➤ Click OK to save the new parameter name.

Save the original server response value to a parameter.

➤ In the Replay Snapshot: Response Data, right-click the node above the value (for example, string), and select Save value in parameter.



 
In the XML Parameter Properties dialog, specify a parameter Name. You will use this name in subsequent steps.

➤ Click OK. The script will now contain a new function, lr_xml_get_values.

Insert the parameter in the subsequent calls.

In VuGen edit view, beginning with the call that failed, replace the value in all subsequent calls to the object with the parameter that you defined:

➤ Right-click the step node (in the Action pane) corresponding to the failed call and select Properties.
➤ Locate the argument that required correlation.
➤ In the Value box, type the parameter name in curly brackets, for example, {ParamValue_string}.



Click OK
 
Run the script.

Make sure that VuGen properly substitutes the argument value with the parameter value that you saved.

Some Important JAR files needed are 


 
We need application JAR files as well along with these JAR files from developer to generate the decoded AMF calls in the scripts else we can’t parse and correlate the requests.

Wednesday 23 November 2016

Reasons for High response time

It all depends on you scenario setup. How you have setup scenario to run vusers, is it initialize all vusers simultaneously or is it in ramp up fashion.....so having response time high could be your application as well but again you have to look over your scenario settings then come up with conclusion over high response time.

Execution logs are the logs which got captured during your test based on client server communication.


During on of my project .SWT file was taking longer time.


Response from Team:


Very 1st point generally we should not keep login part in Action section of script as it doesn't seem to be a realistic scenario. Think does real world user (Customer) login and logout that frequently as you are making your application to do in your scenario? My suggestion would be to keep login in init and logout in end section of scripts. But still taking your scenario into consideration.

I am not sure if this way I can help you without having look at the results but still you can try as mentioned below:

1. You must be having .lrr file as test results. (If test was executed in controller)

2. Open .lrr file with Analysis LR component. Let it open complete 100% data. Data generation can be seen at bottom on analysis component.

3. Once 100% data is generated. Open Average Response Time graph.

4. Right click on graph select merge graph and select running vuser graph. This will give you running vuser and average response time graphs in single graph.

5. With this graph you can find exactly after what user load login transaction started taking more time. Once you find the point where login transaction starts consuming more time note down the time and note down what is user load at that particular point of time.

6. Now open other graphs like CPU utilization, Memory utilization (Committed Bytes/ Available MB) check there consumption level if there are normal utilization if you see utilization beyond 90% note down user load and point of time when your server starts consuming beyond 90% level.

Report this to development/Application team with this detail. This will help them.

Ask them to monitor application server from back end while you are running load test. This will give them great understand of root cause.

7. If you have tools like NewRelic,Appdynamics or Dynatrace from there you can drill down transaction wise and find out the culprit behind the high respone time. It could be a database query taking high response time,Network delay, high Disk read/write or multiple queries getting fired for the same transaction.





Tuesday 22 November 2016

common recording problems

Problem 1: No events are being recorded
Here are the most common reasons why no events are showing in the script:

The events counter keeps increasing, while the generated script is empty
This may be because VuGen’s recording mechanism fails to identify HTTP data. To fix it, ensure that your application indeed uses HTTP Web traffic. If the application uses SSL connections, make sure you choose the correct SSL version (SSL 2, SSL 3, TLS) through the Port Mapping dialog, available by clicking the ‘Options…’ button on the Record > Recording Options… dialog:

The Advanced Port Mapping Settings dialog opens when you click ‘Options…’:

The events counter shows less than five events, while the application keeps getting data from the server
In this case, VuGen’s recording mechanism fails to capture any network activity at all. Ensure that your application really does provide some network traffic, ie. it sends and receives data through the IP network. If an antivirus program is running, turn it off during recording. Check the recording log for any clues about the recording failure. Messages such as “connection failure” or “connection not trapped” can be a sign of the wrongly configured Port Mapping settings.
In addition, if you are recording on a Chrome or Firefox browser, make sure that all the instances of the browser are closed prior to the recording.

Problem 2: Specific events are not recorded
This problem could be caused by the event being dropped as “uninteresting”. By default, VuGen’s Web (HTTP/HTML) protocol records client requests that return an HTTP response status of 2xx or 302, and discards all other requests. If a missing request returns a response that was discarded, such as 301, you can make a modification to the registry to instruct VuGen to generate a command for it:

  • Locate the following registry key:
    • [HKEY_CURRENT_USER\Software\Mercury Interactive\Networking\Multi Settings\QTWeb\Recording]
  • Add the following string value to it:
    • "GenerateApiFuncForCustomHttpStatus"="301"
Problem 3: The recorded application becomes unresponsive during the recording
This could be caused by VuGen’s recording mechanism not being able to connect to the application’s server. Network connection errors can be seen in the Recording Log:

[Net An. Warning  (1068:197c)] Request Connection: Remote Server @ 123.123.123.123 - 5222 (Service=) Failed attempt #1. Unable to connect to remote server: rc = -1 , le = 10060)
[Net An. Warning  (1068:197c)] Request Connection: Remote Server @ 123.123.123.123 - 5222 (Service=) Failed attempt #2. Unable to connect to remote server: rc = -1 , le = 10060)

Note: the Recording log is in the ‘Output’ pane.  Make sure ‘Recording’ is selected in the combo-box on the left:

In order to fix this problem, the Port mapping for the specific IP and port should be added to the Port Mapping dialog (under theRecord > Recording Options… menu), and the entry should be unchecked. That will ensure that the above IP and port are not recorded – that application simply connects to them without any LoadRunner involvement. For the messages above the correct setting would be:

This workaround can be done in case the communication to 123.123.123.123:5222 is not important for the business process and can be omitted. If that’s not the case, the same entry should still be added, but left as checked. That will ensure correct traffic capture to this address.

Problem 4: During the recording the recorded application shows an error message about the wrong server certificate
The problem is caused by the inability of the client side to verify the validity of the server certificate. In order to fix this problem, the LoadRunner Certificate Authority (CA) file should be added to the machine’s “Trusted Root Certificate Authorities” certificate store (in case of a Java client application, LoadRunner’s CA should be added to Java’s trusted CA list using the keytool). This file is supplied with LoadRunner, and is called wplusCAOnly_Expiration_2022.crt. It’s located in the <LR_folder\bin\certs> folder.

To add it to the store, double-click on the file to open the certificate:

Then click ‘Install Certificate…’ to open the Certificate Import Wizard’:

Make sure you check ‘Place all certificates in the following store’ and select ‘Trusted Root Certification Authorities’.  When the wizard is completed, you should be able to record the application.

Problem 5: The browser crashes during recording when using the Ajax Click and Script protocol
This can happen when some of the Ajax controls inside the application are not recognized by VuGen. In order to fix it:

  • Go to the  <LR_folder\dat\protocols> folder and open the WebAjax.lrp file
  • Comment out the following: DllGetClassObject:jscript.dll=DllGetClassObjectHook:ajax_hooks.dll (simply put a semi-colon (‘;’) in front of the line)
You should now be able to record the application.



We hope you found this article useful.  Let us know by leaving a comment in the box below.