環境
準備
JMeterをダウンロードして展開します。
$ wget http://ftp.riken.jp/net/apache//jmeter/binaries/apache-jmeter-2.13.zip $ unzip apache-jmeter-2.13.zip $ chmod +x ./apache-jmeter-2.13/bin/jmeter
次にレポート作成ツールを準備します。
JMeterPluginsCMD Command Line Toolからダウンロードします。
$ wget http://jmeter-plugins.org/downloads/file/JMeterPlugins-Standard-1.2.1.zip
こちらはJMeterのlib/ext/
フォルダに置く必要があるので以下のように展開先を指定してください。
$ unzip JMeterPlugins-Standard-1.2.1.zip -d apache-jmeter-2.13/ Archive: JMeterPlugins-Standard-1.2.1.zip inflating: apache-jmeter-2.13/lib/ext/JMeterPlugins-Standard.jar inflating: apache-jmeter-2.13/lib/ext/CMDRunner.jar replace apache-jmeter-2.13/LICENSE? [y]es, [n]o, [A]ll, [N]one, [r]ename: N inflating: apache-jmeter-2.13/lib/ext/JMeterPluginsCMD.sh inflating: apache-jmeter-2.13/lib/ext/TestPlanCheck.bat inflating: apache-jmeter-2.13/lib/ext/JMeterPluginsCMD.bat inflating: apache-jmeter-2.13/lib/ext/TestPlanCheck.sh
テストシナリオ作成
GUIで作成してください。今回は以下の設定で作ります。作成したファイルをtest.jmx
とします。
設定項目 | 値 |
---|---|
スレッド数 | 100 |
Ramp-Up期間 | 10 |
ループ回数 | 100 |
それぞれの数値の関係ですが、以下のようになります。
項目 | 計算式 | 今回の値 |
---|---|---|
総テスト回数 | スレッド数×ループ回数 | 10,000 |
1秒あたりのリクエスト数 | 総テスト回数÷Ramp-Up | 1,000 |
テスト実行
単に標準出力で良い場合は以下の通りに実行します。スループットやMin, Maxが知りたいだけならこれだけでも十分です。
$ ./apache-jmeter-2.13/bin/jmeter -n -t test.jmx Creating summariser <summary> Created the tree successfully using test.jmx Starting the test @ Tue Apr 07 12:06:29 UTC 2015 (1428408389381) Waiting for possible shutdown message on port 4445 summary + 1 in 1s = 1.8/s Avg: 117 Min: 117 Max: 117 Err: 0 (0.00%) Active: 6 Started: 6 Finished: 0 summary + 9999 in 10s = 1052.4/s Avg: 0 Min: 0 Max: 132 Err: 0 (0.00%) Active: 0 Started: 100 Finished: 100 summary = 10000 in 10.1s = 993.2/s Avg: 0 Min: 0 Max: 132 Err: 0 (0.00%) Tidying up ... @ Tue Apr 07 12:06:39 UTC 2015 (1428408399567) ... end of run
median、90percentileの分かるレポート作成するためには各リクエストの結果を残す必要があります。以下のように.jtl
ファイルを作成してください。
$ ./apache-jmeter-2.13/bin/jmeter -n -t test.jmx -l result.jtl
レポート作成
先ほどの.jtl
ファイルを用いてレポートを作成します。レポートファイルをreport.csv
とします。
$ ./apache-jmeter-2.13/lib/ext/JMeterPluginsCMD.sh --generate-csv report.csv --input-jtl result.jtl --plugin-type AggregateReport
csvファイルが生成されるので、確認してみましょう。
$ column -s, -t < report.csv | less -N -S
medianや90percentileがわかるようになりました。