report-export.js 762 B

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