Hi,
For me to start my stress run, i have to get lot of parameters from DB by executing n number of sql queries.
for this what i have done is
created a file named BasicSimulation .scala and the file is as below.
`
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import scala.concurrent.duration._
import Headers._
import MysqlDataFeeder._
class BasicSimulation extends Simulation {
val urlHost = System.getProperty(“URL_HOST”)
val nbUsers:Int = java.lang.Integer.getInteger(“users”, 1)
val myRamp:Long = java.lang.Long.getLong(“ramp”, 0L)
val jsonFileFeeder = jsonFile(“StressData.json”).circular
val httpProtocol = http
.baseURL(urlHost)
.acceptHeader("/")
.acceptEncodingHeader(“gzip,deflate,sdch”)
.acceptLanguageHeader(“en-US,en;q=0.8”)
.connection(“keep-alive”)
.userAgentHeader(“Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36”)
val scn = scenario(“Sample”)
.feed(jdbcFileFeeder)
.exec(http(“Authentication”)
.post("""/authenticator""")
.headers(headers_1)
.header(“Developerid”, “${userName}”)
.header(“Developerpassword”,"${secondaryPassword}")
.header(“Origin”, “urlHost”)
.check(jsonPath("$.token").saveAs(“tokenId”))
.check(status.is(200)))
setUp(scn.inject(rampUsers(nbUsers) over (myRamp seconds)).protocols(httpProtocol))
}
`
and then created a seperate scala file named "MysqlDataFeeder.scala and file is as below
`
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import scala.concurrent.duration._
object MysqlDataFeeder {
val jdbcFileFeeder = jdbcFeeder(“jdbc:mysql://#########/#######”, “#######”, “#######”, “##########################################”)
}
`
I am able to get the values from the sql query.
but i dont want to do it as a feeder, as i want these queries to execute only during the start up and store the values for the rest of the session. ( like the init method we have in JAVA )
but i need to execute it only once prior to start up of the run and to use those values in my entire simulation ( like these values doesnt change with respect to user)
do we have any other way of achieving this?
Thanks,
Sujatha