r/learnjavascript • • 5d ago

How do you customize artillery load tests and create a more realistic simulation?

Artillery gives me detailed reports that I absolutely love. I can write a YAML script or use JavaScript. However, I'd like to do more with the scenarios instead of just "think for x seconds".

I want to test my socket.io server, and while I can write an emit, I'd like to use my seed data so that each virtual user sends a unique emit and has logic to process callbacks from the socket and listen to events.

For example, given the scenario (in JS) below:

{
  name: "scenario 1",
  engine: "socketio-v3",
  flow: [
    {
      think: 1,
      emit: [
        {
          channel: "channel",
          data: [
            {
              one: "one",
              two: two
            }
          ]
        }
      ],
      acknowledge: {
        match: {
          three: {
            four: 'string',
            five: 'string',
            six: {
              seven: 'number',
              eight: 'number'
            },
            nein: 'number'
          },
          dix: 'object'
        }
      },
      think: thinkingTime
    }
  ]
}

I would prefer to manipulate the data sent, and while I still want to validate the acknowledgement, I'd still like to use the data received.

I want to do this, so I don't use think.
For further context, I am new to this and don't actually know what the "correct" procedure for testing actually is. I'm going on the assumption that the closer to reality a simulation is, the better, and so I want to use seed data to simulate what users will actually be able to do.

I never actually checked if think is enough and going for more realistic simulations is putting in effort for little reward.

Thank you kindly!

3 Upvotes

Duplicates