Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging the session

As part of my performance testing, I need to debug the session etc. The same code is running if I remove session =>. When I add that it says there was no request sent during simulation since it is not sending any.

 val scn1 = scenario("LaunchAction").exec{ session => 

   http("Poll report status page report")
     .get("myURL/rest/reports")
     .queryParam("applicationId", "123")          
     .queryParam("id", "1")
     .check(xpath("//status").saveAs("responseStatus"))

   session
}

I need to add few prints etc in between. Can you please provide some information?

like image 733
user666 Avatar asked Jan 06 '23 05:01

user666


2 Answers

I just started with Gatling and I had exactly the same problem. The easiest way to debug for me was the addition of the entrypoint object, which I use to start/debug tests locally by running the main method

object DebugEntrypoint {

  def main(args: Array[String]) {

    // This sets the class for the Simulation we want to run.
    val simClass = classOf[Smoke].getName

    val props = new GatlingPropertiesBuilder
    props.sourcesDirectory("./src/test/scala")
    props.binariesDirectory("./target/scala-2.10/classes")
    props.simulationClass(simClass)
    Gatling.fromMap(props.build)
  }
}

As soon as the test is being executed from here, any breakpoints I put in the simulation will pause execution during the runtime. As soon as you hit a breakpoint, you can evaluate expressions and have all other debug instruments at your bidding.

like image 149
Eugene A Avatar answered Jan 13 '23 02:01

Eugene A


You can add another exec to it like this:

.exec(
      session => {
        val activityId = session.get("someId").asOption[String]
        println(activityId)
        session
      }
    )

This should give you the session details.

like image 34
Pritam Banerjee Avatar answered Jan 13 '23 03:01

Pritam Banerjee