-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaula23.js
36 lines (31 loc) · 852 Bytes
/
aula23.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
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 100,
duration: '10s',
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<1000'],
},
};
const BASE_URL = 'https://test-api.k6.io';
export function setup() {
const loginRes = http.post(`${BASE_URL}/auth/token/login/`, {
username: '[email protected]',
password: 'User@123',
});
const token = loginRes.json('access');
return token;
}
export default function (token) {
const params = {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
};
const res = http.get(`${BASE_URL}/my/crocodiles`, params);
check(res, {
'status é 200': (r) => r.status === 200,
});
}