attendance-import.js 856 B

1234567891011121314151617
  1. import http from 'k6/http'
  2. import { check, sleep } from 'k6'
  3. export const options = { vus: 5, iterations: 10, 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: 'hr_admin', password: 'ChangeMe123!' }), { headers: { 'Content-Type': 'application/json' } })
  7. return res.json('data.accessToken')
  8. }
  9. export default function () {
  10. const csv = 'employeeNo,workDate,clockIn,clockOut\nE0001,2026-01-01,09:00,18:00\n'
  11. const res = http.post(`${baseUrl}/api/v1/attendance/import-jobs`, { file: http.file(csv, 'attendance.csv', 'text/csv') }, { headers: { Authorization: `Bearer ${token()}` } })
  12. check(res, { 'import accepted': (r) => r.status === 200 })
  13. sleep(1)
  14. }