-
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
1 parent
326fb5c
commit e9e5330
Showing
6 changed files
with
107 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,21 @@ | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,14 @@ | ||
{ | ||
"name": "k6-techshow", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/k6": "^0.28.1" | ||
} | ||
} |
Empty file.
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,22 @@ | ||
import http from 'k6/http'; | ||
import { sleep } from 'k6'; | ||
|
||
const homeService = (check, checkFailureRate) => { | ||
// our HTTP request, note that we are saving the response to res, | ||
// which can be accessed later | ||
|
||
const res = http.get('http://test.k6.io'); | ||
|
||
sleep(1); | ||
|
||
const checkRes = check(res, { | ||
'status is 200': (r) => r.status === 200, | ||
'response body': (r) => | ||
JSON.stringify(r.body).indexOf( | ||
'Collection of simple web-pages suitable for load testing.' | ||
) !== -1, | ||
}); | ||
checkFailureRate.add(checkRes); | ||
}; | ||
|
||
exports.homeService = homeService; |
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,36 @@ | ||
import { check } from 'k6'; | ||
import { Counter, Rate } from 'k6/metrics'; | ||
import { homeService } from '../services/home.js'; | ||
import papaparse from 'https://jslib.k6.io/papaparse/5.1.1/index.js'; | ||
|
||
const data = papaparse.parse(open('../data/sample.csv'), { header: true }).data; | ||
// A simple counter for http requests | ||
|
||
export const requests = new Counter('http_reqs'); | ||
// Custom metric with rate value | ||
let checkFailureRate = new Rate('check_failure_rate'); | ||
// you can specify stages of your test (ramp up/down patterns) through the options object | ||
// target is the number of VUs you are aiming for | ||
|
||
export const options = { | ||
stages: [ | ||
{ target: 20, duration: '3s' }, | ||
{ target: 15, duration: '3s' }, | ||
{ target: 0, duration: '3s' }, | ||
], | ||
thresholds: { | ||
requests: ['count < 100'], | ||
http_req_connecting: ['p(95)<450'], | ||
'http_req_duration{staticAsset:yes}': ['p(95)<100'], | ||
RTT: ['p(99)<300', 'p(70)<250', 'avg<200', 'med<150', 'min<100'], | ||
'Content OK': ['rate>0.95'], | ||
ContentSize: ['value<4000'], | ||
Errors: ['count<100'], | ||
}, | ||
}; | ||
|
||
export default function () { | ||
console.log(__VU, JSON.stringify(data[__VU - 1])); | ||
// our HTTP request, note that we are saving the response to res, which can be accessed later | ||
homeService(check, checkFailureRate); | ||
} |