Skip to content

Load testing for Carbyne Stack via a Load-Testing-as-Code approach

License

Notifications You must be signed in to change notification settings

carbynestack/caliper

Repository files navigation

Carbyne Stack Caliper Load Testing Harness

Codacy Badge Known Vulnerabilities Conventional Commits pre-commit Contributor Covenant

DISCLAIMER: Carbyne Stack Caliper is in proof-of-concept stage. The software is not ready for production use. It has neither been developed nor tested for a specific use case.

Caliper is the Load-Testing-as-Code harness for Carbyne Stack. This project is based on the Gatling load test tool and provides a plugin that can be used to communicate with backend services of a Carbyne Stack Virtual Cloud using the dedicated java-clients.

Components

Protocol

The cs object is used to provide a common configuration that is shared between all virtual users. A list of Amphora Service endpoint URIs and the SPDZ parameters matching the backend service configuration are used to initialize an Amphora client.

Action

To test the performance of one or multiple backend services of a Carbyne Stack Virtual Cloud we create scenarios that make requests to a backend service. The exec method is used to execute an Action, in the context of this plugin, actions are requests performed by a client that will be sent during a simulation.

Usage

To execute the simulation we can use the gatling-maven-plugin where we specify the simulation class we want to use, e.g.

 <plugin>
    <groupId>io.gatling</groupId>
    <artifactId>gatling-maven-plugin</artifactId>
    <version>${gatling-maven-plugin-version}</version>
    <configuration>
        <simulationClass>CarbynestackSimulation</simulationClass>
    </configuration>
</plugin>

Multiple simulations can be executed using <runMultipleSimulations>true</runMultipleSimulations>, by default the results are stored in ${project.build.directory}/gatling but this value can be overriden using <resultsFolder>path/to/folder</resultsFolder>. To run the simulation simply use the test goal ./mvnw gatling:test. The following example shows a simulation class that provides the functionality to upload data to a Carbyne Stack Virtual Cloud.

class CarbynestackSimulation extends Simulation { //1

  val csProtocol = cs //2
    .endpoints(List("http://172.18.1.128/amphora", "http://172.18.2.128/amphora"))
    .prime("198766463529478683931867765928436695041")
    .r("141515903391459779531506841503331516415")
    .invR("133854242216446749056083838363708373830")

  val tagKeys = List.fill[String](2)(Random.alphanumeric.take(10).mkString)
  val tagGenerator =
     new TagGenerator(tagKeys, Some(1000000000L), Some(9999999999L))
  val secretGenerator =
     new SecretGenerator(tagGenerator, 1000000000L, 9999999999L, 1) //3

  val feeder = Iterator.continually { //4
    Map("secret" -> secretGenerator.generate)
  }

  val createSecret = scenario("Amphora-createSecret-scenario") //5
    .feed(feeder) //6
    .exec(amphora.createSecret("#{secret}")) //7

  setUp( //8
    createSecret.inject(atOnceUsers(10) //9
    ).protocols(csProtocol)) //10
}
  1. The class declaration, it needs to extend Simulation
  2. The common configuration to all Carbynestack client requests, e.g. see amphora-java-client
  3. Create a secret with randomized data that can be used by the client
  4. A Feeder is used to inject data into the virtual user
  5. The Scenario definition
  6. The secret generated by the secretGenerator.generate method is injected into the virtual users session
  7. An amphora-java-client-request calling the createSecret method of the io.carbynestack.amphora.client.AmphoraClient. Using the Gatling Expression Language we can use dynamic parameters that will be replaced with the value stored in the virtual user's session
  8. Setting up the scenario(s) we want to use in this simulation
  9. Declaring that 10 virtual users will be injected at once into the createSecret scenario
  10. Attaching the cs configuration matching the backend service configuration

Namesake

A caliper [...] is a device used to measure the dimensions of an object (Source).

The object being measured in our case is Carbyne Stack. The dimensions are primarily performance and scalability.

License

The Carbyne Stack Caliper Load-Testing-as-Code harness is open-sourced under the Apache License 2.0. See the LICENSE file for details.

3rd Party Licenses

For information on how license obligations for 3rd party OSS dependencies are fulfilled see the README file of the Carbyne Stack repository.

Contributing

Please see the Carbyne Stack Contributor's Guide