Skip to main content
  1. Posts/

How to use JMeter to do Performance Testing

·491 words·3 mins· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

Record JMeter Scripts
#

use JMeter’s HTTP(S) Test Script Recorder, please refer to this official document https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html

Running JMeter Scripts
#

  • Debug scripts on JMeter in GUI Mode

    You can debug your record scripts in GUI Mode until there are no errors

  • run test scripts in Non-GUI Mode(Command Line mode) recommend

    jmeter -n -t ..\extras\Test.jmx -l Test.jtl
    

Running JMeter Scripts on Jenkins
#

Need Tools
#

  1. Jmeter - Web Request Load Testing
  2. Jmeter-plugins
    • ServerAgent-2.2.1 - PerfMon Agent to use with Standard Set

Test server
#

Two virtual machines

  • System under test
  • Jmeter execution machine, this server is also Jenkins server

Implement
#

Develop test script
#

Record Scripts - use JMeter’s HTTP(S) Test Script Recorder, please refer to this official document https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html

Create Jenkins job for running JMeter scripts
#

  1. Create a new item->select Freestyle project

  2. Add build step->Execute Windows batch command

    //access to jenkins jobs workspace, empty the last test results
    cmd
    cd C:\Users\peter\.jenkins\jobs\TEST-122 Upload large data\workspace
    del /Q "jtl"\*
    del /Q "PerfMon Metrics Collector"\*
    
  3. Add build step->Execute Windows batch command

    //add first run jmeter script command, if you want run others script you can continue to add "Execute Windows batch command"
    jmeter -n -t script/UploadLargeData-1.jmx -l jtl/UploadLargeData-1.jtl
    
  4. Configure build email - Configure System

    //Configure System, Extended E-mail Notification
    SMTP server: smtp.gmail.com
    
    //Job Configure, Enable "Editable Email Notification"
    Project Recipient List: xianpeng.shen@gmail.com
    Project Reply-To List: $DEFAULT_REPLYTO
    Content Type: HTML (text/html)
    Default Subject:$DEFAULT_SUBJECT
    Default Content: ${SCRIPT, template="groovy-html.template"}
    
    //Advance setting
    Triggers: Always
              Send to Recipient List
    

Generate test report
#

JMeter->Add listener->add jp@gc - PerfMon Metrics Collector, browse Test.jtl, click right key on graph Export to CSV

Analyze test results
#

Introduction test scenarios

Using 1, 5, 10, 20, 30, (50) users loading test, record every group user test results

Glossary

  • Sample(label) - This indicates the number of virtual users per request.
  • Average - It is the average time taken by all the samples to execute specific label
  • Median - is a number which divides the samples into two equal halves.
  • %_line - is the value below which 90, 95, 99% of the samples fall.
  • Min - The shortest time taken by a sample for specific label.
  • Max - The longest time taken by a sample for specific label.
  • Error% - percentage of failed tests.
  • Throughput - how many requests per second does your server handle. Larger is better.
  • KB/Sec - it is the Throughput measured in Kilobytes per second.

Example: Test results of each scenario shown in the following table

User# SamplesAverageMedian90% Line95% LIneMinMaxError %ThroughputReceivedSend KB/sec
13134834545251777357730.00%2.852152.5
515511661164141416021639918210.00%4.264453.73
10310227522992687295436712041040.00%4.385473.84
20620447946205113615264353965710.00%4.428263.88
309306652689974889552100514100600.00%4.467763.91

Test results analysis chart

Response Chart
PerMon Metrics

Related

Bitbucket Webhooks Configuration
·398 words·2 mins
How to configure Bitbucket webhooks to trigger Jenkins builds for multi-branch pipelines, ensuring that Jenkins can automatically respond to events like pull requests and branch updates.
Three Ways to Solve the Jenkins Declarative Pipeline "Method code too large" Exception
·558 words·3 mins
This article introduces three methods to solve the “Method code too large” exception in Jenkins declarative pipelines, including moving steps outside the pipeline, migrating from declarative to scripted pipelines, and using Shared Libraries.
How to Slim Down Your Git Repository
·1133 words·6 mins
How to remove unnecessary files and history from a Git repository to reduce its size, providing two methods using BFG Repo Cleaner or git filter-branch.
A Free C/C++ Static Code Analysis Tool—Cppcheck—Integrated with Jenkins
·926 words·2 mins
This article introduces the installation, usage, and integration of Cppcheck with Jenkins to improve C/C++ code quality and static analysis capabilities.