From 2c714fc6a5e13aabb42f2e8f9ece85ac3a4d9f27 Mon Sep 17 00:00:00 2001 From: Bernardo Guerreiro <39738771+bernardobridge@users.noreply.github.com> Date: Tue, 19 Sep 2023 17:23:34 +0100 Subject: [PATCH] fix(validate-script): socketio runtime schema max value (#2151) --- examples/socket-io/app.js | 4 +++- examples/socket-io/socket-io.yml | 8 +++++--- packages/artillery/lib/util/validate-script.js | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/socket-io/app.js b/examples/socket-io/app.js index eace862bfb..917ff4f3b7 100644 --- a/examples/socket-io/app.js +++ b/examples/socket-io/app.js @@ -3,7 +3,9 @@ const io = require('socket.io')(8080, { serveClient: false }); -io.on('connection', (socket) => { +const personalisedNamespace = io.of('/personalised'); + +personalisedNamespace.on('connection', (socket) => { socket.on('echo', (msg) => { socket.emit('echoResponse', msg); }); diff --git a/examples/socket-io/socket-io.yml b/examples/socket-io/socket-io.yml index b45056e83e..81d014f5e2 100644 --- a/examples/socket-io/socket-io.yml +++ b/examples/socket-io/socket-io.yml @@ -1,5 +1,5 @@ config: - target: "http://localhost:8080/" + target: "http://localhost:8080" phases: - duration: 60 arrivalRate: 25 @@ -8,7 +8,8 @@ scenarios: - name: "Emit and validate response" engine: socketio flow: - - emit: + - namespace: /personalised + emit: channel: "echo" data: "Hello from Artillery" response: @@ -18,7 +19,8 @@ scenarios: - name: "Emit and validate acknowledgement" engine: socketio flow: - - emit: + - namespace: /personalised + emit: channel: "userDetails" acknowledge: match: diff --git a/packages/artillery/lib/util/validate-script.js b/packages/artillery/lib/util/validate-script.js index 7d666a7e81..cab4f0b62c 100644 --- a/packages/artillery/lib/util/validate-script.js +++ b/packages/artillery/lib/util/validate-script.js @@ -83,7 +83,7 @@ const flowItemSchema = Joi.object({ }), otherwise: Joi.when('...engine', { is: Joi.exist().valid('socketio'), - then: Joi.object().max(2), + then: Joi.object().max(3), otherwise: Joi.object().length(1) }) });