Load testing a protocol buffers based server application

Hi,

I want to loadtest a server application that uses Google protocol buffers. Of course all the .proto files (RPC calls, request/response objects) are compiled into .java files that are bundled up into a .JAR. I would like to add this JAR file as a dependency to my Gatling loadtest. I want that Gatling invokes those protobuf RPCs just as any other loadtest.

However, I am unsure if/how this would work with Gatling’s current DSL. My request/response bodies are all binary. And ideally I can hide this as much as possible from the load test. I am looking for a way to use the generated protobuf Java code as much as possible for deserializing and sending requests. But I would like to use Gatling’s DSL to specify which RPCs to call.

How would I add my JAR file as a dependency to the Gatling loadtest?
Assuming my generated code is on Gatling’s classpath, how would I use Gatling’s DSL to test my protobuf-based server?

Thanks,
Ingo

In other words: Can I loadtest a protobuf-based server with Gatling already, or would I have to customize Gatling to do that?

Thanks,
Ingo

Customize.

As protobuf requires you to ship and use the generated serializers, so that’s not something we can have built-in.

Regarding request bodies: you can probably use ByteArrayBody and feed it an Expression[Array[Byte]] that would perform your protobuf serialization.
Regarding response bodies: you can probably use the bodyBytes check, with a transform step that would perform your protobuf deserialization.

Cheers,

Stéphane

Hey Stéphane,

Do you mind providing some example Scala code to demonstrate the approach? I have found a code snippet on stackoverflow that contains the ByteArrayBody type you mentioned:

`

val request = exec(http("FirstRequest")
    .post("/message")
    .body(new ByteArrayBody((session: Session) => getFirstRequest(session)))
    // ...

val response = exec(http("SecondRequest")
    .post("/message")
    .body(new ByteArrayBody((session: Session) => getSecondRequest(session)))
    // ...

`

Would I directly pass a bytes array into ByteArrayBody?

I don’t quite understand the syntax of the value passed into the ByteArrayBody constructor. Can you elaborate what this actually does?

`

(session: Session) => getSecondRequest(session)

`

Just for the record: This was requested and rejected in this Github issue: https://github.com/gatling/gatling/issues/96.

Thanks,
Ingo

Things are pretty clear in the SOF thread :slight_smile:

getFirstRequest and getSecondRequest are methods that take a Session and return an Array[Byte] (or better, a Validation[Array[Byte]).

In those, you would populate some POJO with values coming from the Session, and serialize it.

For example:

getFirstRequest(session: Session) =

for {
id ← session(“id”).validate[Int]
name ← session(“id”).validate[String]
email ← session(“id”).validate[String]
} yield Person.newBuilder.setId(id).set(name).set(email).toByteArray