48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import http from 'k6/http'
|
|
import { check, sleep } from 'k6'
|
|
|
|
const BASE_URL = __ENV.SUPPORT_API_BASE_URL || 'http://localhost'
|
|
const TOKEN = __ENV.SUPPORT_API_TOKEN || ''
|
|
const DEFAULT_SLEEP = __ENV.SUPPORT_API_SLEEP || '1'
|
|
|
|
if (!TOKEN) {
|
|
throw new Error('SUPPORT_API_TOKEN is required')
|
|
}
|
|
|
|
export const options = {
|
|
vus: Number(__ENV.SUPPORT_API_VUS || 10),
|
|
duration: __ENV.SUPPORT_API_DURATION || '1m',
|
|
thresholds: {
|
|
http_req_failed: ['rate<0.01'],
|
|
http_req_duration: ['p(95)<500'],
|
|
},
|
|
}
|
|
|
|
function authHeaders() {
|
|
return {
|
|
headers: {
|
|
Authorization: `Bearer ${TOKEN}`,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
}
|
|
}
|
|
|
|
export default function () {
|
|
const listTenants = http.get(`${BASE_URL}/api/v1/support/tenants?per_page=25`, authHeaders())
|
|
check(listTenants, {
|
|
'list tenants 200': (res) => res.status === 200,
|
|
})
|
|
|
|
const listEvents = http.get(`${BASE_URL}/api/v1/support/events?per_page=25`, authHeaders())
|
|
check(listEvents, {
|
|
'list events 200': (res) => res.status === 200,
|
|
})
|
|
|
|
const listPhotos = http.get(`${BASE_URL}/api/v1/support/photos?per_page=25`, authHeaders())
|
|
check(listPhotos, {
|
|
'list photos 200': (res) => res.status === 200,
|
|
})
|
|
|
|
sleep(Number(DEFAULT_SLEEP))
|
|
}
|