のえら

技術備忘とかメモとか.間違いはつっこんでいただきたい所存.

Gatlingを使ってみる セット編

負荷テストのツール Gatling を使ってみた。
セットアップにごにょごにょしてしまったのでメモライズ

2.1.x は Java のバージョン8でしか使えません、というお話。

公式サイトから本体をDLして、任意のディレクトリに展開する。

Gatling Load and Performance testing - Open-source load and performance testing

展開したディレクトリに移動して、テスト実行スクリプトを呼び出す。
と、バージョンによっては以下のエラーが表示される。

cd gatling-charts-highcharts-bundle-2.1.7
sh bin/gatling.sh

Java9(or 6)

GATLING_HOME is set to /Users/akirasan/work/gatling-charts-highcharts-bundle-2.1.7
intx ThreadPriorityPolicy=42 is outside the allowed range [ 0 ... 1 ]
Improperly specified VM option 'ThreadPriorityPolicy=42'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Java7

GATLING_HOME is set to /Users/akirasan/work/gatling-charts-highcharts-bundle-2.1.7
Exception in thread "main" java.lang.UnsupportedClassVersionError: io/gatling/app/Gatling : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

java8

起動するとどのシミュレータを実行するか尋ねられるので選択。
*デフォルトでサンプルが6つ入っているので試しに一番を実行

GATLING_HOME is set to /Users/akirasan/work/gatling-charts-highcharts-bundle-2.1.7
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
1
Select simulation id (default is 'advancedsimulationstep01'). Accepted characters are a-z, A-Z, 0-9, - and _

Select run description (optional)

Simulation computerdatabase.advanced.AdvancedSimulationStep01 started...

================================================================================
2018-03-09 19:19:12                                           0s elapsed
---- Scenario Name -------------------------------------------------------------
[                                                                          ]  0%
          waiting: 1      / active: 0      / done:0
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=0      KO=0     )

================================================================================


================================================================================
2018-03-09 19:19:16                                           5s elapsed
---- Scenario Name -------------------------------------------------------------
[--------------------------------------------------------------------------]  0%
          waiting: 0      / active: 1      / done:0
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=4      KO=0     )
> Home                                                     (OK=1      KO=0     )
> Home Redirect 1                                          (OK=1      KO=0     )
> Search                                                   (OK=1      KO=0     )
> Select                                                   (OK=1      KO=0     )
================================================================================


================================================================================
2018-03-09 19:19:22                                          10s elapsed
---- Scenario Name -------------------------------------------------------------
[--------------------------------------------------------------------------]  0%
          waiting: 0      / active: 1      / done:0
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=8      KO=0     )
> Home                                                     (OK=2      KO=0     )
> Home Redirect 1                                          (OK=2      KO=0     )
> Search                                                   (OK=1      KO=0     )
> Select                                                   (OK=1      KO=0     )
> Page 1                                                   (OK=1      KO=0     )
> Page 2                                                   (OK=1      KO=0     )
================================================================================


================================================================================
2018-03-09 19:19:27                                          15s elapsed
---- Scenario Name -------------------------------------------------------------
[--------------------------------------------------------------------------]  0%
          waiting: 0      / active: 1      / done:0
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=10     KO=0     )
> Home                                                     (OK=2      KO=0     )
> Home Redirect 1                                          (OK=2      KO=0     )
> Search                                                   (OK=1      KO=0     )
> Select                                                   (OK=1      KO=0     )
> Page 1                                                   (OK=1      KO=0     )
> Page 2                                                   (OK=1      KO=0     )
> Page 3                                                   (OK=1      KO=0     )
> Page 4                                                   (OK=1      KO=0     )
================================================================================


================================================================================
2018-03-09 19:19:31                                          19s elapsed
---- Scenario Name -------------------------------------------------------------
[##########################################################################]100%
          waiting: 0      / active: 0      / done:1
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=13     KO=0     )
> Home                                                     (OK=2      KO=0     )
> Home Redirect 1                                          (OK=2      KO=0     )
> Search                                                   (OK=1      KO=0     )
> Select                                                   (OK=1      KO=0     )
> Page 1                                                   (OK=1      KO=0     )
> Page 2                                                   (OK=1      KO=0     )
> Page 3                                                   (OK=1      KO=0     )
> Page 4                                                   (OK=1      KO=0     )
> Form                                                     (OK=1      KO=0     )
> Post                                                     (OK=1      KO=0     )
> Post Redirect 1                                          (OK=1      KO=0     )
================================================================================

Simulation finished
Parsing log file(s)...
Parsing log file(s) done
Generating reports...

================================================================================
---- Global Information --------------------------------------------------------
> request count                                         13 (OK=13     KO=0     )
> min response time                                    287 (OK=287    KO=-     )
> max response time                                   1121 (OK=1121   KO=-     )
> mean response time                                   452 (OK=452    KO=-     )
> std deviation                                        242 (OK=242    KO=-     )
> response time 50th percentile                        333 (OK=333    KO=-     )
> response time 75th percentile                        540 (OK=540    KO=-     )
> mean requests/sec                                  0.683 (OK=0.683  KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                            11 ( 85%)
> 800 ms < t < 1200 ms                                   2 ( 15%)
> t > 1200 ms                                            0 (  0%)
> failed                                                 0 (  0%)
================================================================================

Reports generated in 0s.
Please open the following file: results/advancedsimulationstep01-1520590751977/index.html

実行結果は results ディレクトリの配下に保存される。

open results/advancedsimulationstep01-1520590751977/index.html