I have a scenario where while executing gatling. sh, I need to pass the authorization from the terminal instead of going and changing the situation.scala file always, because authorization is specified only for particular and once a user logs out we need to provide new login Auth key. Basically can we pass the arguments from the command line while running the gatling.sh in Gatling Performance testing. Please, check the simulation.scala file for reference. ""authorization" -> "Need to pass value from terminal while running the gatling.sh","
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class RecordedSimulation extends Simulation {
val httpProtocol = http
.baseURL("baseURL")
.inferHtmlResources()
val headers_0 = Map(
"accept" -> "*/*",
"accept-encoding" -> "gzip, deflate, br",
"accept-language" -> "en-US,en;q=0.9",
"access-control-request-headers" -> "access-control-allow-origin,authorization,content-type",
"access-control-request-method" -> "GET",
"origin" -> "URL_LINK",
"user-agent" -> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36")
val headers_1 = Map(
"accept" -> "*/*",
"accept-encoding" -> "gzip, deflate, br",
"accept-language" -> "en-US,en;q=0.9",
"access-control-allow-origin" -> "*",
**"authorization" -> "Need to pass value from the terminal while running the gatling.sh",**
"content-type" -> "application/json",
"origin" -> "ORIGIN_URL",
"referer" -> "REFERER_URL",
"user-agent" -> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36")
Your scala file
class abcdClass extends Simulation { val environment = System.getProperty("environment", "Performance Env.") // here "Performance Env." is default value .... .... }
Console:
For Linux
For Windows