| 12345678910111213141516 |
- import http from 'k6/http'
- import { check, sleep } from 'k6'
- export const options = { vus: 10, duration: '30s', thresholds: { http_req_failed: ['rate<0.01'], http_req_duration: ['p(95)<2000'] } }
- const baseUrl = __ENV.BASE_URL || 'http://localhost:8080'
- function token() {
- const res = http.post(`${baseUrl}/api/v1/auth/login`, JSON.stringify({ username: 'sys_admin', password: 'ChangeMe123!' }), { headers: { 'Content-Type': 'application/json' } })
- return res.json('data.accessToken')
- }
- export default function () {
- const res = http.post(`${baseUrl}/api/v1/reports/headcount/export`, '{}', { headers: { Authorization: `Bearer ${token()}`, 'Content-Type': 'application/json' } })
- check(res, { 'export accepted': (r) => r.status === 200 })
- sleep(1)
- }
|