-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload-test.js
68 lines (63 loc) · 2.21 KB
/
load-test.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import http from 'k6/http';
import { sleep } from 'k6';
import { Trend, Counter } from 'k6/metrics';
const duration = 30;
export const options = {
discardResponseBodies: true,
scenarios: {
long_sync: {
executor: 'constant-vus',
exec: 'long_request_sync',
vus: 2,
duration: duration + 's',
tags: { type: 'long_sync' },
},
short_while_sync: {
executor: 'constant-vus',
exec: 'short_while_sync_request',
vus: 1,
duration: duration + 's',
tags: { type: 'short_while_sync' },
},
long_async: {
executor: 'constant-vus',
exec: 'long_request_async',
vus: 2,
startTime: duration + 5 + 's',
duration: duration + 's',
tags: { type: 'long_async' },
},
short_while_async: {
executor: 'constant-vus',
exec: 'short_while_async_request',
vus: 1,
startTime: duration + 5 + 's',
duration: duration + 's',
tags: { type: 'short_while_async' },
},
},
};
const trend_short_while_async = new Trend('duration_short_while_async');
const trend_short_while_sync = new Trend('duration_short_while_sync');
const trend_long_async = new Trend('duration_long_async');
const trend_long_sync = new Trend('duration_long_sync');
const counter_short_while_async = new Counter('counter_short_while_async');
const counter_short_while_sync = new Counter('counter_short_while_sync');
export function short_while_sync_request() {
const r = http.get('http://localhost:5260/short');
trend_short_while_sync.add(r.timings.duration);
counter_short_while_sync.add(1);
}
export function short_while_async_request() {
const r = http.get('http://localhost:5260/short');
trend_short_while_async.add(r.timings.duration);
counter_short_while_async.add(1);
}
export function long_request_sync() {
const r = http.get('http://localhost:5260/long-sync');
trend_long_sync.add(r.timings.duration);
}
export function long_request_async() {
const r = http.get('http://localhost:5260/long-async');
trend_long_async.add(r.timings.duration);
}