Your SlideShare is downloading. ×
Gatling @ Scala.Io 2013
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Gatling @ Scala.Io 2013

3,228
views

Published on

Gatling

Gatling


0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,228
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
39
Comments
0
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Gatling 2, What’s up Doc? by Stéphane Landelle @slandelle
  • 2. Quick Introduction / Reminder about
  • 3. What’s Gatling? •  Stress Test Tool •  Scala + Akka +Netty •  Scenarios = code + DSL
  • 4. Scenario val scn = scenario("Scala.Io DoS") .repeat(10000) { exec(http("Scala.Io").get("http://scala.io")) } setUp( scn.inject(rampUsers(10000) over 30 seconds) )
  • 5. Scenario = Actor Workflow Start Actor Http Request Actor Session Repeat Actor End Actor Async Handler Actor
  • 6. Scenario = Actor Workflow Start Actor Repeat Actor End Actor Session Http Request Actor Async Handler Actor
  • 7. Scenario = Actor Workflow Start Actor Repeat Actor End Actor Session Http Request Actor Async Handler Async Handler Actor
  • 8. Scenario = Actor Workflow Start Actor Http Request Actor End Actor Repeat Actor Session Async Handler Async Handler Actor
  • 9. Scenario = Actor Workflow Start Actor End Actor Repeat Actor Session Http Request Actor Async Handler Actor
  • 10. Scenario = Actor Workflow Start Actor Http Request Actor Session Repeat Actor End Actor Async Handler Actor
  • 11. Timeline •  Mid 2011: o  Start developing Gatling o  No Scala background •  End 2012: o  Better Scala skills o  Community feedback o  Need for open APIs Time to clean this up!
  • 12. Gatling 2! •  Planned for 2014: o  Tons of refactoring o  Tons of new features •  Sorry folks, we’re late: o  Greater good: stability •  Milestones: o  Current M3 o  Next M4 november/december
  • 13. New Expression API
  • 14. Expression in Gatling 1 type Expression = Session => String implicit def toExpression(s: String): Expression http("Foo").get("https://www.google.fr/search?q=${term}")
  • 15. Gatling 1 issues o  What if “term” is undefined? o  What if “term” is of wrong type? repeat("${times}") {} // Expects Int foreach("${seq}”) {} // Expects Seq è Unsafe, deal with Exceptions, not generic
  • 16. Validation Validation[+T] -  map -  flatMap Success[+T] (value: T) Failure (message: String)
  • 17. Usage: Building a request flatMap that s**t! buildURI(httpAttributes.urlOrURI) .flatMap(configureQueryCookiesAndProxy) .flatMap(configureVirtualHost) .flatMap(configureHeaders) .flatMap(configureRealm)
  • 18. New Expression API type Expression[T] = Session => Validation[T] implicit def toExpression[T](s: String): Expression[T]
  • 19. New Session API val foo: Validation[T] = session("foo").validate[T] // unsafe: val bar: T = session("foo").as[T] val baz: Option[T] = session("foo").asOption[T]
  • 20. New Templating API
  • 21. Templating API in Gatling 1 •  (Session => String) / Expression: o  Function o  Implicitly compiled EL String •  Scalate SSP
  • 22. Scalate SSP o  Can have complex logic o  Scala compiler in the background (overhead, proper stop) o  Own API, learning curve o  Does play well with Session API Why do we need this anyway?
  • 23. New Templating API: the EL way Embedded // passing an EL String setBody(StringBody("""{ foo: "${foo}", bar: ${bar} }""")
  • 24. New Templating API: the EL way External EL based text file // passing an EL File setBody(ELFileBody("body.txt")) { foo: "${foo}", bar: ${bar} }
  • 25. New Templating API: the EL way o  Simple o  Limited, can’t implement complex logic
  • 26. Why do we need non-Scala templates anyway?! We’re not in JSP world! We have multiline Strings and macros!
  • 27. String interpolation val jsonTemplate: Expression[String] = session => for { foo <- session("foo").validate[String] bar <- session("bar").validate[Int] } yield s"""{ foo: "$foo", bar: $bar }"""
  • 28. String interpolation o  Pure Scala o  Compile time, not runtime o  Standard Scala library o  Requires a bit more Scala skills o  Complex logic => intermediate String concatenations
  • 29. Fastring https://github.com/Atry/fastring •  StringBuilder underneath •  Produces Fastrings, not Strings
  • 30. Fastring val jsonTemplate: Expression[String] = session => for (foos <- session("foos").validate[Seq[String]]) yield fast"""{ foos = [ ${foos.map(foo => fast"""{foo: "$foo"}""").mkFastring("n")} ] }""".toString
  • 31. Checks improvements
  • 32. Regex check in Gatling 1 regex("foo(.*)bar").saveAs("baz") è produces Strings è no more than 1 capture group
  • 33. Issue <form> <input type="hidden" name="foo" value="foo" /> <input type="hidden" name="bar" value="baz" /> </form> è workaround: 2 regex + manual zip
  • 34. Tuple support We need: String (String, String) (String, String, String) (String, String, String, String) … But generic, please…
  • 35. Type class FTW regex[T](pattern: Expression[String]) (implicit groupExtractor: GroupExtractor[T]) object GroupExtractor { implicit val groupExtractor2: GroupExtractor[(String, String)] = ??? } trait GroupExtractor regex[(String, String)]("foo(.*)bar(.*)baz")
  • 36. Also for •  headerRegex[T] T of String, Tuple2[String] , Tuple3[String]… •  jsonPath[T] T of Int, Long, Double, Float, String, List, Map •  XPath? •  CSS selectors?
  • 37. Resource fetching
  • 38. Gatling 1 HTML page Resource 1 Resource 2 Sequential workflow Resource 3
  • 39. Not how browsers work Resource 1 HTML page Resource 2 Resource 3 Parallel workflow
  • 40. Very complex actually 1. Fetch HTML 2. Fetch HTML embedded resources 3. Fetch some additional resources (CSS @import) 4. Fetch matching CSS rules resources (@font-face, background-image) 5. … (not accounting for javascript) è Can’t be perfect without being a browser è Will have to approximate
  • 41. Kind of scatter-gather pattern Fetch resources HTML page Session + HTML Resource Fetcher Actor New Session Beware of Session reconciliation! Next
  • 42. DSL exec( http(“Page").get("http://foo.com") .resources( http(“Ajax1").get("http://foo.com/ajax1"), http(“Ajax2").get("http://foo.com/ajax2") .check(regex("foo(.*)bar").saveAs("baz")) ) )
  • 43. And many more to come… Q/A? @GatlingTool http://gatling-tool.org https://github.com/excilys/gatling