-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris
authored and
Chris
committed
Sep 3, 2022
0 parents
commit 0afe696
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## K6 Load Testing | ||
|
||
Grafana k6 is an open-source load testing tool that makes performance testing easy and productive for engineering teams. k6 is free, developer-centric, and extensible. | ||
|
||
https://k6.io/docs/ | ||
|
||
### Pre-requisites | ||
|
||
Follow the guide https://k6.io/docs/getting-started/installation/ to install K6. | ||
|
||
|
||
### Resources | ||
|
||
https://github.com/grafana/k6-learn | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import http from 'k6/http'; | ||
import { check, sleep } from 'k6'; | ||
|
||
export let options = { | ||
vus: 1, | ||
thresholds: { | ||
http_req_duration: ['p(95)<=200', 'avg<=200'] | ||
} | ||
}; | ||
|
||
export function setup() { | ||
console.log('setup'); | ||
} | ||
|
||
export default function () { | ||
const params = { | ||
cookies: { my_cookie: 'HSJSHJKSHyhJK900093233DSJSJljkl' }, | ||
headers: { 'X-MyHeader': 'k6test' }, | ||
redirects: 5, | ||
tags: { k6test: 'yes' }, | ||
}; | ||
|
||
const res = http.get('https://httpbin.org/headers', params); | ||
|
||
console.log(res.json()['headers']); | ||
check(res, { | ||
'status is 200': (r) => r.status === 200, | ||
'X-Myheader is k6test': (r) => r.json()['headers']['X-Myheader'] == 'k6test' | ||
}) | ||
} | ||
|
||
export function teardown() { | ||
console.log('teardown'); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import http from 'k6/http'; | ||
import { sleep } from 'k6'; | ||
|
||
export const options = { | ||
vus: 10, | ||
duration: '10s', | ||
}; | ||
|
||
export default function () { | ||
http.get('https://test.k6.io'); | ||
sleep(1); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import http from 'k6/http'; | ||
import { check, sleep } from 'k6'; | ||
|
||
export let options = { | ||
vus: 10, | ||
iterations: 20, | ||
thresholds: { | ||
http_req_duration: ['p(95)<=500', 'avg<=500'] | ||
} | ||
}; | ||
|
||
export default function() { | ||
let url = 'https://httpbin.test.k6.io/post'; | ||
let response = http.post(url, 'Hello world!'); | ||
|
||
check(response, { | ||
'Application says hello world!': (r) => r.body.includes('Hello world!') | ||
}); | ||
sleep(1) | ||
} |