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")
According to the docs, you can pass additional
JAVA_OPTSeither by editing the launch script (gatling.sh) or specifying them in the command line before calling the launch script.I'd advise to specify them via the command line as this seems clearer and is explicitly visible.
Specifying
JAVA_OPTSvia the command line:Assuming your on a Unix based system (guessing from your user agent you're on OS X) you can define additional
JAVA_OPTSbefore calling gatling.sh like described here:Assuming the value you want to access is a String, you should be able to use the additional value like this:
You can also edit the launch script itself. Therefore open gatling.sh with the text editor of your choice and add the above
JAVA_OPTSthere.