Created
July 8, 2020 15:36
-
-
Save imavroukakis/f96029c7d82682fd17720d3fcc6f7933 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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