JMeterまとめ
徐々に追加していく。
バージョンは2.9。
コマンドライン実行
■サンプルjmeter.bat -n -t sample.jmx -l result.jtl
※Windowsは「jmeter.bat」、Linuxは「jmeter.sh」
■オプション
オプション | 説明 |
---|---|
-n | コマンドライン実行を有効化 |
-t | シナリオを記録したjmxファイルを指定 |
-l | 実行結果を出力するファイルを指定 |
-j | JMeterの実行ログを出力するファイルを指定 |
-r | Run the test in the servers specified by the JMeter property "remote_hosts" |
-R | [list of remote servers] Run the test in the specified remote servers |
-H | プロキシサーバのホスト名orIPアドレス |
-P | プロキシサーバのポート番号 |
参考:http://jmeter.apache.org/usermanual/get-started.html#non_gui
結果だけGUIで見る方法もある。
→参考:http://d.hatena.ne.jp/yuheiomori0718/20130206/1360161748
アサーション
BeanShellアサーション(英語名:BeanShell Assertion)
BeanShellスクリプトにより検査する。
BeanShellはほぼJava文法のスクリプト。
下記のようにコードを書く。
if (ResponseCode != null && ResponseCode.equals ("200") == false ) { Failure = true; FailureMessage = "HTTPリクエスト失敗"; } else { try { byte [] array = (byte[]) ResponseData; String xx = new String(array, "UTF-8"); print (xx + "\n"); if (array.length < 5000) { Failure = true; FailureMessage = "応答サイズが5000バイト未満です"; } } catch (Throwable t ) { print ( array ); } }
「print」は標準出力(JMeterを起動したDOSとか)へ、「FailureMessage」は「Failure == true」の時の「アサート結果」へ出力される。
リターンコードを残して終わるのもあり?
参考:http://www.geocities.jp/maakun_gemini_ab/contents/pc/terminating_commands.html
BSF Assertion
BSFスクリプトにより検査する。
Compare Assertion
1つ前のテストと比較する。
HTML Assertion
レスポンスデータのHTMLをJTidyにより検査する。
JSR223 Assertion
JSR223スクリプトによりチェックを行う。
SMIME Assertion
Mail Reader Samplerの結果を検査する。
XML Schema Assertion
XML Schema(.xsd)に準拠しているか検査する。
アサーションの維持(英語名:Duration Assertion)
指定された時間内にサーバから応答があったかどうかを検査する。単位はミリ秒。
サイズアサーション(英語名:Size Assertion)
応答結果のバイトサイズを検査する。
参考:http://jmeter.apache.org/usermanual/component_reference.html#assertions