Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

822 Load Testing #833

Merged
merged 15 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/controller/testController.ts
kclark-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ function handleTest(req: OpenAiAddInfoToChatHistoryRequest, res: Response) {
for (let x = 0; x <= 1000000; x++) {
num = num++;
}
handleAddInfoToChatHistory(req, res);
handleAddInfoToChatHistory(req, res);
}
export { handleTest };
2 changes: 1 addition & 1 deletion k6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Grafana k6 is an open-source load testing tool that makes performance testing ea
## Running locally

1. Make sure local backend is running, [refer to the backend README](../backend/README.md)
1. in a separate terminal cd into the K6 folder and run `k6 run script.js` (Where 'script' is the name of the script you want to run)
1. in a separate terminal cd into the K6 folder and run `K6_WEB_DASHBOARD=true K6_WEB_DASHBOARD_EXPORT=k6-html-report.html K6_WEB_DASHBOARD_OPEN=true k6 run script.js` (Where 'script' is the name of the script you want to run)
44 changes: 44 additions & 0 deletions k6/k6-html-report.html

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions k6/load.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import http from 'k6/http';
import exec from 'k6/execution';
import {check, sleep} from 'k6';

export const options = {
// Key configurations for avg load test in this section
// stages: [
// { duration: '5m', target: 100 }, // traffic ramp-up from 1 to 100 users over 5 minutes.
// { duration: '5m', target: 100 }, // stay at 100 users for 30 minutes
// { duration: '5m', target: 0 }, // ramp-down to 0 users
// ],

vus: 2, // Key for Smoke test. Keep it at 2, 3, max 5 VUs
// duration: '10s', // This can be shorter or just a few iterations
iterations: 4
};

export default () => {
const data = { infoMessage: "Hi", chatMessageType: 'LEVEL_INFO' , level: 3};
const url = 'http://localhost:3001/test/load';

let response = http.post(url, JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
}
);
check(response, {
'response code was 200': (response) => response.status === 200,
});
console.log('VU ID:' + exec.vu.idInTest);
console.log('Cookie:' + response.cookies['prompt-injection.sid'][0].value);

sleep(1);
};
4 changes: 1 addition & 3 deletions k6/smoke.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import http from 'k6/http';
// import exec from 'k6/execution';
import { check, sleep } from 'k6';

export const options = {
Expand All @@ -8,10 +7,9 @@ export const options = {
};

export default () => {
const data = { message: "hi", currentLevel: '3' };
const data = { infoMessage: "Hi", chatMessageType: 'LEVEL_INFO' , level: 3};
const url = 'http://localhost:3001/test/load';

// console.log('VU ID:' + exec.vu.idInTest);
let response = http.post(url, JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
});
Expand Down
Loading