如何使用artillery.io从yaml发送两个参数到socket.io
https://artillery.io/docs/socketio-reference/
我对yaml和artillery.io很陌生
我不知道如何发送两个参数,在我的情况下,从yaml“数据”和“按摩”发送到“发送房间消息”
Socket.io
socket.on('send-room-message', function (data, message) { socket.broadcast.to(data.room).emit('get-room-message', data, message); });
socketio-聊天负荷test.yaml
config: target: "http://localhost:3030" phases: - duration: 5 arrivalRate: 100 variables: greeting: ["hello", "goedemorgen", "добрый день", "guten tag", "bonjour", "hola"] variables: room: - 2 scenarios: - name: "A user that just talks" weight: 75 engine: "socketio" flow: - get: url: "/" - emit: channel: "add-user" data: {"id": "112312", "Name":'Hello'} - emit: channel: "join-room" data: "2" - emit : channel: "push-room-button" data: "2" response: channel: "room-busy" data: "2" - emit: channel: "send-room-message" data: <<--TODO-->>
请build议
目前这不是炮兵支援。 我find了一个办法,但是。 你必须做的是:
- 叉火炮核心
- 打开文件
engine_socketio.js
-
用以下代码replace所有
socketio.emit(...)
消息:const splitData = ougoing.data.split('|'); socketio.emit(outgoing.channel, ...splitData);
-
提交并将更改推送到您的分支
-
克隆大炮
-
打开package.json,将依赖的
artillery-core
改为:"artillery-core": "git://github.com/YOUR-GITHUB-USERNAME/artillery-core.git#YOUR-BRANCH",
-
在克隆炮兵的目录中运行命令
npm link
,以便在命令行中使用带有更新的炮兵核心的版本。
现在,当你使用炮兵时,你可以在你的socketio-chat-load-test.yaml中指定多个参数:
- emit: channel: "Insert your channel here" data: "Insert first parameter here|Insert second parameter|Third parameter"