-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathload.js
More file actions
40 lines (32 loc) · 945 Bytes
/
load.js
File metadata and controls
40 lines (32 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import http from 'k6/http';
import { sleep } from 'k6';
import { Rate } from 'k6/metrics';
export const options = {
stages: [
{ duration: '10s', target: 500 },
{ duration: '10s', target: 1000 },
{ duration: '10s', target: 1500 },
{ duration: '10s', target: 2000 },
{ duration: '10s', target: 0 },
],
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<1000'],
cache_hit_rate: ['rate>=0.9'],
},
};
export const cacheHitRate = new Rate('cache_hit_rate');
export default function () {
const isLoggedIn = Math.random() < 0.05;
const headers = isLoggedIn
? { headers: { Cookie: 'session=abc123xyz' } }
: {};
const res = http.get('https://securebuild.com/images/postgres/inspect', headers);
const status = res.headers['cf-cache-status'];
if (status === 'HIT') {
cacheHitRate.add(true);
} else {
cacheHitRate.add(false);
}
sleep(Math.random() * 2);
}