Adamus77
Adamus77

Reputation: 23

Gatling - passing data from feeder to method in exec

Im new to Gatling and I'm trying to reuse test scripts I'm using for functional testing I wrote in RestAssured/Java to work with gatling. So what I do to call my login methods is I call them in wrapperForJavaMethods method(line 4) before calling the last method in "gatling fashion"(line 6 ). If I just put strings as arguments in line 4 it works perfectly well but when I'm trying to use feeder's variable ${login} is printed, for comparison in line 7(where it makes no logical sense to call feeder's variable I just did it for debugging purposes) data from csv is printed. Is there anyway in which I can pass data from csv feeder to method's parameters or can they only be. called in session?

  val csvCredentails = csv("data/data.csv")//1
  val scenario = scenario("my custom scenario")//1
    .feed(csvCredentails)//3
    .exec(wrapperForJavaMethods("${login}","${pass}"))//4
    .exec(http("login")//5
      .post("/login")//6
      .check(status is "${login}")//7

  def wrapperForJavaMethods(login: String, pass: String): Unit = {
    print("login11 " + username + " pass " + password)
    objectOfJavaClass.inputCredentials(username, password)
    objecyOfJavaClass.anotherJavaMethod
    objecyOfJavaClass.anotherJavaMethod2
    objecyOfJavaClass.anotherJavaMethod3
...

}

Upvotes: 0

Views: 1358

Answers (1)

Stéphane LANDELLE
Stéphane LANDELLE

Reputation: 6623

Disclaimer: Gatling founder here

First, I'm very skeptical about what you're trying to build.

  • RestAssured and other functional test tools are not implemented for heavy load. Typically, they are not built on top of a fast non-blocking HTTP client. It's not just their target use case. Triggering RestAssured from a Gatling's orchestrator won't make it able to generate large loads like genuine Gatling HTTP module does. Moreover, such blocking APIs don't play nice when plugged into an async engine like Gatling's.
  • Are you really sure your connections usage will match what happens on your target's system? RestAssured will either use a shared connection pool, or no connection pool at all. I suspect you won't be able to implement a connection pool per virtual user. Again, functional test tools are not designed for this.

Then, regarding the code you shared, this is not how Gatling Expression Language works. You would have to resolve your parameters in a function. Please check the Session API.

Upvotes: 2

Related Questions