gatling-grpc


License

License

Categories

Categories

Gatling Application Testing & Monitoring gRPC Net Networking
GroupId

GroupId

com.github.phisgr
ArtifactId

ArtifactId

gatling-grpc_2.12
Last Version

Last Version

0.10.1
Release Date

Release Date

Type

Type

jar
Description

Description

gatling-grpc
gatling-grpc
Project URL

Project URL

https://github.com/phiSgr/gatling-grpc
Project Organization

Project Organization

com.github.phisgr
Source Code Management

Source Code Management

https://github.com/phiSgr/gatling-grpc

Download gatling-grpc_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.phisgr/gatling-grpc_2.12/ -->
<dependency>
    <groupId>com.github.phisgr</groupId>
    <artifactId>gatling-grpc_2.12</artifactId>
    <version>0.10.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.phisgr/gatling-grpc_2.12/
implementation 'com.github.phisgr:gatling-grpc_2.12:0.10.1'
// https://jarcasting.com/artifacts/com.github.phisgr/gatling-grpc_2.12/
implementation ("com.github.phisgr:gatling-grpc_2.12:0.10.1")
'com.github.phisgr:gatling-grpc_2.12:jar:0.10.1'
<dependency org="com.github.phisgr" name="gatling-grpc_2.12" rev="0.10.1">
  <artifact name="gatling-grpc_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.phisgr', module='gatling-grpc_2.12', version='0.10.1')
)
libraryDependencies += "com.github.phisgr" % "gatling-grpc_2.12" % "0.10.1"
[com.github.phisgr/gatling-grpc_2.12 "0.10.1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.10
io.grpc : grpc-netty jar 1.30.2
com.thesamet.scalapb : scalapb-runtime-grpc_2.12 jar 0.10.8
io.gatling : gatling-core jar 3.4.1
com.github.phisgr : gatling-ext_2.12 jar 0.1.0

test (3)

Group / Artifact Type Version
io.gatling.highcharts : gatling-charts-highcharts jar 3.4.1
io.gatling : gatling-test-framework jar 3.4.1
org.scalatest : scalatest_2.12 jar 3.0.8

Project Modules

There are no modules declared in this project.

Gatling-gRPC

A Gatling load test plugin for gRPC.

Usage

Because of gRPC's need of code generation, I assume you are running the tests using the SBT plugin. For a quickstart guide, see this Medium article.

To use this library, add this library to the test dependencies along with the two required by Gatling.

libraryDependencies ++= Seq(
  "io.gatling.highcharts" % "gatling-charts-highcharts" % gatlingVersion % "test",
  "io.gatling" % "gatling-test-framework" % gatlingVersion % "test",
  "com.github.phisgr" %% "gatling-grpc" % "0.10.1" % "test"
)
enablePlugins(GatlingPlugin)

For setting up the code generation, see the documentation in ScalaPB.

If your protobuf files are in src/test/protobuf instead of src/main/protobuf, change Compile to Test.

PB.targets in Test := Seq(
  scalapb.gen() -> (sourceManaged in Test).value
)

To make a gRPC call:

exec(
  grpc("my_request")
    .rpc(ChatServiceGrpc.METHOD_GREET)
    .payload(GreetRequest(
      username = "myUserName",
      name = "My name"
    ))
)

For a complete demo and various examples including the proper syntax to include session attributes (e.g. from a feeder, or saved in a check), see GrpcExample in test.

For more complex manipulations with session attributes and protobuf objects, like repeated fields and map fields, see the unit test.

Dynamic Payload

There are helper methods in gatling-grpc for generating dynamic ScalaPB objects with Lenses, as demonstrated in the example linked above. It makes uses of extension methods, and requires importing com.github.phisgr.gatling.pb._.

If you want to use Java Protobuf classes, you can use the gatling-javapb library.

If the expressive power of these two plumbing tools are not enough, you can always resort to writing a lambda. Because an Expression[T]is just an alias for Session => Validation[T].

Logging

In logback.xml, add
<logger name="com.github.phisgr.gatling.grpc" level="DEBUG" />
to log the requests that are failed; or set the level to TRACE to log all gRPC requests.

Development

sbt clean coverage test gatling:test coverageReport for a coverage report.
sbt clean bench/clean 'bench/jmh:run -i 3 -wi 3 -f10 -t1 -prof gc' for JMH tests.

Versions

Version
0.10.1
0.10.0
0.9.0
0.8.2
0.8.1
0.8.0
0.7.0
0.6.0
0.5.0
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0
0.0.1