artillery
artillery copied to clipboard
multiple target in http and websocket
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 ?
@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.
}
};