Skip to content

Instantly share code, notes, and snippets.

@lenybernard
Last active May 20, 2020 22:08
Show Gist options
  • Select an option

  • Save lenybernard/d026ee788b14ed455cac18e05e3f8c74 to your computer and use it in GitHub Desktop.

Select an option

Save lenybernard/d026ee788b14ed455cac18e05e3f8c74 to your computer and use it in GitHub Desktop.

Revisions

  1. lenybernard revised this gist Nov 27, 2019. 1 changed file with 0 additions and 7 deletions.
    7 changes: 0 additions & 7 deletions artillery-test.yml
    Original file line number Diff line number Diff line change
    @@ -5,31 +5,24 @@ config:
    arrivalRate: 25
    name: "Warming up"
    - duration: 300
    arrivalRate: 5
    rampTo: 50
    name: "Little caress"
    - duration: 300
    arrivalRate: 5
    rampTo: 75
    name: "Do you feel this ?"
    - duration: 300
    arrivalRate: 5
    rampTo: 150
    name: "Can you undertake it ?"
    - duration: 300
    arrivalRate: 5
    rampTo: 300
    name: "This is serious"
    - duration: 300
    arrivalRate: 5
    rampTo: 500
    name: "What the hell"
    - duration: 300
    arrivalRate: 5
    rampTo: 500
    name: "I will burn you"
    - duration: 300
    arrivalRate: 5
    rampTo: 1000
    name: "Hello ?"
    processor: "./functions.js"
  2. lenybernard created this gist Nov 26, 2019.
    100 changes: 100 additions & 0 deletions artillery-test.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,100 @@
    config:
    target: "https://example.com"
    phases:
    - duration: 300
    arrivalRate: 25
    name: "Warming up"
    - duration: 300
    arrivalRate: 5
    rampTo: 50
    name: "Little caress"
    - duration: 300
    arrivalRate: 5
    rampTo: 75
    name: "Do you feel this ?"
    - duration: 300
    arrivalRate: 5
    rampTo: 150
    name: "Can you undertake it ?"
    - duration: 300
    arrivalRate: 5
    rampTo: 300
    name: "This is serious"
    - duration: 300
    arrivalRate: 5
    rampTo: 500
    name: "What the hell"
    - duration: 300
    arrivalRate: 5
    rampTo: 500
    name: "I will burn you"
    - duration: 300
    arrivalRate: 5
    rampTo: 1000
    name: "Hello ?"
    processor: "./functions.js"
    variables:
    formSlug:
    - "form-test-1"
    - "form-test-2"
    - "form-test-3"
    - "form-test-4"
    - "form-test-5"
    - "form-test-6"
    - "form-test-7"
    - "form-test-8"
    - "form-test-9"
    - "form-test-10"
    scenarios:
    - name: "Come and submit only a single form"
    flow:
    - function: "generateRandomData"
    - log : "Going on forms landing page"
    - get:
    url: "/forms"
    - log : "Going on specific form page"
    - get:
    url: "/forms/{{ formSlug }}"
    - think: 3
    - log : "Submit the form"
    - post:
    url: "/api/forms/{{ formSlug }}"
    headers:
    Accept: "*/*"
    Content-Type: "application/json"
    json:
    email: "{{ email }}"
    message: "{{ message }}"
    - get:
    url: "/forms/{{ formSlug }}/thanks"
    - name: "Come and submit all the forms in a row"
    flow:
    - function: "generateRandomData"
    - get:
    url: "/forms"
    - loop:
    - get:
    url: "/forms/{{ $loopElement }}"
    - think: 3
    - post:
    url: "/api/forms/{{ $loopElement }}"
    headers:
    Accept: "*/*"
    Content-Type: "application/json"
    json:
    email: "{{ email }}"
    message: "{{ message }}"
    - think: 1
    - get:
    url: "/forms/{{ $loopElement }}/thanks"
    over:
    - "awesome-form-test-1"
    - "awesome-form-test-2"
    - "awesome-form-test-3"
    - "awesome-form-test-4"
    - "awesome-form-test-5"
    - "awesome-form-test-6"
    - "awesome-form-test-7"
    - "awesome-form-test-8"
    - "awesome-form-test-9"
    - "awesome-form-test-10"
    16 changes: 16 additions & 0 deletions functions.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    'use strict';

    module.exports = {
    generateRandomData
    };

    // Make sure to "npm install faker" first.
    const Faker = require('faker');

    function generateRandomData(userContext, events, done) {
    // add variables to virtual user's context:
    userContext.vars.email = "artillery_fake_" + Faker.internet.exampleEmail();
    userContext.vars.message = Faker.lorem.sentences(3);

    return done();
    }