I have a method .exec that does a post request with 20+ different parameters which are null valued. What should I do to make the code more compact.
Have you tried paramsMap?
https://github.com/excilys/gatling/blob/master/src/sphinx/http/http_request.rst#post-parameters
Thanks, I will try it asap. What if in my post request I have like 15-20 parameters, but they are allowed to be empty. If I remove them from my post request will gatling just make these params empty or will it cause an error?
I encountered some problems while trying paramsMap method. I have the following code which causes an error:
.paramsMap(Map(“vatDeclarationForm9_hf_0” → “”,
//“transactionsWithRate20” → session => “” + number3 + “”,
//“selfSupplyWithRate20” → session => “” + number3 + “”,
“transactionsWithRate9” → “”,
“selfSupplyWithRate9” → “”))
The first problem is that it doesn’t compile
[ant:scalac] /home/andrei/myrepos/kmdinf/src/main/scala/LoadTest.scala:90: error: value paramsMap is not a member of com.excilys.ebi.gatling.http.request.builder.PostHttpRequestBuilder
[ant:scalac] possible cause: maybe a semicolon is missing before `value paramsMap’?
[ant:scalac] .paramsMap(Map(“vatDeclarationForm9_hf_0” → “”
And the second is that it doesn’t allow me to do
“transactionsWithRate20” → session => “” + number3 + “”
while .param(“transactionsWithRate20”, session => “” + number3 + “”) allows. Maybe there is another way to do this?
Try current snapshot
How can I do this? Should I change it in my build script?
compile ‘com.excilys.ebi.gatling:gatling-app:1.5.6’
compile ‘com.excilys.ebi.gatling.highcharts:gatling-charts-highcharts:1.5.6’
https://github.com/excilys/gatling/wiki/Gatling%202
But, yes, you’ll have some migrating efforts.
Well, I have problems putting right dependencies and IDE doesn’t allow me to
compile ‘com.excilys.ebi.gatling:gatling-app:2.0.0-M3a’
compile ‘com.excilys.ebi.gatling.highcharts:gatling-charts-highcharts:2.0.0-M3a’
compile ‘org.scala-lang:scala-compiler:2.10’
compile ‘org.scala-lang:scala-library:2.10’
as it simply can’t find them
I am completely lost, as I cannot put
compile ‘com.excilys.ebi.gatling:gatling-app:2.0.0-SNAPSHOT’
compile ‘com.excilys.ebi.gatling.highcharts:gatling-charts-highcharts:2.0.0-SNAPSHOT’
compile ‘org.scala-lang:scala-compiler:2.10’
compile ‘org.scala-lang:scala-library:2.10’
Because they cannot be found, and my ide (idea13) only allows me to get gatling 1.5.6 and scala 2.9 from
maven { url ‘http://repository.excilys.com/content/groups/public’ }
Yeah, yeah, you deserve a RTFM here…
“Gatling 2 uses Scala 2.10. For those using an IDE, beware of using a compatible one.”
=> If you’re using eclipse + Scala IDE, the only way to have it ship multiple Scala versions is to use the latest nightly build. Until then, you have to re-install Scala IDE with the proper version for Scala 2.10, not Scala 2.9
groupId is no longer “com.excilys.ebi.gatling” but “io.gatling”
Ok, I started migrating to Gatling 2. Now, when I try some test RecordedSimulation, which works perfectly through gatling.sh, by using my gradle task:
task runLoadTest(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
// Gatling application
main = “io.gatling.app.Gatling”
// Specify the simulation to run
args = Eval.me("[’-s’, ‘loadTests.RecordedSimulation’]")
//("[’-s’, ‘loadTests.EtollLoadTest’]")
}
I get the following error:
[ant:scalac] /home/…/src/main/scala/RecordedSimulation.scala:35: error: not found: value atOnceUsers
[ant:scalac] setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
Because you’ve set up 2.0.0-M3a instead of the snapshot.
https://github.com/excilys/gatling/wiki/Continuous-Integration
(of course, you have to set up Sonatype snapshot repo)
I finally was able to run the simulation. It went sucessfully, however, it couldn’t generate the report and the build failed in the end.
Exception in thread “main” java.lang.NoClassDefFoundError: io/gatling/charts/component/impl/ComponentLibraryImpl
…
Caused by: java.lang.ClassNotFoundException: io.gatling.charts.component.impl.ComponentLibraryImpl
…
Sorry for bothering, I simply put the wrong dependency.
So now I’m back to params. Instead of:
.param(“roleSwitch1_hf_0”, “”)
.param(“choice”, “company”)
.param(“method”, “handle”)
.param(“companySelect”, “xxx”))
I tried:
.paramsMap(Map(
“roleSwitch1_hf_0” → “”,
“choice” → “company”,
“method” → “handle”,
“companySelect” → “1649539”)
)
and it gave me the following error:
.scala:20: type mismatch;
found : String("")
required: io.gatling.core.validation.Validation[Map[String,Any]]
13:15:35.334 [ERROR] i.g.a.ZincCompiler$ - “roleSwitch1_hf_0” → “”,
I tried paramsSeq instead of paramsMap and it did work. Why is that?