Skip to content

Instantly share code, notes, and snippets.

@lenybernard
Last active May 20, 2020 22:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lenybernard/d026ee788b14ed455cac18e05e3f8c74 to your computer and use it in GitHub Desktop.
Save lenybernard/d026ee788b14ed455cac18e05e3f8c74 to your computer and use it in GitHub Desktop.
config:
target: "https://example.com"
phases:
- duration: 300
arrivalRate: 25
name: "Warming up"
- duration: 300
rampTo: 50
name: "Little caress"
- duration: 300
rampTo: 75
name: "Do you feel this ?"
- duration: 300
rampTo: 150
name: "Can you undertake it ?"
- duration: 300
rampTo: 300
name: "This is serious"
- duration: 300
rampTo: 500
name: "What the hell"
- duration: 300
rampTo: 500
name: "I will burn you"
- duration: 300
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"
'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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment