Home

Awesome

Gatling-gRPC demo in Gradle

A demo project showcasing a Gatling tests, written in Scala and Kotlin, living in the same project as the gRPC server.

Run

Run the server: ./gradlew run
Run the load test: ./gradlew gatlingRun

Dynamic Payload

This project also demonstrates the integration between Java Protobuf messages with Gatling Expressions.

val message: Expression[Ping] =
  Ping.getDefaultInstance
    // dynamic payload!
    .update(_.setData)($("data"))

_.setData is a method reference of Ping.Builder; and
data is a session attribute containing a number.

See the runtime-generated payload in the TRACE logging!

=========================
gRPC request:
headers=
grpc-accept-encoding: gzip
payload=
data: 18

=========================
gRPC response:
status=
OK
body=
data: 18

<<<<<<<<<<<<<<<<<<<<<<<<<

Extension

Some magic is used to aid type inference in Gatling-JavaPB. For that to work in IntelliJ, enable the extension in the "Event Log" in the bottom right corner.

enable extension

Otherwise, IntelliJ cannot recognize the method references like setData, and they will not be auto-suggested or syntax-highlighted.

If you do not get the notification, try forcing the download of the extension by adding
gatling 'com.github.phisgr:gatling-javapb-ijext:1.3.0'
in dependencies { in build.gradle.

After that you can remove that line of dependency.

Kotlin

To run: ./gradlew gatlingRun-com.github.phisgr.exampletest.PingPongKt

.payload(Ping::newBuilder) { session ->
    // dynamic payload!
    data = session.getInt("data")
    build()
}