Gatling is a Scala-based high performance server performance testing tool that is used primarily for testing server workloads and analyzing and measuring various performance metrics for servers. Gatling is primarily used to measure HTTP-based servers, such as Web applications, restful services, and so on, in addition to the following features:
Supports Akka Actors and Async IO to achieve high performance
Enables real-time generation of HTML dynamic lightweight reports, making reports easier to read and analyze data
Support for DSL scripts to make test scripts easier to develop and maintain
Supports recording and generating test scripts, making it easy to generate test scripts
Support for importing Har (Http Archive) and generating test scripts
Support Maven,eclipse,intellij and so on to develop
Support for Jenkins for continuous integration
Plug-ins are supported to extend their functionality, such as the ability to extend support for other protocols
Open Source Free
Gatling applicable scenarios include: test requirements change frequently, test scripts need to be maintained frequently, test environment client performance is not strong, but also want to play the ultimate hardware performance, the test script can be very good version management, and through CI for continuous performance testing, hope that the test results are lightweight and easy to read.
Other Detailed: http://www.infoq.com/cn/articles/new-generation-server-testing-tool-gatling/
Using the Installation
Latest Version 2.0.1
SBT build "io.gatling.highcharts"% "gatling-charts-highcharts"% "2.0.1" (Guthub should save the build template)
Relatively simple installation, according to their own system to download the appropriate ZIP package, extracted to the installation directory, configuration system environment variable Gatling_home (WIN)
After the environment variable is configured, there is a gatling.bat or gatling.sh run script under the directory bin, which prompts the user to select a test script after successful run
After successful operation, this test data will be generated in/$gatling/results: Graph, request response time and so on to view the results statistics conveniently.
Tips for use:
Currently using Gatling 1.5.6 version of the majority, but with the 2.0.1 version changes are significantly different, add features such as DSL, specific details
See also: http://gatling.io/docs/2.0.1/project/migration_guides/1.5.x-to-2.0.html#x-to-2-0
API DOC:HTTP://GATLING.IO/DOCS/2.0.1/
Problems encountered in use:
Q: How to append request parameters to a request
A: For Scala, you can use Queryparammap (Map[string,any]) to increase request parameters (a GET request can convert a Map to a string of k=v) and, of course, a single argument Queryparam (String, String), etc., refer to: query-parameters
Q: The result of the request needs to be detected or verified
A: Use Check (status.is), check (Regex ("" "<.*>" ""). Findall.exsits)
Q: How do I manipulate the results of a response after a request? Action: Set the result to the session?
A: The above example will be more clear, case description: Get all the topics users like to request the corresponding ID according to each topic ID recommendation
val ranking = scenario ("Just Test Userlike")
. EXEC (http ("Userliketopic"). Get ("User/general_men/like.json"). Queryparammap (params)
. Check (status.is, JsonPath ("$.datas[*]"). Oftype[map[string,any]]//jsonpath
. Findall.saveas ("Liketopics")). foreach ("${liketopics}", "topics") {
EXEC (Session = {
Val topics = Session ("Topics"). As[map[string, any]]
session.set ("CID", Topics ("CID"))
})
Pause (2, 5)
. EXEC (http ("ranking") Get ("Topic/${cid}/rankings.json") Queryparammap (params)//Can be changed to page request
}
Setup (Ranking.inject (atonceusers (1)). Protocols (httpconf))//Set a user request setting greater than 1 o'clock, refers to n users concurrent access, of course, Gatling also provides another configuration to resolve, " Multi-user but not concurrent access "inject (Rampusers (n) over (n times))
Follow the finishing ...
Gatling Test Tool Learning