Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Basic Example

  • Loading branch information...
commit 68651b3606f8afd4a28056b8882fe1c7aea9e23f 1 parent df958e4
@krishnenc authored
View
6 README.md
@@ -1,4 +1,8 @@
gatling-sbt
===========
-A sbt template project for writing [Gatling](https://github.com/excilys/gatling.git) simulations in eclipse
+A sbt template project for writing [Gatling](https://github.com/excilys/gatling.git) simulations in Eclipse.
+
+Depends on gatiling 1.1.6
+sbt 0.11.3
+Scala 2.9.2
View
11 src/main/resources/data/user_credentials.csv
@@ -0,0 +1,11 @@
+username,password
+user1,password1
+user2,password2
+user3,password3
+user4,password4
+user5,password5
+user6,password6
+user7,password7
+user8,password8
+user9,password9
+user10,password10
View
11 src/main/resources/data/user_information.csv
@@ -0,0 +1,11 @@
+username,password,account_id
+user1,password1,4
+user2,password2,7
+user3,password3,10
+user4,password4,13
+user5,password5,17
+user6,password6,21
+user7,password7,23
+user8,password8,27
+user9,password9,29
+user10,password10,34
View
2  src/main/scala/Engine.scala
@@ -4,8 +4,6 @@ import com.excilys.ebi.gatling.core.util.PathHelper.path2string
object Engine extends App {
- println(IDEPathHelper.mavenBinariesDir)
-
new Gatling(Options(
dataFolder = Some(IDEPathHelper.dataFolder),
resultsFolder = Some(IDEPathHelper.resultsFolder),
View
122 src/main/scala/FooSimulation.scala
@@ -1,9 +1,123 @@
-import com.excilys.ebi.gatling.core.Predef.Simulation
+package basic
-class FooSimulation extends Simulation {
+import com.excilys.ebi.gatling.core.Predef._
+import com.excilys.ebi.gatling.http.Predef._
+
+class BasicExampleSimulation extends Simulation {
def apply = {
- // This is where your simulation should be coded
- List()
+
+ val urlBase = "http://excilys-bank-web.cloudfoundry.com"
+
+ val httpConf = httpConfig.baseURL(urlBase)
+
+ 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")
+
+ 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_information.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))
+ .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)
+ .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))
+
+ List(scn.configure.users(10).ramp(10).protocolConfig(httpConf))
}
}
View
21 src/main/scala/IDEPathHelper.scala
@@ -3,18 +3,19 @@ import scala.tools.nsc.io.Path
object IDEPathHelper {
val gatlingConfUrl = getClass.getClassLoader.getResource("gatling.conf").getPath
- val projectRootDir = File(gatlingConfUrl).parents(2)
-
- val mavenSourcesDir = projectRootDir / "src" / "main" / "scala"
- val mavenResourcesDir = projectRootDir / "src" / "main" / "resources"
- val mavenTargetDir = projectRootDir / "target"
- //val mavenBinariesDir = mavenTargetDir / "classes"
+ val projectRootDir = File(gatlingConfUrl).parents(0)
+
+ val projectSourceDir = File(gatlingConfUrl).parents(3)
+
+ val mavenSourcesDir = projectSourceDir / "src" / "main" / "scala"
+ val mavenResourcesDir = projectSourceDir / "src" / "main" / "resources"
+ val mavenTargetDir = projectSourceDir / "target"
- val mavenBinariesDir = "/home/logos/Desktop/gatling-sbt/target/scala-2.9.2/classes"
+ val mavenBinariesDir = projectRootDir
- val dataFolder = mavenResourcesDir / "data"
- val requestBodiesFolder = mavenResourcesDir / "request-bodies"
+ val dataFolder = projectSourceDir / "userfiles/data"
+ val requestBodiesFolder = projectSourceDir / "userfiles/request-bodies"
val recorderOutputFolder = mavenSourcesDir
- val resultsFolder = mavenTargetDir / "gatling-results"
+ val resultsFolder = projectSourceDir / "results"
}
View
11 userfiles/data/user_credentials.csv
@@ -0,0 +1,11 @@
+username,password
+user1,password1
+user2,password2
+user3,password3
+user4,password4
+user5,password5
+user6,password6
+user7,password7
+user8,password8
+user9,password9
+user10,password10
View
11 userfiles/data/user_information.csv
@@ -0,0 +1,11 @@
+username,password,account_id
+user1,password1,4
+user2,password2,7
+user3,password3,10
+user4,password4,13
+user5,password5,17
+user6,password6,21
+user7,password7,23
+user8,password8,27
+user9,password9,29
+user10,password10,34
Please sign in to comment.
Something went wrong with that request. Please try again.