ぺーぺーSEのブログ

備忘録・メモ用サイト。

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スクリプトによりチェックを行う。


MD5Hexアサーション(英語名:MD5Hex Assertion)

レスポンスデータのMD5ハッシュ値を計算し設定した値と比較する。


SMIME Assertion

Mail Reader Samplerの結果を検査する。


XML Schema Assertion

XML Schema(.xsd)に準拠しているか検査する。


XMLアサーション(英語名:XML Assertion)

サーバからの応答がXMLの構文に準拠してるかを検査する。DTDやXMLSchemaに基づいているかは検査しない。


Xpath Assertion(英語名:)

XPathによりフォーマットの検査を行う。


アサーション(英語名:Response Assertion)

サーバから応答された文字列を検査する。正規表現も使用可能。


アサーションの維持(英語名:Duration Assertion)

指定された時間内にサーバから応答があったかどうかを検査する。単位はミリ秒。


サイズアサーション(英語名:Size Assertion)

応答結果のバイトサイズを検査する。

参考:http://jmeter.apache.org/usermanual/component_reference.html#assertions