Newbie Gatling+Scala question: I’m using George Leung's gatling-grpc library (which is modeled after the http library) and trying to pass a value from the session (generated in a feeder), into a non-DSL, non-Gatling method call, specifically calls populating the gRPC payload object.
Before I start, let me add that it seems I can’t use the sessionFunction (Expression[T]
) form of exec
, which would resolve my issue:
.exec{ session => { … grpc(…).rpc(…)… }}
…because, AFAICT, the grpc
call must be the last thing in the block, or else it’s never evaluated ... yet it can’t be the last thing in the block because there’s no way to coerce it to return a Session object (again, AFAICT).
Therefore, I have to use the ActionBuilder
form of exec
(grpc(...)
returns a Call
so this is as designed):
.exec( grpc(…).rpc(…)... )
and this works… until I have a gRPC payload (i.e., non-Gatling) method call to which I need to pass a non-constant value (from a feeder).
In this context, I have no access to a Session
object, and the Gatling Expression Language is not applied because the library defining the gRPC types I need to use (to generate the payload) has no knowledge of Gatling.
So, in this fragment:
.header(transactionIdHeader)("${tid}.SAVE")
.payload(Student.newBuilder()
.setId(GlobalId.newBuilder().setValue("${authid}_${uniqId}").build()).build())
)
…the first call evaluates ${tid}
because the param in the second parens is Expression[T]
, and hence is evaluated as Expression Language, but the second call fails to evaluate ${authid}
or ${uniqId}
because the external, generated library that defines the gRPC type GlobalId has no knowledge of Gatling.
So...
- Is there a way to invoke the EL outside of Gatling's DSL?
- Or a way to access a
Session
object via anActionBuilder
?- (I see that the Gatling code magically finds a Session object when I use the sessionFunction form, but I can't see whence it comes — even looking at the bytecode is not illuminating)
- Or, turning back to the
Expression[T]
form ofexec
, is there a way to have anActionBuilder
return aSession
object? - Or, still in the
Expression[T]
form, I could trivially pass back the existingSession
object, if I had a way to ensure thegrpc()...
expression was evaluated (i.e., imperative programming).
Gatling 3.3.1, Scala 2.12.10
The gatling-grpc library is at phiSgr/gatling-grpc; I'm using version 0.7.0 (com.github.phisgr:gatling-grpc
).
(The gRPC Java code is generated from .proto files, of course.)
protoc
) for Java, but the gatling-grpc library, somewhat reasonably, appears to assume (in some cases) that the code was generated for scala. IOW: D'oh – LarryW