è² è·ãã¹ããã¼ã«Gatlingã触ã£ã¦ã¿ã
è² è·ãã¼ã«ã¨ãã¦Gatlingã®ãã¨ãå°ãåããè³ã«ããæ©ä¼ãå¢ããã®ã§ãå©ç¨ãã¦ã¿ããã¨ã«ããã
è²ã æ¢åºã ã¨ã¯æãããå ¬å¼ã®Quickstartã«å¾ã£ã¦è©¦ãã¦ã¿ãã®ã§ã¡ã¢ã
GUIãå¿ è¦ã ã£ãã®ã§ãä»åã¯æå ã®Macã§å®è¡ã
Gatlingã¨ã¯
Java/Scala製ã®è² è·ãã¹ããã¼ã«ã
JMaterã¨ä¼¼ãæãã®ãã¼ã«ã§ã¯ãããã
- ãã¤ããã©ã¼ãã³ã¹
- è¦ãããã¬ãã¼ãHTML
- developerãã¬ã³ããªã¼ãªã·ããªãªãã¡ã¤ã«
ã¨ããã®ãã¦ãªã¨ãã¦è¬³ã£ã¦ããã
ãã¶ãã3é ç®ã¨ã対JMater(éãã»ã¬ãã¼ãè¦ã¥ããã»XMLã®ã·ããªãªã¤ãã)ãæèããã¡ãªããã ãããªã¼ã
ãªããã·ããªãªãã¡ã¤ã«ã¯ããã
Gatling simulation scripts are written in Scala, but donât panic!
ãããã
ã¨ããããã§ã触ã£ã¦ã¿ã
Install
Javaã¨Galingãã¤ã³ã¹ãã¼ã«ãããGatlingã¯unzipããã ãã
% brew cask install java % wget https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.1.6/gatling-charts-highcharts-bundle-2.1.6-bundle.zip % unzip gatling-charts-highcharts-bundle-2.1.6-bundle.zip
ã·ããªãªã®ä½æ
ãã¹ãã·ããªãª
ã¾ãæåã«ããã¹ãã·ããªãªã決ããããã¥ã¼ããªã¢ã«ã«å¾ã£ã¦ä»¥ä¸ã®ã¨ããã
測å®å¯¾è±¡ã¨ããã®ã¯ http://computer-database.herokuapp.com/ ã¨ãããã¼ã¸
- ããã¯ãããããªPCçã³ã³ãã¥ã¼ã¿ã®ã¢ãã«æ å ±ãç»é²ããCGMçãªãµã¤ã
- Play framework製ï¼
- èªåã®ãã¼ã«ã«ã§åããã¦ããã https://github.com/playframework/playframework/tree/2.2.x/samples/scala/computer-database
ãªã¢ã«ãªã¦ã¼ã¶ã¼ã®ã·ããªãªã¨ãã¦ã以ä¸ã®æ§ãªæ³å®ã§ãã¹ããã
- ã¦ã¼ã¶ã¼ãã¢ããªã±ã¼ã·ã§ã³ã«ã¢ã¯ã»ã¹
-
mackbook
ã§æ¤ç´¢ - é¢é£ããã¢ãã«ãéã
- homeãã¼ã¸ã«æ»ã
- ãããç¹°ãè¿ã
- ã¦ã¼ã¶ã¼ãæ°ããã¢ãã«ãç»é²ãã
Gatling Recorderã«ããã·ããªãªã®è¨é²
ã·ããªãªã®ä½æã«ã¯ãGatling Recorderã使ãã
Gatling Recorderã¯ãproxyãéãã¦ãã©ã¦ã¶ã¢ã¯ã»ã¹ãã¦è¨é²ãåãã¨ã§ãScalaã§æ¸ãããã·ããªãªãã¡ã¤ã«ãèªåçæãã¦ããããã¼ã«ã
ãã¡ãããèªåã§Scalaãæ¸ãã¦ã·ããªãªä½ãããã¦ãè¯ãããä»åã¯æ軽ã«ã§ããproxyå¼ã®ææ³ãã¨ãã
èµ·åã¨è¨å®
Gatling Recorderãèµ·åããã
% cd gatling-charts-highcharts-bundle-2.1.6 % bin/recorder.sh
ãã¼ã«ãèµ·åããããåæè¨å®ã¨ãã¦ä»¥ä¸ã®ããã«é ç®ãåããã
ãã®ç¶æ ã§ãWebãããã·ã¨ãã¦Gatling Recorderãè¨å®ããã
ãã©ã¦ã¶ã¢ã¯ã»ã¹ã§ã·ããªãªãä½ã
Start
ãæ¼ãã¨è¨å®ã«å¾ã£ã¦proxyãèµ·åããã®ã§ããã©ã¦ã¶ã§ã¢ã¯ã»ã¹ããªããè¨é²ãåãã
ã·ããªãªä½ææã®Tipsã¨ãã¦ãå¤ãªpluginãªã©ã®å½±é¿ããªãããã«secret windowã§ããã¨ããæ°ã ã¾ããGatling Recorderã«ã¯ãã°ã®éã«TAGãå·®ãè¾¼ãæ©è½ããããã·ããªãªã®è¨é²ã綺éºã«ãªãã®ã§ãããæ´»ç¨ããã¨ããã
ã¨ãããã¨ã§ã以ä¸ã®æµãã§æä½ãè¨é²ããã
- Recorderå´ã§
Search
ã¿ã°ã追å - ãã©ã¦ã¶ã§http://computer-database.herokuapp.com/ ã®ãããã«ç§»å
mackbook
ã§æ¤ç´¢Macbook Pro
ãBrowse
ã¿ã°ã追å- http://computer-database.herokuapp.com/ ã®ãããã«æ»ã
- ä½åã
Next
ãã¿ã³ã§é·ç§» - ããã¤ããã¼ã¸ãéãã¦ã¿ã
Edit
ã¿ã°ã追å- http://computer-database.herokuapp.com/ ã®ãããã«æ»ã
Add new computer
ãæ¼ã- (ãã¥ã¼ããªã¢ã«ã§ã¯ãã£ã¨ãããã©ãããã¾ã§ã«ãã)
ããã¾ã§å®è¡ãçµãã£ãããStop & Save
ãæ¼ãã¨ãuser-files/simulations/computerdatabase/BasicSimulation.scala
ã«ã·ããªãªãã¡ã¤ã«ãä¿åãããã
å 容ã¯ä»¥ä¸ã®ããã«ãªã£ãã
package computerdatabase import scala.concurrent.duration._ import io.gatling.core.Predef._ import io.gatling.http.Predef._ import io.gatling.jdbc.Predef._ class BasicSimulation extends Simulation { val httpProtocol = http .baseURL("http://computer-database.herokuapp.com") .inferHtmlResources(BlackList(""".*\.css""", """.*\.js""", """.*\.ico"""), WhiteList()) .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") .acceptEncodingHeader("gzip, deflate, sdch") .acceptLanguageHeader("ja,en-US;q=0.8,en;q=0.6") .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.39 Safari/537.36") val uri1 = "http://computer-database.herokuapp.com" val scn = scenario("BasicSimulation") // Search .exec(http("request_0") .get("/")) .pause(5) .exec(http("request_1") .get("/computers?f=macbook")) .pause(2) .exec(http("request_2") .get("/computers/6")) .pause(10) // Browse .exec(http("request_3") .get("/")) .pause(2) .exec(http("request_4") .get("/computers?p=1") .resources(http("request_5") .get(uri1 + "/computers?p=2"), http("request_6") .get(uri1 + "/computers?p=3"))) .pause(2) .exec(http("request_7") .get("/computers/72")) .pause(1) .exec(http("request_8") .get("/")) .pause(1) .exec(http("request_9") .get("/computers?p=1") .resources(http("request_10") .get(uri1 + "/computers?p=2"))) .pause(3) .exec(http("request_11") .get("/computers/70")) .pause(10) // Edit .exec(http("request_12") .get("/")) .pause(1) .exec(http("request_13") .get("/computers/new")) setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol) }
以ä¸ã§ã·ããªãªã®ä½æã¯å®äºã
ãã¹ãã®å®è¡
ä»ã®ã·ããªãªãå ã«ãGatlingãèµ·åãã
% bin/gatling.sh
ãã°ãå¾ ã¤ã¨ãå®è¡åè£ã¨ãªãã·ããªãªã®ä¸è¦§ãåºã¦ããã®ã§ã対象ãé¸ã¶ã(ä»åã¯0) ãªããBasicSimulation以å¤ã®åè£ã¯ãå ã å«ã¾ãã¦ãããµã³ãã«ã
ãã®ä»ã®è³ªåãã¨ããããEnterãã¦å®è¡ããã
Choose a simulation number: [0] computerdatabase.BasicSimulation [1] computerdatabase.advanced.AdvancedSimulationStep01 [2] computerdatabase.advanced.AdvancedSimulationStep02 [3] computerdatabase.advanced.AdvancedSimulationStep03 [4] computerdatabase.advanced.AdvancedSimulationStep04 [5] computerdatabase.advanced.AdvancedSimulationStep05 0 Select simulation id (default is 'basicsimulation'). Accepted characters are a-z, A-Z, 0-9, - and _ Select run description (optional) Simulation computerdatabase.BasicSimulation started...
ããã¨ãã¹ããå®è¡ãããæçµçã«çµæãåºåããã
================================================================================ ---- Global Information -------------------------------------------------------- > request count 18 (OK=18 KO=0 ) > min response time 191 (OK=191 KO=- ) > max response time 414 (OK=414 KO=- ) > mean response time 217 (OK=217 KO=- ) > std deviation 64 (OK=64 KO=- ) > response time 50th percentile 195 (OK=195 KO=- ) > response time 75th percentile 197 (OK=197 KO=- ) > mean requests/sec 0.441 (OK=0.441 KO=- ) ---- Response Time Distribution ------------------------------------------------ > t < 800 ms 18 (100%) > 800 ms < t < 1200 ms 0 ( 0%) > t > 1200 ms 0 ( 0%) > failed 0 ( 0%) ================================================================================ Reports generated in 0s. Please open the following file: results/basicsimulation-1434181826508/index.html
çµæã®ç¢ºèª
results/basicsimulation-1434181826508/index.html
ã«ã¬ãã¼ããåºåããããããªã®ã§ãè¦ã¦ã¿ã
% open results/basicsimulation-1434181826508/index.html
æã£ã以ä¸ã«ãªãããªã¬ãã¼ããåºåããã¦ãã¦ãå ¨ä½ã®rpsã®ç¶æ³ãæå失æã®ã°ã©ããåãªã¯ã¨ã¹ããã¨ã®è©³ç´°ãªæ å ±ããã¼ã»ã³ã¿ã¤ã«å¤ãªã©ãåºãã
ä»åã®ãã¹ãã¯åä½ãã§ãã¯ç¨åº¦ãªã®ã§å¤§ããã°ã©ãã«ãªã£ã¦ããªãããããã¯ã¾ããã«è² è·ãã¹ãããã¨ãããè¯ãããã æ©ä¼ããã£ããããããã¯ãå´ã§ä½¿ã£ã¦ã¿ããã