如何从YAML发送两个参数使用artillery.io到socket.io

问题描述:

https://artillery.io/docs/socketio-reference/如何从YAML发送两个参数使用artillery.io到socket.io

我是新来的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-->> 

请建议

这目前不支持火炮。尽管如此,我找到了一种方法。 你所要做的是:

  1. artillery-core
  2. 打开文件engine_socketio.js
  3. 用下面的代码替换所有socketio.emit(...)消息:

    const splitData = ougoing.data.split('|'); 
    socketio.emit(outgoing.channel, ...splitData); 
    
  4. 提交和推送更改您的分支

  5. 克隆artillery

  6. 开放的package.json,改变依赖artillery-core到: "artillery-core": "git://github.com/YOUR-GITHUB-USERNAME/artillery-core.git#YOUR-BRANCH",

  7. 运行在你克隆炮兵所以它使用的版本更新火炮核心目录的命令npm link命令行。

现在,当您使用大炮,你可以在你的socketio-聊天负荷test.yaml指定多个参数,例如:

- emit: 
     channel: "Insert your channel here" 
     data: "Insert first parameter here|Insert second parameter|Third parameter"