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.

setUp(getpost_scenario.inject(....).protocols(getpost_protocol))

setUp(database_scenario.inject(....).protocols(database_Protocol))


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),
database_scenario.inject(
nothingFor(30 minute),
constantUsersPerSec(1) during(10 minute)
).protocols(database_Protocol))

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"
println(Ids(i))
writer.writeNext(Ids)
i = i + 1
session
}
}
after {
writer.close()
}

val scn = scenario(“Case”)
.group(“login”){
exec( Login.login)
}
.group(“actions”){
exec(Actions.actions)
}
.group(“dbQuery”){
exec(dbQuery.scn1)
}

.exec(flushHttpCache)
.exec(flushCookieJar)
.exec(flushSessionCookies)

setUp(
scn.inject(atOnceUsers(1)).protocols(httpProtocol)
)

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.