はじめに
Gatlingはレポートが見やすかったりと負荷テストをするのに便利ですね。
公式のGradleプラグインもあり、ドキュメントもしっかりしているので、Gradleからの実行も簡単です。
$ gradlew gatlingRun
とすれば、全てのSimulationを、
$ gradlew gatlingRun-foo.bar.fqcn.of.MySimulation
とすれば、任意のSimulationを個別に実行できます。
ただ、後者の実行方法が個人的にあまり好みでなく。。ハイフンとかドットとか優しくなくて、何かと阻害要因になりそう。。
なので、本記事では下記のようにシンプルなコマンドで実行するための方法を紹介します。
$ gradlew runMySimulation
公式ドキュメントの情報を読めば分かる方法ではあるものの、具体的なサンプルはなかったので忘れないように書いておきます。
Simulation実行用のGradleタスクを追加する
見出しの通り、単純にGradleタスクを追加すればいい話なのですが、細かいポイントを書いておきます。
build.gradleやプロジェクトの全体像は下記リポジトリにあります。
GitHub - norio-io/example-gatling-with-gradle: Example of stress test with Gatling
Example of stress test with Gatling. Contribute to norio-io/example-gatling-with-gradle development by creating an account on GitHub.
Gradleタスクとして追加しておくと、IDEAなどGUIのタスク一覧にも表示されるので、画面からぽちぽちクリックして実行できるので、自分のようなへなちょこGUI派には一石二鳥です。
参考
公式ドキュメント(Gradleプラグインによる使用方法)

Gradle Plugin
How to use the gradle plugin for Gatling to run tests and deploy them to Gatling Enterprise.
Gradleプラグインを使用した公式デモ
GitHub - gatling/gatling-gradle-plugin-demo: Showcase of the Gatling Plugin for Gradle
Showcase of the Gatling Plugin for Gradle. Contribute to gatling/gatling-gradle-plugin-demo development by creating an account on GitHub.
Gradleプラグイン(バージョン確認など)
Gradle - Plugin: io.gatling.gradle
コメント