Skip to content

Commit d9e04de

Browse files
committed
Add PATCH load test
1 parent b95e787 commit d9e04de

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

k6/PATCHSingle.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import http from 'k6/http'
2+
import { Rate } from 'k6/metrics'
3+
4+
const URL = "http://" + __ENV.HOST;
5+
6+
const RATE = (function(){
7+
switch(__ENV.HOST){
8+
case 'c5xlarge': return 1650;
9+
case 't3axlarge': return 1500;
10+
case 't3anano': return 1500;
11+
default: return 1000;
12+
}
13+
})();
14+
15+
export let options = {
16+
discardResponseBodies: true,
17+
scenarios: {
18+
constant_request_rate: {
19+
executor: 'constant-arrival-rate',
20+
rate: RATE,
21+
timeUnit: '1s',
22+
duration: '30s',
23+
preAllocatedVUs: 100,
24+
maxVUs: 600,
25+
}
26+
},
27+
thresholds: {
28+
'failed requests': ['rate<0.1'],
29+
'http_req_duration': ['p(95)<1000']
30+
}
31+
};
32+
33+
const myFailRate = new Rate('failed requests')
34+
35+
export default function () {
36+
const body = { last_update: 'now' }
37+
const params = {
38+
headers: {
39+
'Content-Type': 'application/json',
40+
}
41+
}
42+
const res = http.patch(`${URL}/actor?actor_id=eq.${Math.floor(Math.random() * 203 + 1)}`, JSON.stringify(body), params)
43+
myFailRate.add(res.status !== 204)
44+
}

0 commit comments

Comments
 (0)