Skip to content

@rsertelon /gist:1564504
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Benchmarks for Gatling: Gatling's simulation
val urlBase = "http://192.168.10.142:8080"
val httpConf = httpConfig.baseURL(urlBase)
val common_headers = Map(
"Accept-Charset" -> "ISO-8859-1,utf-8;q=0.7,*;q=0.3",
"Accept-Encoding" -> "gzip,deflate,sdch",
"Accept-Language" -> "en-US,en;q=0.8,fr;q=0.6",
"Host" -> "192.168.10.142:8080",
"User-Agent" -> "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.71 Safari/534.24")
val post_headers = Map(
"Content-Type" -> "application/x-www-form-urlencoded",
"Origin" -> "http://192.168.10.142:8080")
val ajax_headers = Map(
"Accept" -> "application/json, text/javascript, */*; q=0.01",
"X-Requested-With" -> "XMLHttpRequest")
val common_accept = ("Accept" -> "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5")
val cache_control_header = ("Cache-Control" -> "max-age=0")
val referer_login = ("Referer" -> "http://192.168.10.142:8080/excilys-bank-web/public/login.html")
val referer_operations = ("Referer" -> "http://192.168.10.142:8080/excilys-bank-web/private/bank/account/${acc1}/operations.html")
val referer_operations_transfer = ("Referer" -> "http://192.168.10.142:8080/excilys-bank-web/private/bank/account/${acc1}/transfers/operations.html")
val login_page_headers = common_headers + common_accept + cache_control_header
val authentication_headers = common_headers + common_accept + cache_control_header ++ post_headers + referer_login + ("Content-Length" -> "35")
val accounts_page_headers = common_headers + common_accept + cache_control_header + referer_login
val operations_headers = common_headers + common_accept + ("Referer" -> "http://192.168.10.142:8080/excilys-bank-web/private/bank/accounts.html")
val operations_data_headers = common_headers ++ ajax_headers + referer_operations
val cards_operations_headers = common_headers + common_accept + referer_operations
val cards_operations_data_headers = common_headers ++ ajax_headers + referer_operations_transfer
val transfer_viewing_headers = common_headers + common_accept + referer_operations_transfer
val perform_transfer_headers = common_headers + common_accept + cache_control_header ++ post_headers ++ Map(
"Referer" -> "http://192.168.10.142:8080/excilys-bank-web/private/bank/account/${acc1}/transfers/perform.html",
"Content-Length" -> "65")
val logout_headers = common_headers + common_accept + ("Referer" -> "http://192.168.10.142:8080/excilys-bank-web/private/bank/accounts.html?accountNumber=${acc1}&page=TRANSFER_PERFORM")
val scn = scenario("Test Gatling vs JMeter")
.feed(tsv("bank_users.tsv").random)
.exec(
http("Authentication page before login")
.get("/excilys-bank-web/public/login.html")
.headers(login_page_headers)
.check(regex("""<legend>Please log in</legend>""")))
.pause(5)
.exec(
http("Authentication")
.post("/excilys-bank-web/login")
.param("username", "${username}")
.param("password", "${password}")
.headers(authentication_headers)
.check(status.eq(302)))
.loop(
chain
.pause(100, MILLISECONDS)
.exec(
http("Accounts")
.get("/excilys-bank-web/private/bank/accounts.html")
.headers(accounts_page_headers)
.check(
regex("""<a href="/excilys-bank-web/private/bank/account/(ACC[0-9]*)/operations.html">""").find(0).saveAs("acc1"),
regex("""<a href="/excilys-bank-web/private/bank/account/(ACC[0-9]*)/operations.html">""").find(1).saveAs("acc2")))
.pause(5)
.exec(
http("Operations")
.get("/excilys-bank-web/private/bank/account/${acc1}/operations.html")
.headers(operations_headers)
.check(regex("""<td class="amount"><span class="figure green">(.*)</span>""")))
.pause(100, MILLISECONDS)
.exec(
http("Operations data")
.get("/excilys-bank-web/private/bank/account/${acc1}/year/2011/month/12/page/0/operations.json")
.headers(operations_data_headers))
.pause(5)
.exec(
http("Cards operations")
.get("/excilys-bank-web/private/bank/account/${acc1}/cards/all/operations.html")
.headers(cards_operations_headers))
.pause(100, MILLISECONDS)
.exec(
http("Cards operations data")
.get("/excilys-bank-web/private/bank/account/${acc1}/cards/all/year/2011/month/12/page/0/operations.json")
.headers(cards_operations_data_headers))
.pause(5)
.exec(
http("Transfers operations")
.get("/excilys-bank-web/private/bank/account/${acc1}/transfers/operations.html")
.headers(transfer_viewing_headers)
.check(regex("""<a href="/excilys-bank-web/private/bank/account/${acc1}/transfers/perform.html">""")))
.pause(100, MILLISECONDS)
.exec(
http("Transfers operations data")
.get("/excilys-bank-web/private/bank/account/${acc1}/transfers/page/0/operations.json")
.headers(transfer_viewing_headers))
.pause(5)
.exec(
http("Perform transfer")
.get("/excilys-bank-web/private/bank/account/${acc1}/transfers/perform.html")
.headers(transfer_viewing_headers)
.check(regex("""<legend>Perform a new transfer</legend>""")))
.pause(5)
.exec(
http("Performing transfer")
.post("/excilys-bank-web/private/bank/account/${acc1}/transfers/perform.html")
.param("debitedAccountNumber", "${acc1}")
.param("creditedAccountNumber", "${acc2}")
.param("amount", "100")
.headers(perform_transfer_headers)
.check(status.eq(302)))).times(20)
.pause(5)
.exec(
http("Logout")
.get("/excilys-bank-web/logout")
.headers(logout_headers)
.check(status.eq(302)))
.pause(100, MILLISECONDS)
.exec(
http("Authentication page after logout")
.get("/excilys-bank-web/public/login.html")
.headers(logout_headers)
.check(regex("""<legend>Please log in</legend>""")))
runSimulation(
scn.configure users (2000) ramp (200) protocolConfig httpConf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.