The gatling gradle plugin provides the ability to run gatling scenarios directly from a gradle build. The plugin utilizes the gatling cli provided by gatling.
The following gradle configuration will execute the gatling scenarios "MyAwesomeSimulation" and "MyCoolSimulation" using bodies in the "bodies" directory, data in the "data" directory, and the configuration file "resources/gatling.conf". Reports will be stores in the "reports" directory. The plugin will also check for KOed requests, and compare request times to previous request times.
apply plugin: 'scala'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.commercehub:gatling-gradle-plugin:1.0.+'
}
configurations.all {
// check for updates every build
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
repositories {
mavenCentral()
}
ext {
SCALA_VERSION = "2.11.7"
GATLING_VERSION = "2.2.0-M3"
}
dependencies {
compile "org.scala-lang:scala-library:${SCALA_VERSION}"
testCompile "io.gatling:gatling-http:${GATLING_VERSION}"
testCompile "io.gatling:gatling-core:${GATLING_VERSION}"
testCompile "io.gatling.highcharts:gatling-charts-highcharts:${GATLING_VERSION}"
testCompile "io.gatling:gatling-app:${GATLING_VERSION}"
}
apply plugin: 'gatling-plugin'
sourceSets {
test {
scala {
srcDirs 'simulations'
}
resources {
srcDirs 'resources'
}
}
}
gatlingTest {
gatlingVersion = '2.2.0-M3'
checkForKOs = true
koThreshold = 10
numberOfDaysToCheck = 5
graphiteUrl = "http://my.graphite.url.com"
gatlingSimulation = ['MyAwesomeSimulation', 'MyCoolSimulation']
metricsToCheck = ['Request_Name_1', 'Request_Name_2']
gatlingDataFolder = 'data'
gatlingBodiesFolder = 'bodies'
gatlingReportsFolder = 'reports'
gatlingConfFile = 'resources/gatling.conf'
}
Running the following command will execute the scenario:
gradle(w) gatlingTest
gatlingVersion
: Set the version of gatling to use. Defaults to 2.2.0-M3.checkForKOs
: Set whether or not to check for KOed requests. Defaults to true.koThreshold
: Number of KOs that will be allowed before the build is considered failed. Defaults to 0.numberOfDaysToCheck
: Number of previous days to compare the current run to. If this value is 0, no check will occur. Must be a positive integer. Defaults to 0.graphiteUrl
: The graphite base url.gatlingSimulation
: The list of scenarios to run.metricsToCheck
: The list of graphite metrics to check.gatlingDataFolder
: The directory containing gatling data files. Defaults to $projectRoot/datagatlingBodiesFolder
: The directory containing gatling bodies files. Defaults to $projectRoot/bodiesgatlingReportsFolder
: The directory where gatling reports will be dropped. Defaults to $projectRoot/reportsgatlingConfFile
: The gatling conf file to use. Defaults to $projectRoot/resources/gatling.confgraphiteMetricPrefix
: prefix to add to the graphite metric