hrms-api-backend/checkin_load_test.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

import http from 'k6/http';
import { check, sleep } from 'k6';
export let options = {
scenarios: {
constant_rate: {
executor: 'constant-arrival-rate',
rate: 1000, // จำกัดที่ 1000 requests ต่อวินาที
timeUnit: '1s',
duration: '5m', // ใช้เวลารันทดสอบ 5 นาที
preAllocatedVUs: 50,
},
},
};
export default function () {
// ข้อมูล payload ที่จะส่งไปยัง server
let payload = JSON.stringify({
lat: 1,
lon: 1,
poi: 'FPT',
isLocation: true
});
// ตัวเลือก headers
let headers = {
'Content-Type': 'application/json',
};
// ส่ง POST request
let response = http.post('https://localhost:7283/api/v1/leave/fake-check-in', payload, { headers: headers });
// ตรวจสอบการตอบสนอง
check(response, {
'is status 200': (r) => r.status === 200,
});
// หน่วงเวลา 1 วินาที
sleep(1);
}