Reading list Switch to dark mode

    Artillery-ways to execute Script

    Updated 18 August 2018

    Till now we have read about the artillery and the HTTP load testing in artillery. There are many ways to execute artillery scripts, a quick test, a simple run or run with some over-rides. Lets see some different ways to execute artillery script :

    Run a quick test

    Artillery allows users to run custom test scripts written in either yaml or json, users can also perform a quick test without loading external scripts. The following command specifies 20 GET requests to be sent every second for 10 seconds creating 10 virtual users per request.
    artillery quick –count 10 -n 20 https://your-local-site-to-be.tested

    Run a simple test

    The following yaml file can be executed to achieve a simple run bu using artillery run your.yaml

    config:
      target: https://your-website-link
      phases:
        - duration: 10
          arrivalRate: 10
    scenarios:
      - flow:
          - get:
              # add the url you need to send get request
              url: "/"
              capture:
              # capturing responce using reg expression
                - regexp: "[^]*"
                  as: "response"
          - log: "response= {{response}}"

    This command run the yaml file and sets a load of 10 users for 10 seconds to the given target. The duration and user count can be changed by changing the values  of “duration” and “arrivalRate” respectively.

    Test with output

    We can run the artillery test stating the output of result in a file. The output of test always returns a json file, the path of the file should be with in retailed to the path of yaml file. The following command run artillery test with output file named as “report.json” and the path of file is given relative to the path of test script.

    Start your headless eCommerce
    now.
    Find out More

    artillery run -o ‘report.json’ test.yaml

    This command will give the test output and will generate a report with name ‘report.json’. The outpot will be something like :

    Started phase 0, duration: 10s @ 14:27:36(+0530) 2018-08-13
     
    Report @ 14:27:38(+0530) 2018-08-13
      Scenarios launched:  10
      Scenarios completed: 10
      Requests completed:  10
      RPS sent: 2.13
      Request latency:
        min: 401
        max: 401
        median: 401
        p95: 401
        p99: 401
      Codes:
        200: 100
    Log file: report.json

    Test with overrides

    In many situations it would be useful to adjust some of the values in the config section. To achieve the same, we can use -overrides in artillery.This option is used to override parts of the test script, for example, we need to override the phase definitions in the test script. We can use:

    artillery run –overrides ‘{“config”: {“phases”: [{“duration”: 10, “arrivalRate”: 1}]}}’ test. yaml

    test.yaml

    config:
      target: https://your-website-link
      phases:
        - duration: 100
          arrivalRate: 100
    scenarios:
      - flow:
          - get:
              # add the url you need to send get request
              url: "/"
              capture:
              # capturing responce using reg expression
                - regexp: "[^]*"
                  as: "response"
          - log: "response= {{response}}"

    Here in the test script, the duration and the arrivalRate are set to 100. When we run the above commad in the command line, the duration and arrivalRate are overridden by 10 and 1 respectively.

    Test with passing Variables

    In case if we need to set some variable or need to override the given variables in artillery, we can achieve it by using
    artillery run -v ‘{“size”: [“small”, “medium”, “large”], “color”:[“black”, “blue”]}’ test.yaml
    Makes variables “size” and “color” available in scenarios, with values picked from the respective lists. If the variables are present in the yaml file, they will be overridden by the provided variables. This overriding of variables could be done to test new values to the data.

    Test with reports

    We now have an output of data in json format for the test run via artillery.So we must convert it into the html format in order to see it in the browser. Artillery also provides a retort generation in a GUI format. So, below is the command to convert above generated report to html
    artillery run -o report.json mytest.yaml
    artillery report report.json

    The command -o <report_name> will generate the report after completion of the test.This report will be generated in json file and could be generated to html file.

    The above were the different ways to run artillery scripts.

    Suggestion are appreciated in the comments 😀

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    2 comments

  • Madan J
    • Gautam Bagchi (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home

    Table of Content