Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

An sample project to show how to use Gatling-gRPC with Gatling's Gradle Plugin

Notifications You must be signed in to change notification settings

phiSgr/gatling-grpc-gradle-demo

Repository files navigation

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()
}

About

An sample project to show how to use Gatling-gRPC with Gatling's Gradle Plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published