Cross Column

Showing posts with label Transaction Controller. Show all posts
Showing posts with label Transaction Controller. Show all posts

Friday, January 5, 2018

JMeter―How to Use Firefox to Record Test Scenarios

Video 1.  JMeter Beginner Tutorial 23 - How to use Test Script Recorder (YouTube link)


This article will cover the details of recording HTTP/HTTPS traffic with Firefox (FF) in Apache JMeter. To achieve that, you can use a workbench with HTTP(S) Test Script Recorder.  If you are new to JMeter, watch the above video first.




"Recording" Template


The easiest way to create a complete Test Plan with the HTTP(S) Test Script Recorder is using Recording Template:[1]
  1. Go to JMETER_HOME/bin and start JMeter
  2. Select Templates... on the menu bar
  3. Select Recording template on the list
  4. A complete Test Plan is generated (see the diagram below)
Using "Recording" template, save you a lot of efforts.  For comparison, you can read [2] for manual steps.

In the HTTP Request Defaults element, you can optionally set "Server name":
Server name
enter example.com
Path
leave blank



JMeter Temporary Root CA


Return to HTTP(S) Test Script Recorder, and click the Start button at the top.
Note that you need to "Configure your browser to use the JMeter Proxy" (see the section below) first.  For the discussion only, we will show you the "JMeter Temporary Root CA" first.

This will start the JMeter proxy server which is used to intercept the browser requests. A file called ApacheJMeterTemporaryRootCA.crt will be generated in jmeter/bin folder and you will find a prompt showing below messages:



Installing the certificate in Firefox for HTTPS Recording


 If you're recording SSL/TLS traffic (i.e., your site URL has https prefix), you need to install the certificate (i.e., ApacheJMeterTemporaryRootCA.crt) in your browser. So, JMeter could record encrypted traffic.  If you don't know how to do it, read Installing the JMeter CA certificate for HTTPS recording first.

For the Firefox (or FF) browser, you choose the following options (note that the configuration looks different in different FF versions):
  • Tools / Options
  • Advanced / Certificates
  • View Certificates
  • Authorities
  • Import …
  • Browse to the JMeter launch directory, and click on the file ApacheJMeterTemporaryRootCA.crt, pressOpen
  • Click View<
    and check that the certificate details agree with the ones displayed by the JMeter Test Script Recorder
  • If OK, select "Trust this CA to identify web sites", and press OK
  • Close dialog by pressing OK as necessary 
After import, you can find a new entry on the Authorities list as shown below:



Configure Your Browser to Use the JMeter Proxy


Like many other web testing tools, JMeter records tests by inserting itself as an HTTP proxy between the browser and the web site.  We use FF as our browser when using the JMeter HTTP(S) Test Script Recorder because, unlike Chrome and some other browsers, it does allows you to override system-wide configuration for its proxy settings (see also [8]).

Configure Firefox to use localhost (127.0.0.1) on port 8080 (Note that you also need to set the Port to  be 8080 in HTTP(S) Test Script Recorder) as its proxy for all traffic by following these steps:[7]
  1. Open Firefox
  2. Go to the Preferences menu
    • From the tool bar, click Edit → Preferences (or Tools → Preferences or type about:preferences#advanced as URL). This should bring up the options.
  3. Click on the Advanced tab
  4. Then Network tab
  5. In the "Connection" section, click on "Settings..."
  6. Select the "Manual proxy configuration" radio button
  7. Set HTTP Proxy to "localhost" and Port to "8080"
  8. Check "Use this proxy server for all protocols"
  9. Click OK and exit the Preferences menu

Note: When Firefox is configured to use JMeter's Script Recorder as a proxy, it will only work properly if the Script Recorder is running.


Recording Tips


When you record, you may want to consider the following extra configurations:
  • Follow Redirects vs Redirect Automatically[3,4]
  • Retrieve All Embedded Resources from HTML Files
    • Set in HTTP Request sampler
    • Tell JMeter to parse the HTML file and send HTTP/HTTPS requests for all images, Java applets, JavaScript files, CSSs, etc. referenced in the file.
  • Firefox Data Collection and Use
  • Use the Transaction Controller[5]
    • To generate a “virtual” sample representing a real page to measure aggregate times of all nested samples (i.e., embedded resources―images, styles, scripts, recordings or anything that seems like a separate request).
    • Transaction controllers also provide scopes for JMeter test elements[10,11]
  • URL Patterns to Exclude
    • Set in HTTP(S) Test Script Recorder→ Requests Filtering
    • If the following patterns were not excluded yet, set them manually:
      • (?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|woff|woff2)
      • (?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|woff|woff2)[\?;].*
  • Post-recording updates of Test Scenarios
  • Prepare your click stream before recording
  • Use timers to simulate a virtual user’s “think time”

References

  1. Apache JMeter HTTP(S) Test Script Recorder (Apache Software Foundation)
  2. Apache JMeter HTTP(S) Test Script Recorder (pdf)
  3. When to use “Follow Redirects” & “Redirect Automatically” while recording with jmeter
  4. Difference Between Redirect Automatically and Follow Redirects in JMeter
  5. JMeter―Using the Transaction Controller (Xml and More)
  6. JMeter Proxy exclusion patterns still being recorded
  7. How To Use JMeter To Record Test Scenarios
  8. Use the Profile Manager to create and remove Firefox profiles (Mozilla)
  9. A Comprehensive Guide to Using JMeter Timers
  10. JMeter Scoping Rules - The Ultimate Guide
  11. Scope and Execution Order of Elements in Jmeter
  12. JMeter Beginner Tutorial 21 - How to use Test Script Recorder (video)

Monday, August 14, 2017

JMeter―Using the Transaction Controller

Apache JMeter is a performance testing tool written in Java and supports many operation systems. Controllers are main part of JMeter and they are useful to control the execution of JMeter scripts for load testing.  Logic controllers (e.g., Transaction Controller) also provide runtime scopes for JMeter test elements (read [9] for details).

For example, you can use Transaction Controller to get the total execution time of a transaction (i.e., an end-to-end scenario) which might include the following transaction steps:
Login → Compute Details → Billing Metrics → Back to Dashboard → Logout

Watch this video on YouTube for more details of Transaction Controller.

Controllers


JMeter has two types of Controllers:[3]

  • Samplers
    • Can be used to specify which types of requests to be sent to a server
    • You may add Configuration Elements to these Samplers to customize your server requests.
    • Examples of Samplers include, but not limited to:
      • HTTP Request
      • FTP Request
      • JDBC Request
      • Java Request
      • SOAP/XML-RPC Request
      • WebService (SOAP) Request
      • LDAP Request
      • LDAP Extended RequestAccess Log Sampler
      • BeanShell Sampler
  • Logic Controllers
    • Can be used to customize the logic that JMeter uses to decide when to send requests
      • For these requests, JMeter may randomly select (using Random Controller), repeat (using Loop Controller), interchange (using Interleave Controller) etc.
      • The child elements of a Logic Controllers may comprise 
    • Examples of Logic Controllers include, but not limited to:
      • Transaction Controller
      • Simple Controller
      • Loop Controller
      • Interleave Controller
      • Random Controller
      • Random Order Controller
      • Throughput Controller
      • Recording Controller
In this article, we will focus mainly on Transaction Controller which may be used to
  • Generate a “virtual” sample to measure aggregate times of all nested samples




Option: "Generate Parent Sample"


When "Generate parent sample" in Transaction Controller is
  • Checked 
    • Only Transaction Controller virtual sample will be generated and  all other Transaction Controller's nested samples will not be displayed in the report
  • Unchecked 
    • Additional parent sample (i.e. Transaction Controller virtual sample) after nested samples will be displayed in the report

Option: "Include Duration of Timer and Pre-Post Processors in Generated Sample"


Each Sampler can be preceded by one or more Pre-processor element, followed by Post-processor element. There is also an option in Transaction Controller to include and/or exclude timers, pre and post processors execution time into/from virtual samples.

When the check box "Include duration of timer and pre-post processors in generated sample" is
  • Checked
    • The aggregate time includes all processing within the controller scope, not just the nested samples
  • Unchecked
    • The aggregate time includes just the nested samples; however, excludes all pre-post processing within the controller scope


© Travel for Life Guide. All Rights Reserved.

Analytical Insights on Health, Culture, and Security.