♻️Made performance test runnable
This commit is contained in:
committed by
Anton Shepilov
parent
6002974306
commit
47106a8459
@@ -0,0 +1,18 @@
|
||||
# Performance Tests
|
||||
|
||||
## Developer guide
|
||||
|
||||
### Getting started
|
||||
|
||||
1. Install k6 if you want to run it locally or user docker image
|
||||
|
||||
```
|
||||
https://grafana.com/docs/k6/latest/set-up/install-k6/
|
||||
```
|
||||
|
||||
2. Run all tests
|
||||
|
||||
```sh
|
||||
k6 run --vus 10 -e BACKEND=https://tdrive.qa.lin-saas.com -e COMPANY_ID=00000000-0000-4000-0000-000000000000 -e JWT= files/upload-files.js
|
||||
```
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import http from 'k6/http';
|
||||
import { sleep } from 'k6';
|
||||
|
||||
export const options = {
|
||||
iterations: 10,
|
||||
};
|
||||
|
||||
// The default exported function is gonna be picked up by k6 as the entry point for the test script. It will be executed repeatedly in "iterations" for the whole duration of the test.
|
||||
export default function () {
|
||||
// Make a GET request to the target URL
|
||||
http.get('https://test-api.k6.io');
|
||||
|
||||
// Sleep for 1 second to simulate real-world usage
|
||||
sleep(1);
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export let options = {
|
||||
{ duration: "10s", target: 0 },
|
||||
],
|
||||
thresholds: {
|
||||
upload_duration: ["p(95)<17000"], // 95% of uploads should be faster than 500ms
|
||||
upload_duration: ["p(95)<500"], // 95% of uploads should be faster than 500ms
|
||||
},
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ function uploadFile(filePath, fileType, JWT, companyID) {
|
||||
const formData = new FormData();
|
||||
const randomInt = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
|
||||
const fileName = `${randomInt.toString(36)}.${fileType.split("/")[1]}`; // Extract extension from MIME type
|
||||
formData.append("file", http.file(open(filePath), fileName, fileType));
|
||||
formData.append("file", http.file(filePath, fileName, fileType));
|
||||
|
||||
const headers = {
|
||||
Authorization: `Bearer ${JWT}`,
|
||||
@@ -56,5 +56,7 @@ export default function () {
|
||||
"company_id is present": body => body.resource.company_id !== undefined,
|
||||
});
|
||||
|
||||
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user