如何使用 Artillery 测试 NodeJS UDP 服务器?

问题描述 投票:0回答:1

我在 NodeJS 中有一个基本的 dgram UDP 服务器,我想使用 Artillery 对此服务器进行负载测试。但是,我找不到实现此目标的方法。

Artillery 拥有 HTTP、WebSocket、SocketIO 和 PlayWright 等引擎。据我所知,SocketIO和WebSocket TCP协议。那么,如何使用这些引擎进行 UDP 测试?

在我的案例中,这些引擎之一或 NodeJS 中 UDP 协议的另一种实现受到欢迎。 有没有办法实现这一点?

我的UDP服务器:

const UDP = require('dgram')
const server = UDP.createSocket('udp4')
const port = 2222

server.on('listening', () => {
  // Server address it’s using to listen

  const address = server.address()

  console.log('Listining to ', 'Address: ', address.address, 'Port: ', address.port)
})

server.on('message', (message, info) => {
  console.log('Message', message.toString())

  const response = Buffer.from('Message Received')

  //sending back response to client

  server.send(response, info.port, info.address, (err) => {
    if (err) {
      console.error('Failed to send response !!')
    } else {
      console.log('Response send Successfully')
    }
  })
})

server.bind(port)

我的火炮配置文件:

config:
  target: http://localhost:2222
  phases:
    - duration: 30
      arrivalRate: 10 
      name: Warm up the API
    - duration: 30
      arrivalRate: 10
      rampTo: 15
      name: Ramp up to peak load

scenarios:
  - name: WebSocket Test
    engine: "socketio" # Enable the Socket.io engine
    flow:
      - emit:
          channel: "message"
          data: "Hello World"
node.js socket.io udp artillery
1个回答
0
投票

这个问题已在 Artillery 的 Github 讨论中得到解答:https://github.com/artilleryio/artillery/discussions/2189

© www.soinside.com 2019 - 2024. All rights reserved.