/gatling-lambda-extension

A Gatling extension for invoking lambda functions

Primary LanguageScalaMIT LicenseMIT

Gatling Lambda Extension

Maven metadata URL Release Date
Build Status MIT License

What is the Gatling Lambda Extension?

This library is a Gatling Extension that adds support for invoking lambda functions directly using Gatling.

How does it work?

The extension extends Gatling by providing actions, protocols, and requests that allow invocations of lambda functions directly. It's not too much different from the way Gatling is set up to handle HTTP requests.

How do I use it?

This part is pretty simple - you just need to create a lambda protocol using a lambda client, and then make lambda requests.

A really simple example simulation using this is something like this:

Scala API
import io.gatling.core.Predef._
import io.gatling.core.scenario.Simulation
import software.amazon.awssdk.services.lambda.LambdaClient
import uk.co.developmentanddinosaurs.gatling.lambda.Predef._

class ExampleSimulation extends Simulation {

  setUp(
    scenario("My Lambda")
      .exec(
        lambda("my-lambda-function-name")
          .payload("{\"myKey\": \"myValue\"}")
      )
      .inject(
        atOnceUsers(1)
      )
  ).protocols(
    lambda.client(LambdaClient.create())
  )
}
Java API
import static io.gatling.javaapi.core.CoreDsl.*;
import static uk.co.developmentanddinosaurs.gatling.lambda.javaapi.LambdaDsl.lambda;

import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Simulation;
import software.amazon.awssdk.services.lambda.LambdaClient;
import uk.co.developmentanddinosaurs.gatling.lambda.javaapi.protocol.LambdaProtocolBuilder;

public class ExampleSimulationJava extends Simulation {
    public ExampleSimulationJava() {
        LambdaClient client = LambdaClient.create();
        LambdaProtocolBuilder protocol = lambda.client(client);
        ScenarioBuilder scenario =
                scenario("Example Scenario")
                        .exec(lambda("my-lambda-function-name").payload("{\"myKey\": \"myValue\"}"));
        setUp(scenario.injectOpen(atOnceUsers(1))).protocols(protocol);
    }
}

This is a simple example of invoking a lambda function once to see how long it takes to complete - which is good for checking the performance of asynchronous event-driven lambda functions. You can inject any number of users using the Gatling framework to test other things - such as the concurrency of the lambda functions and how well it scales.

The LambdaClient is also under your control, so you can set it up with credentials or HTTP clients as you desire.

This is so cool, how do I contribute?

I know right? You should check out the contribution guide.