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