AJAX application Load Testing

Ajax, sometimes written as AJAX (shorthand for Asynchronous JavaScript and XML), is a group of interrelated web development techniques used on the client-side to create interactive web applications or rich Internet applications. With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page. The use of Ajax has led to an increase in interactive animation on web pages and better quality of Web services due to the asynchronous mode. Data is retrieved using the XMLHttpRequest object. Despite the name, the use of JavaScript and XML is not actually required, nor do the requests need to be asynchronous.

Like DHTML, Ajax is not a technology in itself, but a term that refers to the use of a group of technologies. Ajax uses a combination of:

  • HTML and CSS for marking up and styling information.
  • The DOM accessed with JavaScript to dynamically display and interact with the information presented.
  • A method for exchanging data asynchronously between browser and server, thereby avoiding page reloads. The XMLHttpRequest (XHR) object is usually used, but sometimes an IFrame object or a dynamically added <script> tag is used instead.
  • A format for the data sent to the browser. Common formats include XML, pre-formatted HTML, plain text, and JavaScript Object Notation (JSON). This data could be created dynamically by some form of server-side scripting.

Due to this, the browser and the server exchange small amounts of data asynchronously in the background. The number of exchanges may be large in numbers. We are going to use Microsoft's Bing for this tutorial. When you enter a search string in the search field and then search for the match. It presents a list of search results. When you move your mouse of each of the search result it allows you to peep into the site without actually visiting that site. It shows the contents of the site in square box when you move the mouse over the small brown circle with a tool tip "More info". This is done using AJAX request. Where browser sends a requests the server to get the contents of the result entry asynchronously.

Note: The application "Bing" is used only for demo purpose and must not be used to run test with more than 1 virtual user. Also the test duration must not be more than 1 minute.

This tutorial provides a brief introduction to load testing AJAX applications using AppPerfect Load Test with hands-on practice exercises. This tutorial assumes you have successfully downloaded and installed AppPerfect Load Test on your machine with the default options and you are connect to Internet. Apart from this pre-requisite, this tutorial is self contained. Instructions given below are Windows-specific; if you are using a non-Windows machine, please use equivalent commands/instructions.

This document is divided into following sections

  1. Creating Project
  2. AppPerfect Load Test

Within each section, multiple exercises are listed. Each exercise forms a logical unit which is expected to take no more than a few minutes to perform. All exercises use Microsoft's Bing site.

All exercises assume you have installed the product in C:\AppPerfect\LoadTest folder and will be referred as LOADTEST_HOME henceforth in tutorial. If you have installed the product in some other folder, modify the instructions below appropriately.

This tutorial is not intended as a comprehensive training guide. Please refer to the product documentation for detailed information. However, this tutorial will give you a very good overview of the products and substantially improve your productivity with the product.

Creating Project

Exercise 1: Launch AppPerfect Load Test

  1. Click on Start -> Programs ->AppPerfect Load Test x.x.x -> AppPerfect Load Test
  2. On launching AppPerfect Load Test a Welcome page will be displayed. Go through various sections provided in the welcome page.
    NB: Welcome page is displayed only when Load Test x.x.x is launched and last time no project was opened.

Exercise 2: Creating a Project

  1. Launch the Project Wizard by clicking File ->New... menu option. The New Project wizard will be launched.
  2. Keep the default project name and location for the purpose of this exercise. Click on the OK button.
  3. A confirmation message saying that the project is saved will be displayed. Click on the OK button.

Now using this project we will create tests to demonstrate the functionalities of AppPerfect Load Test product.

AppPerfect Load Test

NB: Please follow the steps provided in the "Creating Project" section to first create a project, then proceed further.

Exercise 1: Define a Load Test project

  1. Once the project is successfully created another dialog - Define Project Properties dialog - will be displayed.
  2. Change the default settings as shown in this dialog as Test Duration:1min, Load Type:Loop, Loop Count:3, Virtual Users:1.
  3. Go through the description given for Loop load type at the bottom.
  4. Review other settings in the Panel and click on the Finish button to close this dialog.
  5. Click through all the menu items to familiarize yourself with the available features and how to access them. Viewing through all menu items will give a reasonable overview of the application.
  6. Click Help -> Table of Contents menu item to see AppPerfect Load Test product documentation
  7. Open the Preferences dialog by selecting the menu option Tools -> Options...
  8. Review the default settings for Load Test and click the OK button to close the dialog.

Exercise 2: Recording a Test

  1. To start recording, click on Project -> Record test... in the menu bar.'
  2. 'Record a test' dialog will be displayed. Select ActionGroup1 from the Group combo. Provide starting URL as "http://www.bing.com". Now Click on 'Start recording' button to start recording.
  3. An instance of configured browser will be launched with the Bing's home page loaded. This home page has a search field. Enter "Load Test" in the search text field and press Enter or click on the Search icon.
  4. This will take us to the search results page.
  5. Now move the mouse over the first entry. Keep the mouse more on the right hand side of the entries. You will find a rectangle filled with light brown color. If you take your mouse over this circle. It will pop up a pointer box that shows contents of the site which will be directed to if you click on the search entry.
  6. Browser sends a request to the server to get the contents of the search entry asynchronously. This request though not visible to the user (as it happens when a page refreshes etc) is a request sent to the server and is recorded by AppPerfect Load Test.
  7. Click on Stop recording in the recording dialog box. It will prompt you with a Passthrough parameter resolution dialog. Normally, it is good to resolve the passthrough parameters after recording itself, but we will do it in the next exercise, hence select Cancel in this dialog. Close the recording dialog.
  8. Check the recorded tasks in the Editor tree. Check the tasks with Path [/captionHandler.aspx]. All these tasks are asynchronous requests made by browser to the server. AppPerfect Load Test has successfully recorded all these tasks.

Exercise 3: Resolving Pass-through Parameters in Test

  1. Pass-Through Parameter are request parameter whose value needs to be extracted from previous responses and passed to subsequent requests. Recording of HTTP/HTTPS tasks for Load Testing has completed. Application has arranged the recorded tasks as Main tasks (Html responses) and sub-tasks (images, css, js, etc.) in the test. For correct execution of the test script, all Pass-Through parameters needs to be resolved correctly.
  2. In the editor tree, select 'ActionGroup1' and select 'Resolve Pass-through parameters' from Project Menu.
  3. Click on Ok to start the automated resolving of the passthrough parameters.
  4. It will start executing the test in an interactive manner where you will be able to see recorded response & replayed response of each task along with other request details. Application will prompt a dilaog box if it identifies any passthrough parameter and waits for your confirmation.
  5. In this exercise it will identify 'IG' as a Pass-through parameter. Select Ok in the dialog box when you are prompted for the same.
  6. AppPerfect Load Test has resolved the pass-through parameters successfully, and during replaying it will extract the value of IG from appropriate Task's response and pass it to all the request where it is required to be sent.

Exercise 4: Verify test in browser

  1. Before actually testing if the server can handle desired load, we should verify if the test replays fine with single virtual user. In order to verify the test, click on Project -> Verify Test using Browse... from the menubar. Select Ok in this dialog.
  2. Load Test will start replaying the test and show the response of each task as it gets executed in the dialog along with other details like parameters passed, request headers passed to the server etc.
  3. Verify that the test replays fine and check response of each task by selecting and confirm that it meets the requirement.

Exercise 5: Executing a test

  1. Now you are ready to load test the server. Click on Project -> Run from the menubar.
  2. Check the status of the test in Status view. Once the execution completes, you will be taken to Result's view where you can view the test execution results.