From 7e7b42ce19eb64502b1af2a1c9443bef000b0016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 16 Sep 2020 09:31:44 +0200 Subject: [PATCH] Changing load test to run in circles --- back/src/Controller/IoSocketController.ts | 16 ++++++++++++---- benchmark/socketio-load-test.yaml | 5 +++++ benchmark/socketioLoadTest.js | 9 +++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 878c6c75..c1c00761 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -223,6 +223,14 @@ export class IoSocketController { return new MessageUserPosition(user.id, player.name, player.characterLayers, player.position); }, users); + //console.warn('ANSWER PLAYER POSITIONS', listOfUsers); + if (answerFn === undefined && ALLOW_ARTILLERY === true) { + /*console.error("TYPEOF answerFn", typeof(answerFn)); + console.error("answerFn", answerFn); + process.exit(1)*/ + // For some reason, answerFn can be undefined if we use Artillery (?) + return; + } answerFn(listOfUsers); } catch (e) { console.error('An error occurred on "join_room" event'); @@ -244,7 +252,7 @@ export class IoSocketController { const world = this.Worlds.get(Client.roomId); if (!world) { - console.error("Could not find world with id '", Client.roomId, "'"); + console.error("In SET_VIEWPORT, could not find world with id '", Client.roomId, "'"); return; } world.setViewport(Client, Client.viewport); @@ -255,7 +263,7 @@ export class IoSocketController { }); socket.on(SockerIoEvent.USER_POSITION, (userMovesMessage: unknown): void => { - console.log(SockerIoEvent.USER_POSITION, userMovesMessage); + //console.log(SockerIoEvent.USER_POSITION, userMovesMessage); try { if (!isUserMovesInterface(userMovesMessage)) { socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid USER_POSITION message.'}); @@ -272,7 +280,7 @@ export class IoSocketController { // update position in the world const world = this.Worlds.get(Client.roomId); if (!world) { - console.error("Could not find world with id '", Client.roomId, "'"); + console.error("In USER_POSITION, could not find world with id '", Client.roomId, "'"); return; } world.updatePosition(Client, Client.position); @@ -351,7 +359,7 @@ export class IoSocketController { // update position in the world const world = this.Worlds.get(Client.roomId); if (!world) { - console.error("Could not find world with id '", Client.roomId, "'"); + console.error("In SET_SILENT, could not find world with id '", Client.roomId, "'"); return; } world.setSilent(Client, silent); diff --git a/benchmark/socketio-load-test.yaml b/benchmark/socketio-load-test.yaml index e84b0402..df2f580b 100644 --- a/benchmark/socketio-load-test.yaml +++ b/benchmark/socketio-load-test.yaml @@ -28,6 +28,11 @@ scenarios: y: 170 direction: 'down' moving: false + viewport: + left: 500 + top: 0 + right: 800 + bottom: 200 - think: 1 - loop: - function: "setYRandom" diff --git a/benchmark/socketioLoadTest.js b/benchmark/socketioLoadTest.js index 540cd8bd..f898d7b9 100644 --- a/benchmark/socketioLoadTest.js +++ b/benchmark/socketioLoadTest.js @@ -5,8 +5,13 @@ module.exports = { }; function setYRandom(context, events, done) { - context.vars.x = (0 + Math.round(Math.random() * 1472)); - context.vars.y = (0 + Math.round(Math.random() * 1090)); + if (context.angle === undefined) { + context.angle = Math.random() * Math.PI * 2; + } + context.angle += 0.05; + + context.vars.x = 320 + 1472/2 * (1 + Math.sin(context.angle)); + context.vars.y = 200 + 1090/2 * (1 + Math.cos(context.angle)); context.vars.left = context.vars.x - 320; context.vars.top = context.vars.y - 200; context.vars.right = context.vars.x + 320;