Dynamic Parameter handling in Load Test

This tutorial provides a brief introduction to the handling of dynamic parameterization of an AppPerfect Load Test using a set of hands-on practice exercises. This tutorial assumes you have successfully downloaded and installed AppPerfect Load Test on your machine with the default options. 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 the PetStore demo application running inside Apache Tomcat. The modified PetStore application and Tomcat are both bundled with this product.

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 the brief description given for product.
    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://localhost.:8396/petstore". Now Click on 'Start recording' button to start recording.
  3. An instance of configured browser will be launched with the PetStore home page loaded. Click on enter the store link. This will populate the database and display the PetStore main page. Note that populating the database might take some time.
  4. Order an item by clicking on: Birds -> Amazon Parrot -> Adult Male Amazon Parrot -> Add to cart
  5. Check out by clicking on the Check Out link.
  6. At the 'Sign in' page, under "Are You a returning customer - Yes.", enter username as j2ee and password as j2ee. Click on Submit.
  7. Sign out of PetStore by clicking on Sign-out at top right of screen.
  8. Close browser by clicking on File -> Close in the browser window.
  9. 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.
  10. Click on Close button to close the 'Record a test' dialog.
  11. The URLs navigated will be displayed under ActionGroup1.
  12. Click through each Tasks to view its details on the panel on the right.

Exercise 3: Creating required parameters

There are certain web applications, where the value of typical parameters changes on every access to the page containing this parameter. Further more, the value of this parameter needs to be propogated in subsequent requests to get a desired result. Passing same static recorded value will not result in expected results. Such parameters are called dynamic parameters. AppPerfect Load Test has an ability to identify such parameters and read their values from previous response and propogate it to subsequent requests. Built-In Petstore application does not have any request whose value actually changes on every request, but to give you an understanding about dynamic parameter, we will create a scenario where the category of the animal selected for each virtual user is different from recorded value "Birds". During recording we selected "Birds" category. But, during test execution we want the application to select all the categories present in Petstore application. i.e. Each virtual user should select different category and not just Birds. In order to acheive this we will define a simple parameter named categories. Note, this is not a dynamic parameter. Please do the following:

  1. In the editor tree, select 'Parameters' to open the parameters settings table on the right hand side.
  2. Here, click on 'Add Parameter' button to add a parameter.
  3. Select 'Fixed Values' as Data Source. Select Next button.
  4. In the 'Parameter Setting Dialog', enter 'categories' as the parameter name.
  5. Under Add Value, enter Reptiles and click on the 'Add' button.
  6. Under Add Value, enter Dogs and click on the 'Add' button.
  7. Under Add Value, enter Cats and click on the 'Add' button.
  8. Under Add Value, enter Fish and click on the 'Add' button.
  9. Choose 'Sequential' as parameter selection.
  10. Click Finish.
  11. In the editor tree select the task which states something like 'Task7 [/petstore/selection.do]'.
  12. Select 'Post Parameters' tab.
  13. Click on the parameter name 'selection' in the parameters table. Recorded value of this parameter will be Birds.
  14. Click on the 'parameterize' button.
  15. In the parameterization settings dialog, select selection under the name column in the parameter settings table.
  16. On selection, in the value group, 'Constant' will be selected with the value Birds in the text box.
  17. Select 'Parameterize' and from the combo box, select categories. This will use the values of categories as selection on each iteration.
  18. Click Finish.

Exercise 3: Identifying dynamic parameters

During recording we selected "Birds" category, which we parameterised to use different categories. But note that the next tasks still continues to fire a request which selects "Amazon Parrot" as the bird. What we want is when Reptiles category is selected during replaying, it should select "Rattlesnake" instead. Similarly, in the next step it should select Venomless Rattlesnake and not Adult Male Amazon Parrot. In order to achieve this do the following:

  1. Click on Project -> Resolve Pass-through parameters from the menubar.
  2. Click on Ok. It will open a dialog which shows recorded response and also replayed response.
  3. It will select Reptiles as we have parameterised it. When it goes to next task, viz Task10, it finds that the recorded value was Amazon+Parrot where as it found value of the parameter as Rattlesnake in the response of Task7. Application will hence pop up a dialog to notify that it found a different value than the recorded value, so it feels that this parameter is a dynamic parameter. Select Ok in this dialog, and it will proceed further with next tasks.
  4. Run the above steps two more times so that passthrough parameters in next 2 main tasks i.e. Task13 and Task17 also get resolved.

Exercise 4: Verifying the test and confirming the values chosen by Load Test

  1. Select Project -> Verify Test using Browser... from menubar.
  2. In the dialog box, set sleep time between two tasks as 5 seconds. This will ensure that each new task is fired with a gap of 5 seconds and we can check the parameters passed and the browser view as to which pet has been selected.
  3. In Iteration details specify value as 2 for Iterate through selected action group(s). We will run this test for 2 iterations, this will result in application selecting Reptiles category during first iteration and Dogs during second iteration.
  4. Click on Ok to start verification of the test. Replay in browser dialog will come up with Iteration1 and Iteration2 top level nodes
  5. Test will proceed slowly, select Parameters tab in the bottom tab panel.
  6. Keep checking the execution of the tasks. In first iteration you will find that finally Venomeless Rattlesnake is added to the cart and in the second iteration Adult Femal Golden Retriever is added to the cart.
  7. Once you are confident with the parameter selections, project can be executed with large number of virtual users for actually putting load on your server with proper sets of parameter values