Permalink
Browse files

Enhance simulation to:

1. GET sample instances
2. check response time for sample API interactions are less than 100ms
  • Loading branch information...
1 parent 47bb687 commit a89bc708d6cb7ebdaf3e6acb5185da60dbeaac10 @skuenzli committed Nov 11, 2012
@@ -8,6 +8,7 @@ class OutstandingRequestLimitingFilterSimulation extends Simulation {
def apply = {
val urlBase = "http://localhost:8080"
+ val NUM_SAMPLES = 100
val httpConf = httpConfig.baseURL(urlBase)
.requestInfoExtractor((request: Request) => {
@@ -30,7 +31,7 @@ class OutstandingRequestLimitingFilterSimulation extends Simulation {
"Host" -> "localhost:8080")
val setupScenario = scenario("Setup")
- .repeat(10) {
+ .repeat(NUM_SAMPLES) {
chain
.exec(
http("examples - create")
@@ -40,27 +41,57 @@ class OutstandingRequestLimitingFilterSimulation extends Simulation {
)
}
+ val randomIntegerFeeder = new Feeder {
+
+ import scala.util.Random
+
+ private val RNG = new Random
+
+ // always return true as this feeder can be polled infinitely
+ override def hasNext = true
+
+ override def next: Map[String, String] = {
+ Map("randomInt" -> (RNG.nextInt(NUM_SAMPLES) + 1).toString)
+ }
+ }
+
+ val expectedStatuses: List[Int] = List(200, 503)
val overloadScenario = scenario("Request overload")
.loop(
chain
.exec(
http("homepage")
.get("/sample-webapp/")
.headers(headers_standard)
- .check(status.in(List(200, 503))))
- /* .pause(0, 50, MILLISECONDS) */
- .pauseExp(100 milliseconds)
+ .check(status.in(expectedStatuses)))
.exec(
http("examples - list")
.get("/sample-webapp/examples/")
.headers(headers_json)
- .check(status.in(List(200, 503))))
- ).during(1, MINUTES)
+ .check(status.in(expectedStatuses))
+ .check(responseTimeInMillis.lessThan(100)))
+
+ .feed(randomIntegerFeeder)
+
+ .loop(
+ chain
+ .exec(
+ http("examples - get")
+ .get("/sample-webapp/examples/${randomInt}")
+ .headers(headers_json)
+ .check(status.in(expectedStatuses))
+ .check(responseTimeInMillis.lessThan(100))
+ )
+ ).times(3)
+
+ .pauseExp(100 milliseconds)
+
+ ).during(60, SECONDS)
List(
- setupScenario.configure.users(1).ramp(1).protocolConfig(httpConf)
- , overloadScenario.configure.users(100).ramp(10).protocolConfig(httpConf)
+ setupScenario.configure.users(1).protocolConfig(httpConf)
+ , overloadScenario.configure.users(100).ramp(10).protocolConfig(httpConf).delay(10, SECONDS)
)
}
}

0 comments on commit a89bc70

Please sign in to comment.