www.py4u.net
Open in
urlscan Pro
2606:4700:3032::ac43:b59a
Public Scan
URL:
https://www.py4u.net/discuss/1557673
Submission: On November 04 via manual from GB — Scanned from GB
Submission: On November 04 via manual from GB — Scanned from GB
Form analysis
0 forms found in the DOMText Content
How do I make Gatling capture request while reading from the session? According to the Gatling documentation, I can work with session attributes when executing a scenario. However, every time I use function literals to access the session in a scenario, I end up with the following exception: [error] java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won't be generated [error] at io.gatling.charts.report.ReportsGenerator$.generateFor(ReportsGenerator.scala:45) [error] at io.gatling.app.Gatling.generateReports(Gatling.scala:198) [error] at io.gatling.app.Gatling.start(Gatling.scala:82) [error] at io.gatling.app.Gatling$.fromArgs(Gatling.scala:59) [error] at io.gatling.sbt.GatlingTask.liftedTree1$1(GatlingTask.scala:49) [error] at io.gatling.sbt.GatlingTask.execute(GatlingTask.scala:48) [error] at sbt.ForkMain$Run$2.call(ForkMain.java:296) [error] at sbt.ForkMain$Run$2.call(ForkMain.java:286) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [error] at java.lang.Thread.run(Thread.java:745) [error] Simulation FooBarSimulation failed. [info] Simulation(s) execution ended. More specifically, while this notation gives me correct results: val scn = scenario("Foobar").feed(feeder).exec { http("foo").httpRequest("GET", "http://example.org") }.pause(5) this fails with the aforementioned exception: val scn = scenario("Foobar").feed(feeder).exec { session => http("foo").httpRequest("GET", "http://example.org") session }.pause(5) Asked By: mritz_p || Source ANSWER #1: A scenario is a plan for a simulation. So when you say val scn = ... you are not executing the simulation, but building an AST that is later executed by gatling. So when you say val scn = scenario("Foobar").feed(feeder).exec { session => http("foo").httpRequest("GET", "http://example.org") session }.pause(5) The part http("foo").httpRequest("GET", "http://example.org") is a statement which does not have a side effect and the value of which is never used. So it might as well not be there. As far as gatling is concerned, your scenario is val scn = scenario("Foobar").feed(feeder).exec { session => session }.pause(5) Which does absolutely nothing, and therefore produces an error when generating a report. To achieve what you want, the session manipulation has to be a separate exec statement. Like this: val scn = scenario("Foobar").feed(feeder) .exec ( session => session.set("foo", "bar") ) .exec ( http("foo").httpRequest("GET", "http://example.org") ) }.pause(5) Answered By: Rüdiger Klaehn The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 . # More Articles Scala overloaded constructors and super Future Recursion Patterns/Future Chaining of arbitrary length How is an imported name resolved in Scala? (Spark / Zeppelin) Efficient PairRDD operations on DataFrame with Spark SQL GROUP BY Cannot get type of generic object in a list Can I define “method-private” fields in Scala? Get the result of a stored procedure to a dataframe or Rdd? Scala Play passing variable to view not working Contravariant method argument type scala 2.10 type mismatch using google guava's CacheBuilder debug scala code in intellij? Ebean: Cascade with OneToOne – tries inserts instead of update Transpose on infinite stream loops forever value join is not a member of org.apache.spark.rdd.RDD How to save and load history between invocations of Scala JLine Json Writes in Play 2.1.1 How to use spark with large decimal numbers? Scala unit testing stdin/stdout How can I customize Scala ambiguous implicit errors when using shapeless type inequalities