Skip to content

Instantly share code, notes, and snippets.

@imavroukakis
Created July 8, 2020 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imavroukakis/f96029c7d82682fd17720d3fcc6f7933 to your computer and use it in GitHub Desktop.
Save imavroukakis/f96029c7d82682fd17720d3fcc6f7933 to your computer and use it in GitHub Desktop.
package dev.to.gatling
import com.typesafe.scalalogging.StrictLogging
import io.gatling.core.Predef._
import io.gatling.core.scenario.Simulation
import io.gatling.http.Predef._
import scala.concurrent.duration._
import scala.language.postfixOps
import scala.util.{Failure, Success, Try}
class LoadSimulation extends Simulation with StrictLogging {
GatlingRunner.conf match {
case Some(conf) => {
val duration: FiniteDuration = Try(Duration(conf.testDuration().replace('_', ' '))) match {
case Success(duration) => duration.asInstanceOf[FiniteDuration]
case Failure(exception) => throw exception
}
val usersPerSecond = conf.usersPerSecond().toDouble
val postsScenario =
scenario("Posts")
.exec(http("Get 100 posts").get("http://jsonplaceholder.typicode.com/todos"))
setUp(
postsScenario.inject(
constantUsersPerSec(usersPerSecond) during duration
).protocols(http)
)
}
case None => throw new IllegalStateException
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment