Use (JMeter) Scripts to Test Web Servers

As a system administrator, you are responsible for the performance of your multistep web servers. With ASM (JMeter) Script Monitors, you can simulate and measure the performance of multistep, web server transactions such as, log-ins and shopping carts.
cacm82
As a system administrator, you are responsible for the performance of your multistep web servers. With ASM (JMeter) Script Monitors, you can simulate and measure the performance of multistep, web server transactions such as log-ins and shopping carts.
If you need certificate validation, consider creating another https monitor. That also comes with warnings when your certificate is about to expire because JMeter is validating the SSL layer only.
The JMeter application is used to create the scripts for the ASM Script Monitors. JMeter is a Java-based application that runs on many platforms including, Microsoft Windows, MacOS, and Linux.
JMeter does not execute the client-side code. Construct your scripts to test procedures that do not require JavaScript or any other client-side code.
The following diagram shows the steps for using a script monitor:
Use script monitors
Page Contents:
Verify the Prerequisites
Before you start to record scripts, ensure that you have the latest supported version of JMeter, 4.0. Go to the Apache JMeter website to download. Backward compatibility with JMeter 2.13 is also supported.
Record a JMeter/HTTP Script with JMeter
To create a script that monitors can use to test web servers, record a JMeter/HTTP test script with JMeter.
Follow these steps:
  1. Open JMeter, right-click
    Test Plan
    on the left pane and then select
    Add, Threads (Users), Thread Group
    .
  2. Right-click the
    Workbench
    element on the left pane, and then select
    Add, Non-Test Elements, HTTP(S) Test Script Recorder
    .
    An
    HTTP(S) Test Script Recorder
    opens on the right.
  3. On JMeter, select the
    HTTP(S) Test Script Recorder
    and configure the port field.
  4. Open a Web browser. Set the proxy server settings to use localhost and the port you specified in the
    HTTP(S) Test Script Recorder
    . Save the settings.
    Close all open web pages in the Web browser before the next step.
  5. In the JMeter menu, select
    Run
    then
    Start
    .
  6. Enter the URL of the web page you want to monitor in the Web browser address bar. Select enter or reload.
  7. After the web page loads, perform the web transaction you want to monitor. For example, log in and add items to the shopping cart.
    If the browser displays an untrusted connection, add an exception and continue with the script recording.
    JMeter collects the HTTP requests under the
    Thread Group
    on the left pane.
  8. When you finish the web transaction, select the
    HTTP(S) Test Script Recorder
    ,
    Stop
    .
  9. Remove the proxy settings from the Web browser settings.
  10. Select the icon to the left of the thread spool to expand the
    Thread Group
    .
    The collected requests appear under the
    Thread Group
    .
    The first request under the
    Thread Group
    creates the script file.
  11. To delete all requests except the first, select the requests, right-click the selected items, select
    Remove
    ,
    Yes
    .
    The selected requests are deleted.
  12. To save the HTTP test script file, select 
    File
    ,
    Save Test Plan as
    , enter the
    File Name
    , select a file location, and then select
    Save
    .
    The script file is saved with a JMX extension.
Verify Results of Requests with a Listener
Use Listeners to verify that the target server responds to the script.
Follow these steps:
  1. Open JMeter, select
    File
    ,
    Open
    , browse to your HTTP test script file.
  2. Right-click
    Thread Group
    on the left pane and go to
    Add, Listener, View Results Tree
    .
    A View Results Tree is added to the
    Thread Group
    .
  3. On the menu, select
    Run
    ,
    Start
    .
    The target server responds to the script request and a red or green request icon appears.
    A green request icon result is correct. If the request icon result is red an HTTP error occurred. Select the request icon next to the exclamation mark to see the error. To fix the error, repeat Record a Script with JMeter.
  4. Select
    File, Save
    .
    The Listener is added to the HTTP test script.
Add an Assertion to Test Web Server Responses
Assertions test if your web server returns the expected response properties. Assertions can verify the following response properties:
  • Response Time
    : use duration assertion
  • Response Size:
    use size assertion
  • Response Content
    : use response assertion
  • HTTP Response code
    : use response assertion
Monitors without assertions only report errors if there is a transaction timeout or a standard HTTP error. Content and performance errors are not reported. The number of assertions in a script are unlimited.
Follow these steps:
  1. Open JMeter, select
    File, Open
    , browse to your JMX File, and select
    Open
    .
  2. Select the icon next to the
    Thread Group
    .
  3. Right-click the request that you want to verify. Go to
    Add, Assertions
    , and select
    Response Assertion
    .
  4. On the
    Response Assertion
    page, select
    Add
  5. Under
    Patterns to Test
    , enter a string or regular expression you want to verify. Select
    File, Save.
    The assertion is added to the JMeter.
Create a Script Monitor
To use a test script file to monitor web servers, create a script monitor and upload the test script to the monitor.
Follow these steps:
  1. Log in and mouseover
    Settings
    , select
    Monitors, New Monitor
    .
  2. From the
    Advanced Synthetic Monitors
    tab, select
    SCRIPT
    monitor.
  3. Enter the monitor name in the Name field and select
    Upload File
    . Browse to the HTTP test script file and select upload.
    The maximum size of a JMeter script is 1 MB.
  4. Select
    Continue
    .
    The
    Script Check and Modification
    page opens, verifies the script, and then provides a script If report.
  5. Review the script details and select Continue to test the script monitor.
    If an error occurs, read the message at the top of the screen and follow directions.
  6. Select
    Continue
    , use the slider to select the
    Check Frequency
    , select
    Finish
    .
    The monitor is saved, activated, and begins to monitor.
(Optional) Add Parameters to Scripts
To use the same script for multiple script monitors, replace the fixed values in the test script with variable JMeter parameters.
The following procedure modifies the host property. Other properties follow the same procedure.
Follow these steps:
  1. Open the HTTP test script file in JMeter.
  2. Select the drop-down icon to expand the
    Thread Group
    .
    The
    Thread Group
    file opens.
  3. Below the
    Thread Group
    , select the request that you want to modify.
  4. Type
    ${__property(WMhost)}
    in the Server Name or IP field and save.
  5. Log in and mouseover
    Settings
    , select
    Monitors
    , then select the script monitor that you want to update.
  6. Go to
    Script File
    , select the upload arrow icon, and upload the script.
  7. Select
    More Options
    and go to
    Host
    and type the hostname.
  8. Select
    Save
    .
    The
    Script Check and Modification
    dialog opens and verifies the script file.
  9. Select
    Continue
    .
    The
    Delete
    logs dialog opens.
  10. Select an option, and then select
    Proceed
    .
    Standard Monitor Parameter
    JMeter Property
    Host
    ${__property(WMhost)}
    Port
    ${__property(WMport)}
    Path
    ${__property(WMpath)}
    User Name
    ${__property(WMaccount)}
    Password
    ${__property(WMpasswd)}
    Script Parameters
    JMeter Property
    foo1=bar1&foo2=bar2&foo3=bar3
    ${__property(foo1)}
    ${__property(foo2)}
    ${__property(foo3)}
    The monitor is tested and creates a report.
    If you receive an error message, reconfigure the monitor or Continue Anyways.
  11. Use the slider to select the optimal check frequency and select
    Finish
    .
    The monitor is saved, activated, and begins to monitor.