How to use Artillery for load testing with different input values

konyu

@kon_yu

Posted on May 23, 2020

How to use Artillery for load testing with different input values

Overview

Describes a configuration to achieve a load test that posts sequential input values using a load tool called Artillery.

What is Artillery?

Apache bench is famous for simple load tests, but artillery is useful for more complex tests. It's also lighter and more modern than the old jMater.

Operating environment

" artillery -version

        ___ __ ____ ____ ____
  _____/ | _____/ /_(_) / /__ _______ __ (_)___ _____
 /____/ /| | / ___/ ___/ __/ / / / _\fnDroid_/ ___/ / / / / / / __\froid_/
/____/ ___ |/ / / /_/ / / __/ / / /_/ / /_/ /_/ /_/ /____/
    /_/ |_/, (_)_/, (_)_/, (_)_/, (_)_/, (_)_/.
                                    /____/

------------ Version Info ------
Artillery: 1.6.0
Artillery Pro: not installed (https://artillery.io/pro)
Node.js: v13.7.0
OS: darwin/x64
-------------------
Enter fullscreen mode Exit fullscreen mode

CSV for input data

Prepare a CSV file with defined input values.
In this example, the continuous ID and date strings are set to id and date, respectively.

id,date
1,2020/1/1
2,2020/1/2
3,2020/1/3
4,2020/1/4
5,2020/1/5
6,2020/1/6
7,2020/1/7
8,2020/1/8
9,2020/1/9
10,2020/1/10
11,2020/1/11
Enter fullscreen mode Exit fullscreen mode

Load test definition file

config:
    target: "https://TAEGET_URL"
    phases:
      - Duration: 5
        arrivalRate: 2
    # Add payload element when CSV is loaded. 
    payload:
      # Define the coping file and fields to load
      path: "keywords.csv"
      fields:
        - "id".
        - "DATE"
      # Specify sequential if you want to run csv in order from the beginning 
      order: sequence
      # Ignore the first line of the csv
      skipHeader: true
scenarios. name: "scenario name":
    - name: "Scenario name"
      FLOW:
        - POST:
            url: "/"
            # Define parameters as {{{xxx}} when posting
            json:
                {id: "{{id}}"
                date: "{{date}}"
Enter fullscreen mode Exit fullscreen mode

Run the test

If the artillery path is followed, you can use run and test definition files as arguments like this

artillery run script.yml
Enter fullscreen mode Exit fullscreen mode

Example results

All virtual users finished
Summary report @ 17:31:08(+0900) 2020-05-22
  Scenarios launched: 10
  Scenarios completed: 10
  Requests completed: 10
  Mean response/sec: 1.67
  Response time (msec):
    1.67 Response time (msec): min: 994.1
    Response time (msec): min: 994.1
    median: 1074.3
    p95: 2057.4
    p99: 2057.4
  Scenario counts:
    Search and buy: 10 (100%)
  Codes:
    200: 10
Enter fullscreen mode Exit fullscreen mode
πŸ’– πŸ’ͺ πŸ™… 🚩
konyu
@kon_yu

Posted on May 23, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related