Search code examples
scalagrpcgatling

Gatling reports cannot be generated with GRPC plugin


Hope you doing good today, I have completed to define a stream for Gatling, which is as below:

val grpcConf = grpc(managedChannelBuilder("url:80").usePlaintext())
  
  val Authorization: Metadata.Key[String] = Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER)

  val thePayload = StartPairingRequest(Option(Device("plain")))
  val fromClientSide = grpc("Speak")
    .serverStream[StartPairingRequest, StartPairingResponse](RelayServerGrpc.METHOD_START_PAIRING, "gettingThePairingKey")

  val speaker = scenario("BasicSimu")
  .exec(
    fromClientSide
      .start(thePayload)
      .header(Authorization)(s"Bearer $TokenKey")   
  )
  .pause(5)

  setUp(
    speaker.inject(atOnceUsers(1))
  ).protocols(grpcConf)
}

However, when I tried to run, I got this error

java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won't be generated

I have looked into the previous error reports, here and here, but can't find the solution for this, the "." operation was not lacking (I think so), what could possibly the cause right here ?

Additional Information: I have tried to change the key to a false value, which makes Gatling to return a report with the same script content above.

Additional Information #2: There maybe an issue that I forgot to put in the extract for gatling to send request, so I put it in also, still, same issue persists.

Additional Information #3: I checked for the response, there are content that is exact same with what I give request, but still no reports.


Solution

  • You have added .pause(5) to your scenario. But if your stream lasts longer than that 5 seconds, the log will not include the stream end event.

    Since you have nothing else in your simulation, you get the "There were no requests sent during the simulation, reports won't be generated" exception.

    You can use the following (instead of pause) to make the virtual user wait for the stream to end.

    .exec(
      fromClientSide // weird name but OK
        .reconciliate(waitFor = StreamEnd)
    )