gatling/gatling

HTTP: Avoid race condition in testing SSE

Aperta

#3809 aperta il 18 ott 2019

 (1 commento) (2 reazioni) (0 assegnatari)Scala (1209 fork)batch import
Module - HTTPhelp wanted

Metriche repository

Star
 (6902 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

I am trying to use gatling to test an SSE endpoint that represents an update stream. To properly test this, I want to open the SSE stream, issue a normal HTTP request that triggers an update, then check that the SSE client has received the update event. My code looks something like this:

[...]
                .exec(openSseStream)
                .exec(triggerUpdate)
                .exec(checkUpdateInSseStream)
[...]

My problem is that if the update message is sent to the SSE client very quickly, it might already be consumed and ignored by the time the check is activated.

I can think of three possible ways to solve this:

  1. make the check non-blocking, so I can activate the check before I trigger the update
  2. add an API to specify an ActionBuilder with the setCheck so that the action will be executed after the check is set up but before it blocks further execution
  3. add an option to buffer incoming SSE messages while no check is active and "replay" them as soon as a check is set up

If necessary, I can build a sample application that demonstrates the problem, but I hope it's already clear from the explanation.

Guida contributor