- Plugin versioning scheme
-
Since version 3.0.0 the plugin strictly follows
Gatling
versioning, where the major and minor versions of the plugin are always identical toGatling
's major and minor version. - Gradle version
-
Minimal supported
Gradle
version is 4.0. - Scala version
-
Gatling
uses Scala version 2.12 since version 3.0.0, so the plugin does. - Source code layout
-
Since
Gatling
3.0.0 and corresponding plugin version 3.x.x there were breaking changes for source code layout. Check corresponding section of this README for details and original Gatling issue explaining the scope of changes.
đź’ˇ
|
For those who are familiar with |
The plugin provides bootstrap script that creates sample project with:
-
minimal
build.gradle
leveraging Gradle wrapper -
latest version of this plugin applied
-
proper source file layout
-
sample Simulation class, demonstrating sufficient
Gatling
functionality
For this quickstart - git
and curl
must be instlled and available in $PATH
.
curl -sL https://git.io/Jf2Uk | bash -s ~/sample-gradle-gatling
cd ~/sample-gradle-gatling
./gradlew gatlingRun
-
Install Gradle
-
Create a new project directory, and a file name
build.gradle
within it -
Follow Gradle Plugin Portal instructions.
Plugin creates dedicated Gradle sourceSet named gatling
.
This source set is used for storing simulations and Gatling
configs.
Following directories are configured by default.
Directory | Purpose |
---|---|
|
Simulation sources (Scala code) |
|
Resources (feeders, configuration, bodies, etc) |
Using Gradle
API file locations can be customized.
sourceSets {
gatling {
scala.srcDir "folder1" (1)
// or
scala.srcDirs = ["folder1"] (2)
resources.srcDir "folder2" (3)
// or
resources.srcDirs = ["folder2"] (4)
}
}
-
append
folder1
as an extra simulations folder. -
use
folder1
as a single source of simulations. -
append
folder2
as an extraGatling
resources folder. -
use
folder2
as a single source ofGatling
resources.
The plugin defines the following extension properties in the gatling
closure
Property name | Type | Default value | Description |
---|---|---|---|
toolVersion |
String |
'3.3.1' |
|
logLevel |
String |
'WARN' |
The default Gatling console log level if no |
includeMainOutput |
Boolean |
true |
Include main source set output to gatlingImplementation |
includeTestOutput |
Boolean |
true |
Include test source set output to gatlingImplementation |
scalaVersion |
String |
'2.12.8' |
|
jvmArgs |
List<String> |
['-server', '-Xmx1G',
'-XX:+UseG1GC', '-XX:MaxGCPauseMillis=30',
'-XX:G1HeapRegionSize=16m',
'-XX:InitiatingHeapOccupancyPercent=75',
'-XX:+ParallelRefProcEnabled',
'-XX:+PerfDisableSharedMem',
'-XX:+AggressiveOpts',
'-XX:+OptimizeStringConcat',
'-XX:+HeapDumpOnOutOfMemoryError'] |
Additional arguments passed to JVM when executing |
systemProperties |
Map<String, Object> |
['java.net.preferIPv4Stack': true,
'java.net.preferIPv6Addresses': false] |
Additional systems properties passed to JVM together with caller JVM system properties |
simulations |
Closure |
{ include "**/*Simulation*.scala" } |
Simulations filter. See Gradle docs for details. |
gatling {
toolVersion = '3.3.1'
jvmArgs = [ '-server', '-Xms512M', '-Xmx512M' ]
systemProperties = ['file.encoding': 'UTF-8']
}
gatling {
simulations = {
include "**/package1/*Simu.scala" (1)
include "**/package2/*Simulation.scala" (2)
}
}
-
all
Scala
files from plugin simulation dir subfolderpackage1
ending withSimu
. -
all
Scala
files from plugin simulation dir subfolderpackage2
ending withSimulation
.
To override default parameters of Gatling
just put own version of gatling.conf
into src/gatling/resources
.
Gatling
uses Logback to customize its output.
To change logging behaviour, put your logback.xml
into resources folder,
src/gatling/resources
.
If no custom logback.xml
provided,
by default plugin will implicitly use following configuration.
logback.xml
created by the plugin<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<immediateFlush>false</immediateFlush>
</encoder>
</appender>
<root level="${logLevel}"> (1)
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
-
logLevel
is configured via plugin extension,WARN
by default.
This plugin defines three Gradle configurations gatling
, gatlingImplementation
and gatlingRuntimeOnly
.
By default plugin adds Gatling
libraries to gatling
configuration.
Configurations gatlingImplementation
and gatlingRuntimeOnly
extend gatling
, i.e. all dependencies declared in gatling
will be inherited. Dependencies added to configurations other than these 'gatling' configurations will not be available within Gatling simulations.
Also project classes (src/main
) and tests classes (src/test
) are added to gatlingImplementation
and gatlingRuntimeOnly
classpath,
so you can reuse existing production and test code in your simulations.
If you don’t need such behaviour, you can use flags:
gatling {
// do not include classes and resources from src/main
includeMainOutput = false
// do not include classes and resources from src/test
includeTestOutput = false
}
Additional dependencies can be added by plugin’s users to any of configurations mentioned above.
Gatling
simulationsdependencies {
gatling 'com.google.code.gson:gson:2.8.0' (1)
gatlingImplementation 'org.apache.commons:commons-lang3:3.4' (2)
gatlingRuntimeOnly 'cglib:cglib-nodep:3.2.0' (3)
}
-
adding
gson
library, available both in compile and runtime classpath. -
adding
commons-lang3
to compile classpath for simulations. -
adding
cglib
to runtime classpath for simulations.
Plugin provides GatlingRunTask
that is responsible for executing Gatling
simulations.
Users may create own instances of this task to run particular simulations.
Following configuration options are available. Those options are similar to global gatling
configurations.
Options are used in a fallback manner, i.e. if option is not set the value from gatling
global config is taken.
Property name | Type | Default value | Description |
---|---|---|---|
jvmArgs |
List<String> |
null |
Additional arguments passed to JVM when executing |
systemProperties |
Map<String, Object> |
null |
Additional systems properties passed to JVM together with caller JVM system properties |
simulations |
Closure |
null |
Simulations filter. See Gradle docs for details. |
Task name | Type | Description |
---|---|---|
|
- |
Compiles |
|
GatlingRunTask |
Executes all |
|
GatlingRunTask |
Executes single |
$ gradle gatlingRun
com.project.simu.MySimulation
class$ gradle gatlingRun-com.project.simu.MySimulation
Caused by io.spring.dependency-management
plugin and Spring platform BOM files.
The dependency management plugin ensures that all declared dependencies have exactly the same versions as declared in BOM.
Since Spring Boot
declares own Netty
version (e.g. 4.1.22.Final
) - this version is applied globally
for all the configurations of the Gradle
project, even if configuration doesn’t use Spring
.
There’s 2 ways of solving the problem, depending on the actual usage of Netty
in the project
-
When production code doesn’t rely on
Netty
build.gradleext['netty.version'] = '4.0.51.Final'
This declares
Netty
version globally for all transitive dependencies in your project, includingSpring
. -
When production code uses
Netty
build.gradledependencyManagement { gatling { dependencies { dependencySet(group: 'io.netty', version: '4.0.51.Final') { entry 'netty-codec-http' entry 'netty-codec' entry 'netty-handler' entry 'netty-buffer' entry 'netty-transport' entry 'netty-common' entry 'netty-transport-native-epoll' } } } }
This options ensures that
4.0.51.Final
will be used only forgatling
configurations, leaving other dependencies unchanged.
-
NodeJS and Npm must be installed.
-
Create
GitHub
access token. Onlyrepo
scope is required. -
Install release-it
$ npm install -g release-it @release-it/conventional-changelog
-
Run
$ env GITHUB_TOKEN=${....} release-it --ci patch (1) (2)
-
paste token value from step 2
-
can be
patch
,minor
,major
-
-
Release script will create and push tag to
GitHub
, create a release with a changelog inGitHub
and publish plugin toGradle
plugin portal.