インストール
GatlingはScalaで書かれていて、Java VM上で動作します。 そのため、まずJavaをインストールします。
-
Gatlingインストール
Javaが使用できる環境が用意できたらGatlingを入手します。 ダウンロードは、以下の公式ダウンロードページから行います。
2018年2月時点の最新版をcurlでダウンロードする場合は、以下のようになります。
curl -O https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.3.0/gatling-charts-highcharts-bundle-2.3.0-bundle.zip
zipファイルがダウンロードできたら、解凍します。
unzip gatling-charts-highcharts-bundle-2.3.0-bundle.zip
解凍が完了したら以下のようなディレクトリが作成されています。
gatling-charts-highcharts-bundle-2.3.0このディレクトリ移動して中身を確認すると以下のようになっています。
$ ls -al 合計 20 drwxr-xr-x 7 vagrant vagrant 82 8月 30 19:15 . drwx------. 17 vagrant vagrant 4096 2月 4 11:36 .. -rw-r--r-- 1 vagrant vagrant 11367 8月 30 19:15 LICENSE drwxr-xr-x 2 vagrant vagrant 78 8月 30 19:15 bin drwxr-xr-x 2 vagrant vagrant 87 8月 30 19:15 conf drwxr-xr-x 3 vagrant vagrant 4096 8月 30 19:15 lib drwxr-xr-x 2 vagrant vagrant 18 8月 30 19:15 results drwxr-xr-x 5 vagrant vagrant 48 8月 30 19:15 user-files
動作確認
インストールが完了したら、Gatlingが実行できる環境になっているかテストします。 Gatlingのディレクトリに移動後、Linuxでは以下を実行します。
bin/gatling.sh以下のように表示されて入力待ちになれば実行できる環境になっています。 以下のようにならない場合は何らかの問題があるので原因を見つけて対処します。
$ cd gatling-charts-highcharts-bundle-2.3.0
$ bin/gatling.sh
GATLING_HOME is set to /home/vagrant/gatling-charts-highcharts-bundle-2.3.0
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
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
注意. OpenJDKの場合は、GCの並列処理を使用しない( -XX:ParallelGCThreads=N )ようにという警告が表示されますが、特別に設定していなければ無視します。
0を入力してcomputerdatabase.BasicSimulationを選択します。 するともう一度入力を求められるので、Enterキーを押します。
0 Select simulation id (default is 'basicsimulation'). Accepted characters are a-z, A-Z, 0-9, - and _さらにオプションの入力を求められますので、Enterキーを押します。
Select run description (optional)
すると負荷試験が始まります。 以下のようになったらOKです。
Simulation computerdatabase.BasicSimulation started...
================================================================================
2018-02-12 19:16:22 5s elapsed
---- Requests ------------------------------------------------------------------
> Global (OK=2 KO=0 )
> request_1 (OK=1 KO=0 )
> request_1 Redirect 1 (OK=1 KO=0 )
---- Scenario Name -------------------------------------------------------------
[--------------------------------------------------------------------------] 0%
waiting: 0 / active: 1 / done:0
================================================================================
...
...
Simulation computerdatabase.BasicSimulation completed in 27 seconds
Parsing log file(s)...
Parsing log file(s) done
Generating reports...
================================================================================
---- Global Information --------------------------------------------------------
> request count 13 (OK=13 KO=0 )
> min response time 272 (OK=272 KO=- )
> max response time 1161 (OK=1161 KO=- )
> mean response time 390 (OK=390 KO=- )
> std deviation 242 (OK=242 KO=- )
> response time 50th percentile 283 (OK=283 KO=- )
> response time 75th percentile 294 (OK=294 KO=- )
> response time 95th percentile 797 (OK=797 KO=- )
> response time 99th percentile 1088 (OK=1088 KO=- )
> mean requests/sec 0.464 (OK=0.464 KO=- )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms 12 ( 92%)
> 800 ms < t < 1200 ms 1 ( 8%)
> t > 1200 ms 0 ( 0%)
> failed 0 ( 0%)
================================================================================
Reports generated in 0s.
Please open the following file: /home/vagrant/gatling-charts-highcharts-bundle-2.3.0/results/basicsimulation-1518430577627/index.html
結果のHTMLファイルを開いて、以下のようになっていればOKです。
