How to run multiple Gatling simulations in a sequence (sequence will be provides by us)
Asked Answered
C

2

1

When I run Gatling from my command prompt I get a list of simulations like this:

Choose a simulation number: 1,2,3,4

When I type 3 third simulation will run but this sequence is auto-generated.Suppose I want to list them according to my wish like: 3,2,1,4

Is it possible to give user defined sequence for simulations list.If yes how it is possible?

Charger answered 30/6, 2016 at 12:3 Comment(0)
M
1

As far as I know there is no possibility in Gatling to provide sequence of simulations. You can achieve this by writing for example bash script. For running Gatling tests in mvn it could look like this

#!/bin/bash

#params
SIMULATION_CLASSES=

#usage
function usage (){
    echo "usage: $0 options"
    echo "This script run Gatling load tests"
    echo ""
    echo "OPTIONS:"
    echo "Run options:"
    echo "   -s             [*] Simulation classes (comma separated)"
}

#INIT PARAMS
while getopts “s:” OPTION
do
     case $OPTION in
     s) SIMULATION_CLASSES=$OPTARG;;
     ?) usage
        exit 1;;
     esac
done

#checks
if [[ -z $SIMULATION_CLASSES ]]; then
    usage
    exit 1
fi

#run scenarios
SIMULATION_CLASSES_ARRAY=($(echo $SIMULATION_CLASSES | tr "," "\n"))

for SIMULATION_CLASS in "${SIMULATION_CLASSES_ARRAY[@]}"
do
    echo "Run scenario for $SIMULATION_CLASS"
    mvn gatling:execute -Dgatling.simulationClass=$SIMULATION_CLASS
done

And sample usage

./campaign.sh -s package.ScenarioClass1,package.ScenarioClass2
Multiplicity answered 3/1, 2017 at 23:24 Comment(0)
S
0

If you use the Gatling SBT Plugin (demo project here), you can do, in Bash:

sbt "gatling:testOnly sims.ReadProd02Simulation" "gatling:testOnly sims.ReadProd02Simulation

This first runs only the sceenario ReadProd02Simulation, and then runs ReadProd03Simulation. No Bash script needed.

The output will be first the output from ReadProd02Simulation and then ReadProd03Simulation, like so:

08:01:57 46 ~/dev/ed/gatling-sbt-plugin-demo[master*]$ sbt "gatling:testOnly sims.ReadProd02Simulation"  "gatling:testOnly sims.ReadProd02Simulation"
[info] Loading project definition from /home/.../gatling-sbt-plugin-demo/project
[info] Set current project to gatling-sbt-plugin-demo...
Simulation sims.ReadProd02Simulation started...
...
Simulation sims.ReadProd02Simulation completed in 16 seconds
Parsing log file(s)...
Parsing log file(s) done
Generating reports...
======================================================================
- Global Information ----------------------------------------------
> request count                                          3 (OK=3      KO=0     )
...
...
Reports generated in 0s.
Please open the following file: /home/.../gatling-sbt-plugin-demo/target/gatling/readprod02simulation-1491631335723/index.html
[info] Simulation ReadProd02Simulation successful.
[info] Simulation(s) execution ended.
[success] Total time: 19 s, completed Apr 8, 2017 8:02:33 AM
08:02:36.911 [INFO ] i.g.h.a.HttpEngine - Start warm up
08:02:37.240 [INFO ] i.g.h.a.HttpEngine - Warm up done
Simulation sims.ReadProd03Simulation started...
...
Simulation sims.ReadProd03Simulation completed in 4 seconds
Parsing log file(s)...
Parsing log file(s) done
Generating reports...
======================================================================
---- Global Information ----------------------------------------------
> request count                                          3 (OK=3      KO=0     )
......
Reports generated in 0s.
Please open the following file: /home/.../gatling-sbt-plugin-demo/target/gatling/readprod03simulation-1491631356198/index.html
[info] Simulation ReadProd03Simulation successful.
[info] Simulation(s) execution ended.
[success] Total time: 9 s, completed Apr 8, 2017 8:02:42 AM

That is, first it runs one sim, then another, and concatenates all output.

But how do you make use of this? Well, you could use Bash and grep the output for exactly two lines matching failed 0 ( 0%) (if you run two simulations) + check the total request counts for both simulations, also via Bash + grep etc.

Susurration answered 8/4, 2017 at 6:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.