Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Advanced Example

  • Loading branch information...
commit c0709b563db137f68e745baee745478605aa1fd6 1 parent 9b81a22
@krishnenc authored
View
13 src/main/scala/advanced/AdvancedExampleSimulation.scala
@@ -0,0 +1,13 @@
+package advanced
+import com.excilys.ebi.gatling.core.Predef._
+import com.excilys.ebi.gatling.http.Predef._
+
+class AdvancedExampleSimulation extends Simulation {
+
+ def apply = {
+ val urlBase = "http://excilys-bank-web.cloudfoundry.com"
+ val httpConf = httpConfig.baseURL(urlBase)
+ List(SomeScenario.scn.configure.users(10).ramp(10).protocolConfig(httpConf),
+ SomeOtherScenario.otherScn.configure.users(5).ramp(20).delay(30).protocolConfig(httpConf))
+ }
+}
View
51 src/main/scala/advanced/Headers.scala
@@ -0,0 +1,51 @@
+package advanced
+
+object Headers {
+ val headers_1 = Map(
+ "Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
+ "Accept-Charset" -> "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
+ "Accept-Encoding" -> "gzip,deflate",
+ "Accept-Language" -> "fr,en-us;q=0.7,en;q=0.3",
+ "Host" -> "excilys-bank-web.cloudfoundry.com",
+ "Keep-Alive" -> "115",
+ "User-Agent" -> "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/9.10 (karmic) Firefox/3.6.17")
+
+ val headers_3 = headers_1 ++ Map(
+ "Content-Length" -> "33",
+ "Content-Type" -> "application/x-www-form-urlencoded",
+ "Referer" -> "http://excilys-bank-web.cloudfoundry.com/public/login.html")
+
+ val headers_4 = headers_1 ++ Map(
+ "Referer" -> "http://excilys-bank-web.cloudfoundry.com/public/login.html")
+
+ val headers_5 = headers_1 ++ Map(
+ "Referer" -> "http://excilys-bank-web.cloudfoundry.com/private/bank/accounts.html")
+
+ val headers_6 = Map(
+ "Accept" -> "application/json, text/javascript, */*; q=0.01",
+ "Accept-Charset" -> "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
+ "Accept-Encoding" -> "gzip,deflate",
+ "Accept-Language" -> "fr,en-us;q=0.7,en;q=0.3",
+ "Host" -> "excilys-bank-web.cloudfoundry.com",
+ "Keep-Alive" -> "115",
+ "Referer" -> "http://excilys-bank-web.cloudfoundry.com/private/bank/account/ACC4/operations.html",
+ "User-Agent" -> "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/9.10 (karmic) Firefox/3.6.17",
+ "X-Requested-With" -> "XMLHttpRequest")
+
+ val headers_7 = headers_1 ++ Map(
+ "Referer" -> "http://excilys-bank-web.cloudfoundry.com/private/bank/account/ACC4/operations.html")
+
+ val headers_8 = Map(
+ "Accept" -> "application/json, text/javascript, */*; q=0.01",
+ "Accept-Charset" -> "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
+ "Accept-Encoding" -> "gzip,deflate",
+ "Accept-Language" -> "fr,en-us;q=0.7,en;q=0.3",
+ "Host" -> "excilys-bank-web.cloudfoundry.com",
+ "Keep-Alive" -> "115",
+ "Referer" -> "http://excilys-bank-web.cloudfoundry.com/private/bank/account/ACC4/year/2011/month/11/operations.html",
+ "User-Agent" -> "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/9.10 (karmic) Firefox/3.6.17",
+ "X-Requested-With" -> "XMLHttpRequest")
+
+ val headers_9 = headers_1 ++ Map(
+ "Referer" -> "http://excilys-bank-web.cloudfoundry.com/private/bank/account/ACC4/year/2011/month/11/operations.html")
+}
View
35 src/main/scala/advanced/SomeOtherScenario.scala
@@ -0,0 +1,35 @@
+package advanced
+import com.excilys.ebi.gatling.core.Predef._
+import com.excilys.ebi.gatling.http.Predef._
+import Headers._
+
+object SomeOtherScenario {
+
+ val otherScn = scenario("Other Scenario Name")
+ .exec(
+ http("other_request_1")
+ .get("/")
+ .check(status.is(302)))
+ .pause(0, 100, MILLISECONDS)
+ .exec(
+ http("other_request_2")
+ .get("/public/login.html"))
+ .pause(12, 13)
+ .feed(csv("user_credentials.csv"))
+ .exec(
+ http("other_request_3")
+ .post("/login")
+ .param("username", "${username}")
+ .param("password", "${password}")
+ .check(status.is(302)))
+ .pause(0, 100, MILLISECONDS)
+ .exec(
+ http("other_request_9")
+ .get("/logout")
+ .headers(headers_9)
+ .check(status.is(302)))
+ .pause(0, 100, MILLISECONDS)
+ .exec(
+ http("other_request_10")
+ .get("/public/login.html"))
+}
View
69 src/main/scala/advanced/SomeScenario.scala
@@ -0,0 +1,69 @@
+package advanced
+import com.excilys.ebi.gatling.core.Predef._
+import com.excilys.ebi.gatling.http.Predef._
+import Headers._
+
+object SomeScenario {
+
+ val scn = scenario("Scenario name")
+ .exec(
+ http("request_1")
+ .get("/")
+ .headers(headers_1)
+ .check(status.is(302)))
+ .pause(0, 100, MILLISECONDS)
+ .exec(
+ http("request_2")
+ .get("/public/login.html")
+ .headers(headers_1))
+ .pause(12, 13)
+ .feed(csv("user_credentials.csv"))
+ .exec(
+ http("request_3")
+ .post("/login")
+ .param("username", "${username}")
+ .param("password", "${password}")
+ .headers(headers_3)
+ .check(status.is(302)))
+ .pause(0, 100, MILLISECONDS)
+ .loop(
+ chain
+ .exec(
+ http("request_4")
+ .get("/private/bank/accounts.html")
+ .headers(headers_4)
+ .check(regex("""<td class="number">ACC(\d+)</td>""").saveAs("account_id")))
+ .pause(7, 8)
+ .exec(
+ http("request_5")
+ .get("/private/bank/account/ACC${account_id}/operations.html")
+ .headers(headers_5))
+ .pause(100, 200, MILLISECONDS)
+ .exec(
+ http("request_6")
+ .get("/private/bank/account/ACC${account_id}/year/2011/month/12/page/0/operations.json")
+ .headers(headers_6))
+ .pause(4, 5)
+ .exec(
+ http("request_7")
+ .get("/private/bank/account/ACC${account_id}/year/2011/month/11/operations.html")
+ .headers(headers_7))
+ .pause(100, 200, MILLISECONDS)
+ .exec(
+ http("request_8")
+ .get("/private/bank/account/ACC${account_id}/year/2011/month/11/page/0/operations.json")
+ .headers(headers_8))
+ .pause(6, 7)).times(5)
+ .doIf((session: Session) => session.getAttribute("username") != "user7",
+ chain
+ .exec(
+ http("request_9")
+ .get("/logout")
+ .headers(headers_9)
+ .check(status.is(302)))
+ .pause(0, 100, MILLISECONDS)
+ .exec(
+ http("request_10")
+ .get("/public/login.html")
+ .headers(headers_9)))
+}
View
17 src/main/scala/BasicExampleSimulation.scala → .../scala/basic/BasicExampleSimulation.scala
@@ -1,7 +1,20 @@
package basic
-import com.excilys.ebi.gatling.core.Predef._
-import com.excilys.ebi.gatling.http.Predef._
+import com.excilys.ebi.gatling.core.Predef.MILLISECONDS
+import com.excilys.ebi.gatling.core.Predef.Simulation
+import com.excilys.ebi.gatling.core.Predef.chain
+import com.excilys.ebi.gatling.core.Predef.checkBuilderToCheck
+import com.excilys.ebi.gatling.core.Predef.csv
+import com.excilys.ebi.gatling.core.Predef.extractorCheckBuilderToMatcherCheckBuilder
+import com.excilys.ebi.gatling.core.Predef.scenario
+import com.excilys.ebi.gatling.core.Predef.stringToSessionFunction
+import com.excilys.ebi.gatling.core.Predef.toSessionFunction
+import com.excilys.ebi.gatling.core.feeder.SourceBasedFeederBuilder.feederBuilderToFeeder
+import com.excilys.ebi.gatling.http.Predef.http
+import com.excilys.ebi.gatling.http.Predef.httpConfig
+import com.excilys.ebi.gatling.http.Predef.status
+import com.excilys.ebi.gatling.http.Predef.toHttpProtocolConfiguration
+import com.excilys.ebi.gatling.http.request.builder.AbstractHttpRequestBuilder.toActionBuilder
class BasicExampleSimulation extends Simulation {
Please sign in to comment.
Something went wrong with that request. Please try again.