Passing Paramters isnt working with the RC2

Hi,

I am new to Gatling and learning through the documentation available online @ http://gatling.io/docs/2.0.0-RC2/cookbook/passing_parameters.html.

I was trying to read a parameter from command line and it says me

“[ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘urlHost’ is defined
[ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘urlHost’ is defined
[ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘urlHost’ is defined”

Below are the files that i used.

`
package #######.########

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import Headers._

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 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(“Authentication for LogIn and Card Creation”)
.exec(http(“Authentication”)
.post("""/sample""")
.headers(headers_1)
.header(“Developerid”, “${loginUser}”)
.header(“Developerpassword”,"${loginPwd}")
.header(“Origin”, “${urlHost}”)
.check(status.is(200)))

setUp(scn.inject(rampUsers(nbUsers) over (myRamp seconds)).protocols(httpProtocol))

}

`

Can you let me know if i am missing anything.

Thanks,
Sujatha

Hi Sujatha,

Since urlHost is not in the session, you don’t need (and in fact can’t) use EL for it.

Replace .baseURL("${urlHost}") with .baseURL(urlHost) and it will work fine.

Cheers,

Pierre

Hi Pierre,

Thanks for the quick response. i got that working.

And now i moved to add a json feeder to it and i am not able to parse it.

here is the code below:

`
package XXXXXXX.XXXXXXX

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import Headers._

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(“XXXXXXX.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(“Authentication for LogIn”)
.feed(jsonFileFeeder)
.exec(http(“Authentication”)
.post("""/sample""")
.headers(headers_1)
.header(“Developerid”, “${user}”)
.header(“Developerpassword”,"${pwd}")
.header(“Origin”, “urlHost”)
.check(status.is(200)))

setUp(scn.inject(rampUsers(nbUsers) over (myRamp seconds)).protocols(httpProtocol))

}
`

and it gives me the error

“i.g.h.a.HttpRequestAction - url urlHost/authenticator can’t be parsed into a URI: scheme
i.g.h.a.HttpRequestAction - url urlHost/authenticator can’t be parsed into a URI: scheme
i.g.h.a.HttpRequestAction - url urlHost/authenticator can’t be parsed into a URI: scheme”

me being a starter might bug you many a times on simple issues. but i am planning to master gatling by trying out all the features in it :slight_smile:

Pierre wrote .baseURL(urlHost),not .baseURL(“urlHost”) like you did…

What was the command line argument you were passing here? I’m facing a similar issue where I pass the command line argument .\gatling.bat -s REST.CreateUser.CreateLoadTestUser.Warmup -m -baseUrl localhost

I get error where it does not recognize the string localhost. What’s the syntax for passing command line parameters for the bat file. The same syntax works for the ps1 launcher but not for the bat launcher.