Last active
October 11, 2021 08:57
-
-
Save sylvesterdas/7dbfaf2df2e09d8d5e3b2992c40ca222 to your computer and use it in GitHub Desktop.
Load test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import http from "k6/http"; | |
| import { check } from "k6"; | |
| const authUrl = "https://base.url/account/login"; | |
| const url = [ | |
| "https://base.url/notifications?archived=false&$limit=25&$skip=0", | |
| "https://base.url/connections", | |
| "https://base.url/connectors?state=current", | |
| "https://base.url/orchestration-runs?%24limit=20", | |
| "https://base.url/orchestrations", | |
| "https://base.url/transforms", | |
| "https://base.url/connections/616024ce33518dee473e01ed", | |
| ]; | |
| url.push(...url); | |
| url.push(...url); | |
| url.push(...url); | |
| const auth = JSON.stringify(JSON.parse(open('./auth.json'))); | |
| export const options = { | |
| vus: url.length, | |
| // iterations: 1, | |
| noConnectionReuse: true, | |
| noVuConnectionReuse: true, | |
| } | |
| export function setup() { | |
| const response = http.post(authUrl, auth, { | |
| headers: { 'Content-Type': "application/json" } | |
| }); | |
| return response.json('accessToken'); | |
| } | |
| export default function (token) { | |
| const response = http.get(url[__VU-1], { responseType: 'none', headers: { Authorization: `Bearer ${token}` } }); | |
| if (response.status !== 200) { | |
| console.log(response.status_text, url[__VU-1]); | |
| } | |
| check(response, { 'All Ok': (res) => res.status === 200 }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment