【问题标题】:How to send two parameter from yaml to socket.io using artillery.io如何使用 artillery.io 将两个参数从 yaml 发送到 socket.io
【发布时间】:2018-02-08 01:19:23
【问题描述】:

相关:Testing Socket.io - Artillery.io Docs

我不知道如何发送两个参数,在我的例子中,“数据”和“按摩”从 yaml 发射到“发送房间消息”

Socket.io

socket.on('send-room-message', function (data, message) {
    socket.broadcast.to(data.room).emit('get-room-message', data, message);
});

socketio-chat-load-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-->>

有什么想法吗?

【问题讨论】:

    标签: node.js socket.io load-testing


    【解决方案1】:

    目前火炮不支持此功能。我找到了一种方法来做到这一点。 你要做的是:

    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. 在克隆artillery 的目录中运行命令npm link,以便在命令行中使用带有更新的artillery-core 的版本。

    现在,当您使用大炮时,您可以在 socketio-chat-load-test.yaml 中指定多个参数:

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

    【讨论】:

    • 谢谢!仅供参考,新版本对此进行了更改,并且不使用火炮核心。您可以克隆炮兵回购并将这些更改直接放入engine_socketio.js。注意有两个地方(一个有回调,一个没有)
    猜你喜欢
    • 1970-01-01
    • 2018-05-27
    • 2016-01-08
    • 2023-03-27
    • 2015-07-09
    • 1970-01-01
    • 2019-02-05
    • 2018-08-10
    • 2023-03-14
    相关资源
    最近更新 更多