Gatling 2.0.0-RC2 - Query regarding Gatling Execution errors when using randomSwitch

Hello Gatling Experts,

Gatling Version : 2.0.0-RC2
I’m experiencing errors when trying to use Advanced Simulation Approach, along with randomSwitch. Could you please advise how to resolve this, with possible code snippet.

Class LoadTest extends Simulation {

object HomePage {

val home = { group(“Home Page”) {

exec(http(“home page”) .get("""/""")

.headers(Config.headers_0)

.resources(http(“request_1”)

.get(Config.uri1 + “”"/scripts/main.js""")

… so on

}

}

object search {

val search = { group (“Search”) {

}

val httpConf = http

.baseURL(“https://testsite”)

.inferHtmlResources()

.acceptHeader("""/""")

.acceptEncodingHeader(""“gzip, deflate”"")

.acceptLanguageHeader(""“en-gb,en;q=0.5"”")

.connection(""“keep-alive”"")

.userAgentHeader(""“Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"”")

val headers_0 = Map(""“Accept”"" → “”“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"”")

------ so on

val headers_25 = Map(""“X-Requested-With”"" → “”“XMLHttpRequest”"")

}

val uri1 = “”“https://acceptance.alpha.mygov.scot:81"”"

val scenario1 = scenario(“multiplescenario”).forever() {

randomSwitch{

60 → HomePage.home,

40 → Search.search

}

}

}

Above test is failing with following errors for selected lines

expected class or object definition

I’m able to execute the test after replacing scenario without randomSwitch.

val scenario1 = scenario(“multiplescenario”).during(15 minutes) {exec(HomePage.home,Search.search)}.during(15 minutes){exec(Search.search,Homepage.home)}

Thanks & Regards,

Rajesh

Hi Rajesh,

Have a look at randomSwitch documentation : http://gatling.io/docs/2.0.0-RC2/general/scenario.html#loop-statements
Replace the curly braces in your randomSwitch call by parentheses and it should work as expected.

`

randomSwitch(

60 → HomePage.home,
40 → Search.search

)

`

Cheers,

Pierre

Hi Pierre,

Many thanks for quick response.

After I had modified the test, Test failed with 2 more errors.
The first error seems potential issue with Gatling tool documentation.
Could you advise if any work around to resolve the 2nd error.

Error 1 : This issue resolved upon replacing 20 → 20.0 in randomSwitch. It seems % should always be given in double format.

./gatling.sh

GATLING_HOME is set to /home/ubuntu/gatling-charts-highcharts-2.0.0-RC2

18:03:45.949 [ERROR] i.g.a.ZincCompiler$ - /home/ubuntu/gatling-charts-highcharts-2.0.0-RC2/user-files/simulations/explore/alpha/mygov/scot/Load.scala:338: type mismatch;

found : (Int, io.gatling.core.structure.ChainBuilder)

required: (Double, io.gatling.core.structure.ChainBuilder)

18:03:45.952 [ERROR] i.g.a.ZincCompiler$ - 20 → HomePage.home,

18:03:45.952 [ERROR] i.g.a.ZincCompiler$ - ^

18:03:46.242 [ERROR] i.g.a.ZincCompiler$ - one error found

Compilation failed

Error 2 : Test Execution completed and following error shown while generating report.

Simulation finished

Generating reports…

Parsing log file(s)…

Parsing log file(s) done

Exception in thread “main” java.util.NoSuchElementException: key not found: List(Content Items)

at scala.collection.MapLike$class.default(MapLike.scala:228)

at scala.collection.AbstractMap.default(Map.scala:58)

at scala.collection.MapLike$class.apply(MapLike.scala:141)

at scala.collection.AbstractMap.apply(Map.scala:58)

at io.gatling.charts.report.StatsReportGenerator.io$gatling$charts$report$StatsReportGenerator$$addGroupsRec$1(StatsReportGenerator.scala:104)

at io.gatling.charts.report.StatsReportGenerator$$anonfun$generate$1$$anonfun$apply$1.apply(StatsReportGenerator.scala:115)

at io.gatling.charts.report.StatsReportGenerator$$anonfun$generate$1$$anonfun$apply$1.apply(StatsReportGenerator.scala:114)

at scala.Option.foreach(Option.scala:236)

Thanks & Regards,

Rajesh