import ws from ‘k6/ws’;
import { check } from ‘k6’;
export let options = {
insecureSkipTLSVerify: true,
noConnectionReuse: false,
stages: [
{ duration: ‘1s’, target: 100 }, //simulate ramp-up of traffic from 1 to 100 users over 2 minutes
{ duration: ‘1h’, target: 100 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1s’, target: 150 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 150 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1s’, target: 200 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 200 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1s’, target: 250 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 250 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1s’, target: 300 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 300 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 350 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 400 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 450 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 500 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 550 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 600 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 650 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 700 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 750 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 800 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘1h’, target: 900 }, //stay at 100 users for 3 hours 56 minutes
{ duration: ‘2m’, target: 0 }, //ramp down to 0 users (optional)
],
};
export default function () {
const url = ‘ws://192.168.123.31:8080/dashboard/C0001’;
const params = { tags: { my_tag: ‘registeredcount’ } };
const res = ws.connect(url, params, function (socket) {
socket.on(‘open’, () => console.log(‘connected’));
socket.on(‘message’, (data) => console.log('Message received: ', data));
socket.on(‘close’, () => console.log(‘disconnected’));
});
check(res, { ‘status is 101’: (r) => r && r.status === 101 });
}
(I want to make this dynamic such as using for loop or something so it increases users by 50 automatically after 1hr and ramps up until the websocket crashes and showcases the amount of vu’s required that crashed it and also automatically interrupt the load test and abort it and showcase the results)