I have done simple GRPC plugin and gatling successfully , no issue happening here, when I put this into my project, there are some problems due to my lack of knowledge here:
As @georgeLeung that have a proto message as:
message GreetRequest {
string username = 1;
string name = 2;
}
I saw that he had created a payload as this:
val greetPayload: Expression[GreetRequest] = GreetRequest(name = "World").updateExpr(
_.username :~ $("username")
)
So I have tried to follow his example, by this message and Authorization that I have:
message required to be sent:
{
"device": {
"id": "random"
}
}
Messages defined in proto file:
message StartPairingRequest {
Device device = 1 [(google.api.field_behavior) = REQUIRED]; // Device object containing information
}
Authorization:
BearerToken: “the key”
I have tried to implement the body only as this:
val greetPayload: Expression[StartPairingRequest] = StartPairingRequest(root.scala.None).updateExpr(
_.device :~ $("device")
)
Then it just returned that Java.lang.assertion: Assertion Failed,
But the main question I have that how do I correctly implement the payload with messages and authorization so that I can make the call right ?
I am confused for the message in proto and message required in payload.
Below is my sample code:
import scala.concurrent.duration._
import com.github.phisgr.gatling.grpc.Predef._
import com.github.phisgr.gatling.pb._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.grpc.Status
import io.gatling.core.session.{Expression, Session}
import spray.json._
import DefaultJsonProtocol._
import sttp.client4.quick._
class BasicSimu extends Simulation {
val grpcConf = grpc(managedChannelBuilder(name = "localhost", port = 8080).usePlaintext())
val messageBody = s"""{"device": {"id": "random"}}"""
val greetPayload: Expression[StartPairingRequest] = StartPairingRequest(root.scala.None).updateExpr(
_.device :~ $("device")
)
val scn = scenario("BasicSimulation")
.exec(
grpc("test")
.rpc(RelayServerGrpc.METHOD_START_PAIRING)
.payload(greetPayload)
.check(statusCode is Status.Code.ABORTED)
)
setUp(
scn.inject(atOnceUsers(1))
).protocols(grpcConf)
}