Created
November 22, 2013 19:53
-
-
Save vincentbernat/7605802 to your computer and use it in GitHub Desktop.
Gatling scenario with step up and quick ramp down
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 dailymotion | |
import io.gatling.core.Predef._ | |
import io.gatling.http.Predef._ | |
import io.gatling.http.Headers.Names._ | |
import scala.concurrent.duration._ | |
import bootstrap._ | |
import assertions._ | |
object SearchDailymotion { | |
val topQueries = tsv("es-top.csv").circular | |
val autocompleteQueries = tsv("es-autocomplete.csv").circular | |
def scn(step: Int, duration: Int) = scenario(s"Search Dailymotion Scenario $step") | |
.feed(csv("elasticsearch.csv").random) | |
.during(duration seconds) { | |
randomSwitch( | |
70 -> feed(autocompleteQueries) | |
.exec(http("Autocomplete request") | |
.post("${base}${complete}") | |
.header("Content-Type", "application/json") | |
.body(StringBody("${request}"))) | |
.pause(2 seconds, 10 seconds), | |
30 -> feed(topQueries) | |
.exec(http("Search request") | |
.post("${base}${query}") | |
.header("Content-Type", "application/json") | |
.body(StringBody("${request}"))) | |
.pause(10 seconds, 30 seconds)) | |
} | |
} | |
class SearchDailymotionSimulation extends Simulation { | |
val httpProtocol = http | |
.acceptHeader("text/json,application/json") | |
.acceptEncodingHeader("gzip, deflate") | |
.userAgentHeader("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36") | |
.disableFollowRedirect | |
// Parameters for this test | |
val rampTime = 10 // seconds | |
val rampHeight = 5 // users | |
val steadyTime = 20 // seconds | |
val numSteps = 10 | |
val params = 1 to numSteps map { i => | |
SearchDailymotion.scn(i, (numSteps - i + 3) * (rampTime+steadyTime)) | |
.inject( | |
nothingFor((i-1) * (rampTime+steadyTime) seconds), | |
ramp(rampHeight users) over (rampTime seconds), | |
nothingFor(steadyTime seconds)) | |
} | |
setUp(scenario("Nothing").inject(nothingFor(1 seconds)), | |
params:_*) | |
.protocols(httpProtocol) | |
.assertions( | |
global.successfulRequests.percent.is(100), | |
details("Search request").responseTime.max.lessThan(1000), | |
details("Autocomplete request").responseTime.max.lessThan(200)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, does this still work with Gatling 2.2.2?
I get following error at line 55