Gatling scenarios to be executed sequentially?

I have two scenarios which are in separate scala class files, one of which is get and post requests and the other one is a database extract writing to a csv file. When the running the tests, Gatling always executes the database scala file rather than the other scenario file. What i want is that the other scenario is executed and then the database scenario. Can any one help in this regard.

Simple way would be to copy both the scenarios into one scala class and then set up two injections for the scenarios one after the other in the order you want them to run.



I tried this out and got an error that ‘setUp can only be called once’

This should work in that case:

setUp(getpost_scenario.inject(constantUsersPerSec(1) during(30 minute)).protocols(getpost_protocol),
nothingFor(30 minute),
constantUsersPerSec(1) during(10 minute)

I tried this out and it still behaves the same …i.e executing the db scenario and then the other scenario.

can you share your scala file with the two scenarios and the injection setup to debug into this issue?

Please do apologize as i cannot send the exact scala class file which i am using in my project

This is the last edited scala class file which is a skeleton of it

Object Login { val login = …….}
Object Actions{val actions = }
object dbQuery {

val csvFileLocation = “”
val out = new BufferedWriter(new FileWriter(csvFileLocation)).append(“IDS” + “\n”)
val writer = new CSVWriter(out, CSVWriter.NO_QUOTE_CHARACTER, CSVWriter.NO_ESCAPE_CHARACTER, “\n”)
val scn1 = //scenario(“Database Query”)

var i = 0
feed(jdbcFeeder(“jdbc:oracle:thin:<jdbc connection details, username, password, sql>))
.exec { session =>
val Ids = new Array[String]((jdbcFeeder(”<jdbc connection details, username, password, sql>”).records.length))
println(“Ids”, Ids)
Ids(i) = session(“IDS”).as[Long].toString + “,” +"\n"
i = i + 1
after {

val scn = scenario(“Case”)
exec( Login.login)



What is happening is that the Database query is run first and then the other stuffs.

How do you check if the database query is executed first and rest of the requests later. From your scn scenario set up, it should do the login and actions first and then the db query.
Also, just to be sure, what is the goal of the flow - for each user, run some requests first and then check something in database?
My earlier solution was based on the assumption that you run getpost requests for sometime with multiple users and then once these are finished run the db requests.