Last active
April 8, 2020 10:02
-
-
Save polarnik/d21db22114d1b7b68064202ff95d1c2d to your computer and use it in GitHub Desktop.
src/test/scala/io/qaload/gatling/reportExample/simulation/CloseModel_IncrementConcurrentUsers.scala
This file contains 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 io.qaload.gatling.reportExample.simulation | |
import io.gatling.core.Predef.{constantConcurrentUsers, nothingFor, _} | |
import io.gatling.core.structure.ScenarioBuilder | |
import io.qaload.gatling.reportExample.process.SimpleScenario | |
import io.qaload.gatling.reportExample.setting.Protocol | |
import scala.concurrent.duration._ | |
import io.gatling.core.Predef._ | |
/** | |
* Meta DSL to write closed increment tests (succession of several increasing levels) | |
* | |
* incrementConcurrentUsers(incrementConcurrentUsers) | |
* .times(numberOfSteps) | |
* .eachLevelLasting(levelDuration) | |
* .separatedByRampsLasting(rampDuration) | |
* .startingFrom(initialConcurrentUsers) | |
* | |
* Inject a succession of numberOfSteps levels each one | |
* during levelDuration | |
* and increasing the number of users per sec by incrementConcurrentUsers | |
* starting from zero or the optional initialConcurrentUsers | |
* and separated by optional ramps lasting rampDuration | |
*/ | |
class CloseModel_IncrementConcurrentUsers extends Simulation { | |
def simpleScenarioWithPace(name: String, paceDuration: Duration) = | |
scenario(name) | |
.forever ( | |
pace(100) | |
.exec( | |
SimpleScenario.simpleScenario() | |
) | |
) | |
def simpleScenarioWithPaceAndDuration(name: String, paceDuration: Duration, levelDuration: Duration) = | |
scenario(name) | |
.during(levelDuration) ( | |
pace(paceDuration) | |
.exec( | |
SimpleScenario.simpleScenario() | |
) | |
) | |
setUp( | |
simpleScenarioWithPaceAndDuration("incrementConcurrentUsers", 200 millisecond, 100 second).inject( | |
constantConcurrentUsers(1) during (0.01 seconds), | |
constantConcurrentUsers(0) during (10 seconds), | |
incrementConcurrentUsers(1) | |
.times(5) | |
.eachLevelLasting(100 second) | |
.separatedByRampsLasting(0 second) | |
.startingFrom(1), | |
constantConcurrentUsers(0) during (10 seconds), | |
constantConcurrentUsers(1) during (0.01 seconds) | |
).protocols(Protocol.httpConf).throttle( | |
reachRps(70) in (600 seconds) | |
) | |
) | |
} |
This file contains 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 io.qaload.gatling.reportExample.process | |
import io.gatling.core.Predef._ | |
import io.gatling.core.structure.{ChainBuilder, ScenarioBuilder} | |
import io.gatling.http.Predef._ | |
import io.qaload.gatling.util.UtilsFeed | |
import scala.concurrent.duration._ | |
object SimpleScenario { | |
def simpleScenario(): ChainBuilder = | |
exec( | |
http("/ (GET)").get("/") | |
) | |
.exec( | |
http("/40x.html (GET)").get("/40x.html") | |
) | |
.exec( | |
http("/50x.html (GET)").get("/50x.html") | |
) | |
} |
Видны скачки количества пользователей (Active Users - Virtual User - VU - правая ось на графиках - старты сценариев в сек). Это из-за того, что использовал pace с длительностью шага. Если использовать вариант с forever (тоже есть в коде), то тест не будет вечным, он будет длиться столько, сколько указано в throttle, но скачков не будет.
При этом количество конкрретных пользователей (выполняющихся одновременных "потоков" закрытой модели Gatling - Concurrent Users - левая ось на графике) растёт согласно профилю, от 1 до 5, без скачков. Таким образом, всего 1-5 обработчиков создают в итоге 0-70 запросов в сек.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://snapshot.raintank.io/dashboard/snapshot/eep9a5dkUsB3jq6GYy0mLnv67Hs9Gk47?orgId=2
https://drive.google.com/open?id=19b084ERPlwStc11jm2SUrA7cvZvyexTo
https://yadi.sk/d/eS-tBjuLWqnqEQ