GithubHelp home page GithubHelp logo

vas78 / gatling-grpc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phisgr/gatling-grpc

0.0 0.0 0.0 347 KB

A Gatling load test plugin for gRPC

License: Apache License 2.0

Java 6.06% Scala 64.39% Kotlin 29.55%

gatling-grpc's Introduction

Gatling-gRPC

A Gatling load test community plugin for gRPC.

Since Gatling 3.10, Gatling Corp has released their plugin for gRPC.

This plugin will no longer be updated. Feel free to fork and maintain it if you want (to provide) up-to-date free stuff.

Java/Kotlin API

Since 3.7, Gatling adds Java API for the test to be written in Java or Kotlin. Since Gatling-gRPC 0.14.0, a binding is written in Kotlin for Java and Kotlin users. It is demoed in the gatling-grpc-gradle-demo project.

Usage

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

For usage with the Gradle Gatling plugin, see this example project.

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.17.0" % "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.

Test / PB.targets := Seq(
  scalapb.gen() -> (Test / sourceManaged).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.

gatling-grpc's People

Contributors

phisgr avatar khlumzeemee avatar slandelle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.