artilleryio / artillery

The complete load testing platform. Everything you need for production-grade load tests. Serverless & distributed. Load test with Playwright. Load test HTTP APIs, GraphQL, WebSocket, and more. Use any Node.js module.
https://www.artillery.io
Mozilla Public License 2.0
8.03k stars 511 forks source link

multiple target in http and websocket #2026

Open exodia0x opened 1 year ago

exodia0x commented 1 year ago

Hello, I want to config yaml for multiple target Ex. I gonna GET Websocket url in Domain 1 and capture URL list as variable and next scenario connect websocket with target that Get form Domain 1.

Example Code.

config:
  target: "https://Domain1.com"

  phases:
    - duration: 1
      arrivalRate: 1

  engines:
   socketio:
    transports: ["websocket"]

scenarios:
  - name: " > Send Message and Check Respond"
    engine: socketio
    flow:
      - get:
          url: "/Resource/Weblist"
          capture: 
            json: $.1.Domainlist
            as: urllist

---------------- as this below i want to connect websocket url form "as: urllist". that is domin2,3,4,5,.....? ----------------
      - connect:
          extraHeaders:
            key: "{{ Randomnumber_script }}"

      - emit:
          channel: "command"
          data: "MyDATA"
        response:
          on: event
          match:
            - json: "$"
              value: "OK"

Did you guys have any for config and setup it ?

SpencerWightman commented 11 months ago

@exodia0x This looks like a good use case for processor: extract the bulk of scenario logic from YAML to a JS file, which can be used to construct complicated scenarios or 'chain' multiple scenarios together into one. Hopefully this is helpful.

Example YAML:

config:
  target: https://example.com
  phases:
    - duration: 600
      arrivalRate: 10
  processor: "./myfilename.js"

scenarios:
  - name: "HTTP Request and WebSocket Connection"
    flow:
      - function: "exportedJSFunction"

Example JS:

const io = require('socket.io-client');
const fetch = require('node-fetch');

module.exports = {exportedJSFunction: async function(context, events, done) {
     // WebSocket + HTTP logic for YAML scenario
     // Can have multiple HTTP requests etc.
  }
};