I'm writing a declarative jenkins pipeline and I'm facing problems with gatling reports:
Mean response time trend is not correct, Is there a way to replace following cloud of dots by a curve ?
Extracts from my Jenkinsfile:
stage('perf') {
steps {
bzt params: './taurus/scenario.yml', generatePerformanceTrend: false, printDebugOutput: true
perfReport configType: 'PRT', graphType: 'PRT', ignoreFailedBuilds: true, modePerformancePerTestCase: true, modeThroughput: true, sourceDataFiles: 'results.xml'
dir ("taurus/results") {
gatlingArchive()
}
}
}
Extract from my scenario.yml:
modules:
gatling:
path: ./bin/gatling.sh
java-opts: -Dgatling.core.directory.data=./data
In scenario.yml, I tried to set gatling.core.outputDirectoryBaseName
:
java-opts: -Dgatling.core.directory.data=./data -Dgatling.core.outputDirectoryBaseName=./my_scenario
In this case it replace only gatling by my_scenario, but huge number is already present.
I finally found a solution to solve this problem, but it's not simple since it involves an extension of the taurus code.
The problem is here, at line 309 of the file gatling.py in taurus repo. It explicitly add a prefix 'gatling-' to find a gatling report.
However, parameter -Dgatling.core.outputDirectoryBaseName=./my_scenario
in file scenario.yml change this prefix by my_scenario. What I will describe below is a way to extend taurus in order to quickly extends.
Create a file ./extensions/gatling.py with this code to extend class GatlingExecutor:
from bzt.modules.gatling import GatlingExecutor, DataLogReader
class GatlingExecutorExtension(GatlingExecutor):
def __init__(self):
GatlingExecutor.__init__(self)
def prepare(self):
# From method bzt.modules.gatling.GatlingExecutor:prepare, copy code before famous line 309
# Replace line 309 by
self.dir_prefix = self.settings.get('dir_prefix', 'gatling-%s' % id(self))
# From method bzt.modules.gatling.GatlingExecutor:prepare, copy code after famous line 309
Create a file ./bztx.py to wrap command bzt
:
import signal
import logging
from bzt.cli import main, signal_handler
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
main()
Update file scenario.yml by using new setting property dir_prefix and define new executor class:
modules:
gatling:
path: ./bin/gatling.sh
class: extensions.GatlingExecutorExtension
dir_prefix: my_scenario
java-opts: -Dgatling.core.directory.data=./data -Dgatling.core.outputDirectoryBaseName=./my_scenario
Finaly, update your Jenkinsfile by replacing bzt call with a call to your new file bztx.py:
stage('perf') {
steps {
sh 'python bztx.py ./taurus/scenario.yml'
perfReport configType: 'PRT', graphType: 'PRT', ignoreFailedBuilds: true, modePerformancePerTestCase: true, modeThroughput: true, sourceDataFiles: 'results.xml'
dir ("taurus/results") {
gatlingArchive()
}
}
}
That's all and it works for me. Bonus: this solution gives a way to easily extends taurus with your owns plugins ;-)