HCL Commerce Version 9.1.8.0 or later

OneTest Performance sample script for Emerald B2C Store

HCL OneTest provides software testing tools to support a DevOps approach: API testing, functional testing, UI testing, performance testing and service virtualization. This approach aids in test automation, for earlier and more frequent discovery of errors.

Before you begin

A key aspect of performance testing is the ability to simulate concurrent user load. The - OneTest Performance sample script for the Emerald (B2C) store provides you with a sample project to generate and simulate user traffic against the Emerald (B2C)store. The script includes common search, browse, and checkout scenarios. The functionalities are not all inclusive and need to be adapted to match your store customizations and usage patterns. The following illustrate how to import, configure, and use the script to simulate user traffic against the Emerald (B2C) store.

Setting up the Script

The archived package contains two files:
  • A Word Document with instructions for setting up the script.
  • A OneTest performance script file.

To set up the OneTest Performance script, you will need to follow three steps:

  1. Import the script
  2. Import the libraries.
  3. Clean the project.
  1. Importing the package
    1. Extract the sample package file (zip file) to a working directory.
    2. Open OneTest and choose a new Workspace, then choose a location and an appropriate Workspace name.
    3. Close the Welcome tab.
    4. Right click Test Navigatorand select Import.
    5. Select Test > Test Asset with Dependencies and click Next. Select the file you downloaded in step 1 and then click Finish.
  2. Import the libraries
    1. If a red x appears on the SRC folder, follow the steps described below (this situation can occur if you are running a OneTest version lesser than 10.1.x).
    2. Select Properties from the context menu by right-clicking on the project name.
    3. In the Properties window, select Java Build Path in the left pane and Libraries tab in the left pane.
    4. Click Add JARs button. In the JAR Selection window, expand the project and expand the libs folder. Select the jar files and click OK button.
    5. Click Apply and close the window.
  3. Clean the project
    1. Click menu Project and choose Clean command.
    2. On the Clean window, ensure the project is selected and then click Clean button.
Note: For more information on how to use One Test performance with HCL Commerce (for load testing), see OneTest Performance - Sample Script for Emerald Store.

Updating the script before using

After you import and set up the script, you must update it and apply initializations before you can use it. Before using the script, make sure it is up to date.

  1. Update global variables.
  2. Update Datapools.
  3. Update Schedules.

The details on these steps one by one will be found below:

  1. Update global variables

    The B2C Homepage module houses all of the global variables.

    To see all the global variables, go to Resource View, expand Modules B2C, open B2C Homepage module, then expand Test Resources and Test Variables.

    Change the values of the variables that relate to your surroundings.

    Table 1. The variables that need to be updated before using the performance script are:
    Variable name Description
    hostname The hostname used in the URL of the e-commerce storefront.
    store_id

    The store id.

    The defaults store ids are 11 for Emerald B2C store and 12 for B2B Sapphire store.

    The store Administrator can provide store ids.
    lang_id

    The default language id of the store.

    -1 is English.
    catalog_id

    The catalogue id used in the store.

    The store Administrator can provide catalogue ids.
    port_num The port number used in the URL of the storefront.
    store_name

    The store name.

    The complete URL of the storefront is hostname: port_num/store_name
    max_items_in_cart Maximum number of items in the cart. For each user, the number of items to be added to the cart if calculated randomly to be between one and the value of max_items_in_cart.
    fixed_number_of_items_in_cart

    This variable shows if the number of items in the cart is fixed throughout the run or is randomly calculated to each user. The value of this variable is boolean. 1 for true, and 0 for false.

    • If fixed_number_of_items_in_cart = 1, then the number of items in the cart will be equal to the value of max_items_in_cart for all users.
    • If fixed_number_of_items_in_cart = 0, then the number of items in the cart will be selected randomly for each user between 1 and the value of max_items_in_cart.
    users_password The password used for registered users. The script is configured to use a single password for all registered users. If you plan to use a different password for each user, you may need to create a different Datapool with two columns, one for the userId and one for its password.
    email_domain The email domain that will be added automatically to userids.It is set by default to company.com, so the emails will be with this format string_email@company.com where string_email is randomly generated string.
    enable_80_20

    This variable enables (when equal to 1) or disables (when equal to 0) the 80/20 rule.

    When 80/20 rule is enabled by setting this variable to 1, it will change the way to pick randomly the categories and the products. 20% of categories and 20% of products will be picked 80% of the time. This will increase cache hit.

    When the 80/20 rule is disabled by setting this variable to 0, all the items in the storefront are picked randomly without any rule.

    The other variables do not need to be set or updated. It's basically a bunch of global variables.

  2. Update Datapools
    1. Open the Datapools folder in the Test Navigator.
    2. Change the content of the searchterm_oob datapool by (right-clicking it > Open with > Text Editor) to include search keywords relevant to your catalogue.
    3. Open the userids datapool and populate it with the userids you created and imported into the database earlier.

      In the datapool, users with the format “hcluser % ” are pre-added.

      Before you begin the performance test, you must first load the registered users into your database.

  3. Update Schedules
    1. This project is divided into four schedules:
      Table 2.
      Schedule Description
      B2CFlow This is the most important schedule for driving production storefront load. It contains the shopping flow for registered users, shopping flow for guest users and search.
      TestB2CFlow This schedule is the same as B2CFlow. It should be used for testing and debugging new modules or custom codes. It uses less users and the trace log is set to All. You may disable/enable portions of the schedules to test a part of the flow.
      B2CCleanCarts Used to clean carts. It shows how we can build quickly new schedules by updating some modules (B2CGoToCart) and combining some modules together.
      B2CDeleteFromCart This is used to add some items to cart and then clean the cart. This schedule shows how we can combine and add modules (without any change) to build a new schedule.
      B2CMyAccount Used to test My Account for registered users. It adds and deletes addresses. This part is not included in B2CFlow because it may create a lot of shipping and billing addresses for each registered user which is not common.
    2. Before running a performance test, be sure you check and update the following items as needed:
      1. Show Advanced

        Check the Show Advanced checkbox when you initially access the schedule to see the Change Rate and Settle Time columns.

      2. User stage characteristics

        Select and click Edit to alter the user's stage. You may adjust the number of users, the duration of the run, the pace at which users are started, and the settle time in the popup.

        For one hour, the above configuration runs the schedule with 20 users. Over the course of 5 minutes, all 20 users will be up and running.

      3. Think time

        To check think time, click dropdown Category and select Think Time.

        The Think Time is the amount of time that OneTest takes between each request. For stress load, it's small, and for reliability load, it's between 2 and 5 seconds.

      4. Statistics sampling

        Set the log level and interval time used by OneTest to gather statistics to check the statistics sampling.

        For lengthy runs, increase the interval, while for short runs, lower it.

      5. Test log

        You can set a small number of users and Log levels to All if you're debugging an issue. Uncheck Show errors and failures, Warnings, and Other types for extended production runs and, especially, for a large number of users.

      6. Transactions Weight

        Select Random Selector from the Schedule. You can modify the weight in the right pane depending on the scenario you wish to execute. The percentage of the block on the schedule will change as the weight is changed.

Run the schedule

After you've completed the preceding steps, launch the TestB2CFlow schedule and run it with one user for a few minutes with full logs to check for any issues.