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

830 Dummy endpoint #832

Merged
merged 9 commits into from
Feb 13, 2024
13 changes: 13 additions & 0 deletions backend/src/controller/testController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Response } from 'express';

import { handleAddInfoToChatHistory } from '@src/controller/chatController';
import { OpenAiAddInfoToChatHistoryRequest } from '@src/models/api/OpenAiAddInfoToChatHistoryRequest';

function handleTest(req: OpenAiAddInfoToChatHistoryRequest, res: Response) {
let num = 0;
for (let x = 0; x <= 1000000; x++) {
num = num++;
}
handleAddInfoToChatHistory(req, res);
}
export { handleTest };
4 changes: 4 additions & 0 deletions backend/src/sessionRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
handleSetModel,
} from './controller/modelController';
import { handleResetProgress } from './controller/resetController';
import { handleTest } from './controller/testController';
import { ChatModel, defaultChatModel } from './models/chat';
import { LevelState, getInitialLevelStates } from './models/level';

Expand Down Expand Up @@ -130,4 +131,7 @@ if (isProd) {
});
}

// Testing dummy endpoint
router.post('/test/load', handleTest);

export default router;
8 changes: 5 additions & 3 deletions k6/smoke.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import http from 'k6/http';
// import exec from 'k6/execution';
import { check, sleep } from 'k6';

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

export default () => {
const data = { message: "hi", currentLevel: '3' };
const url = 'http://localhost:3001/openai/chat';
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' },
});
check(response, {
'response code was 200': (response) => response.status === 200,
});
sleep(1);
sleep(0.1);
};
Loading