gatling-akka-root


License

License

Categories

Categories

Gatling Application Testing & Monitoring Akka Container Microservices Reactive libraries
GroupId

GroupId

com.chatwork
ArtifactId

ArtifactId

gatling-akka-root_2.12
Last Version

Last Version

0.1.13
Release Date

Release Date

Type

Type

jar
Description

Description

gatling-akka-root
gatling-akka-root
Project URL

Project URL

https://github.com/chatwork/gatling-akka
Project Organization

Project Organization

com.chatwork
Source Code Management

Source Code Management

https://github.com/chatwork/gatling-akka

Download gatling-akka-root_2.12

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4

Project Modules

There are no modules declared in this project.

gatling-akka

gatling-akka is gatling plugin for stress tests of Akka application.

gatling-akka enables to simulate message passing between actors and measure latency and throughput of the requests and responses.

Installation

For sbt users, add following lines to build.sbt.

Scala 2.11

libraryDependencies ++= Seq(
  "io.gatling.highcharts" % "gatling-charts-highcharts" % "2.2.5",
  "io.gatling" % "gatling-test-framework" % "2.2.5",
  "com.chatwork" %% "gatling-akka" % "0.1.14"
)

Scala 2.12

libraryDependencies ++= Seq(
  "io.gatling.highcharts" % "gatling-charts-highcharts" % "3.1.3",
  "io.gatling" % "gatling-test-framework" % "3.1.3",
  "com.chatwork" %% "gatling-akka" % "0.1.15"
)

Example

import _root_.io.gatling.core.Predef._
import com.chatwork.gatling.akka.Predef._

class BasicSimulation extends Simulation {

  val config = ConfigFactory.load()
  implicit val system = ActorSystem("BasicSimulation", config)

  // gatling-akka protocol configuration
  val akkaConfig = akkaActor.askTimeout(3 seconds)

  // recipient actorRef
  val ponger = system.actorOf(PingerPonger.ponger)

  // scenario definition
  val s = scenario("ping-pong-ping-pong")
    .exec {
      // ask a request to ponger actor and check its response with expectMsg and then save it in session if the check passes
      akkaActor("ping-1").to(ponger) ? PingerPonger.Ping check expectMsg(PingerPonger.Pong).saveAs("pong")
    }
    .exec {
      val pf: PartialFunction[Any, Unit] = {
        case PingerPonger.Pong =>
      }

      akkaActor("ping-2").to(ponger).ask { session =>
        // ask based on session value
        session("pong").as[PingerPonger.Pong.type] match {
          case PingerPonger.Pong => PingerPonger.Ping
        }
      }.check(expectMsgPF(pf)) // check a response with partial function with expectMsgPF
    }
    .exec {
      // message content check, same as expectMsg
      akkaActor("ping-3").to(ponger) ? PingerPonger.Ping check message.is(PingerPonger.Pong)
    }
    .exec {
      // find recipient and save it in session
      akkaActor("ping-4").to(ponger) ? PingerPonger.Ping check recipient.find.exists.saveAs("recipient")
    }

  // inject configurations
  setUp(
    s.inject(constantUsersPerSec(10) during (10 seconds))
  ).protocols(akkaConfig).maxDuration(10 seconds)
}

// simple ping-pong actor definition
object PingerPonger {

  def ponger: Props = Props(new Ponger)

  class Ponger extends Actor {
    override def receive: Receive = {
      case Ping => sender() ! Pong
    }
  }

  case object Ping

  case object Pong

}
com.chatwork

Chatwork

Versions

Version
0.1.13