Skip to content

Instantly share code, notes, and snippets.

@leduyminh48
Created May 29, 2021 19:42
Show Gist options
  • Save leduyminh48/7d65fc1582a53593f8b97663781cd6e5 to your computer and use it in GitHub Desktop.
Save leduyminh48/7d65fc1582a53593f8b97663781cd6e5 to your computer and use it in GitHub Desktop.
Sample Artillery load testing
config:
target: "http://localhost:3000"
phases:
- duration: 30
arrivalRate: 2
name: Warm up
processor: "./processors/users.js"
payload:
-
path: "./payloads/secret.csv"
fields:
- "STOKEN"
ensure:
maxErrorRate: 5
scenarios:
- name: "Search by assignee and status"
flow:
- get:
url: "/user"
qs:
filter: "{\"take\": 30}"
headers:
Authorization: "Bearer {{STOKEN}}"
capture:
json: "$.entities"
as: "users"
- get:
url: "/status"
headers:
Authorization: "Bearer {{STOKEN}}"
capture:
json: "$.entities"
as: "statuses"
- loop:
- function: "getStatusId"
- get:
url: "/task"
qs:
filter: "{\"relations\": [\"assignedTo\", \"status\", \"createdBy\"], \"where\": [{\"assignedTo\": {\"id\": \"{{$loopElement.id}}\"}, \"status\": {\"id\": \"{{statusId}}\"}}]}"
headers:
Authorization: "Bearer {{STOKEN}}"
capture:
json: "$.count"
as: "count"
- log: "countTasks: {{count}}"
over: users
- name: "Adding comments"
flow:
- get:
url: "/task"
qs:
filter: "{\"take\": 30}"
headers:
Authorization: "Bearer {{STOKEN}}"
capture:
json: "$.entities"
as: "tasks"
- loop:
- log: "taskId: {{$loopElement.id}}"
- post:
url: "/comment"
json:
comment: "comment for {{$loopElement.id}}"
taskId: "{{$loopElement.id}}"
headers:
Authorization: "Bearer {{STOKEN}}"
capture:
json: "$.id"
as: "commentId"
- log: "countTasks: {{count}}"
over: tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment