implicit conversions are not applicable because they are ambiguous

import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.http.Headers._
import akka.util.duration._
import bootstrap._
import assertions._
import akka.util.Duration

class SimpleScenario extends Simulation {
val httpConf = httpConfig.baseURL(“https://testServer.com”).disableFollowRedirect;

val scn = scenario(“My Simple Scenario”)
.feed(csv(“sample_types.csv”).circular)
.during(60 * 60) {
repeat(26, “latitude”) {
repeat(192, “longitude”) {
exec(
http(“getNodeBugSummary”)
.get("/bx/name")
.queryParam(“action”,“getStuffFromServer”)
.queryParam(“latitude”, “${latitude}”.toInt + 24)

.queryParam(“longitude”,"${longitude}")// + (-67l))
//.queryParam(“sample”,"${sample}")
//.check(jsonPath("$.data.results").saveAs(“response”))
)
}
}
}

//def mysetup = for (i ← 0 to 25) yield { scn.protocolConfig(httpConf).users(10).ramp(60).delay(i * 3 * 60);}
//
//setUp(
//scn…users(10).protocolConfig(httpConf)

//setUp(scn.protocolConfig(httpConf));
//setUp(scn.protocolConfig(httpConf).users(10).ramp(10).users(100).ramp(60*10));
setUp(scn.protocolConfig(httpConf).users(1));
}

Using scala-compiler 2.9.2, I get the following error

tools/gatling-test/src/test/scala/SimpleScenario.scala:22: type mismatch;
found : Int
required: ?{val +(x$1: ?>: Int <: Any): ?}
Note that implicit conversions are not applicable because they are ambiguous:
both method int2long in object Predef of type (x: Int)Long
and method int2float in object Predef of type (x: Int)Float
are possible conversion functions from Int to ?{val +(x$1: ?>: Int <: Any): ?}
.queryParam(“latitude”, “24”.toInt + “${latitude}”.toInt )
^
one error found

I am adding 24, since the loops start from 0. And didn’t found any loop constructs that start with given seed.
please help me fix this (Using gatling version 1.5.2).

In Gatling 1, queryParam takes 2 (Session => String) parameters, and there’s an implicit conversion from String to (Session => String) that parses the String with the EL syntax. Implicit conversion ONLY happens when the expected type and the actual one don’t match.

Here, you’re passing:

  • “latitude”: a String
  • “24”.toInt + “${latitude}”.toInt: Have you read an example in the documentation that remotely resembles this? This is an instruction that returns an Int, but will fail at runtime because “${latitude}” can’t be parsed into an Int, like “24” would?

You want to perform a computation based on Session attributes, so you have to use a Session function:
https://github.com/excilys/gatling/wiki/Session#wiki-functions

queryParam(“latitude”, (session: Session) => 24 + session.getTypedAttributeString.toInt)

def add(a: Int, b:Int) = (a+b).toString

val scn2 = scenario(“My Simple Scenario using repeat loops”)

.during(6) {

feed(csv(“sample_types.csv”).circular)

repeat(26, “latitude”) {

repeat(195, “longitude”) {

exec(http(“getNodeBugSummary”)

.get("/bbproxy/DeliverableProxyServlet/bugsanddrugs")

.queryParam(“action”,“getnodebugsummary”)

.queryParam(“latitude”, (session: Session) => add(“24”.toInt, session.getTypedAttributeString.toInt))

.queryParam(“longitude”,"${longitude}")

.queryParam(“sample”,"${sample}")

)

}

}

}

above code compiles fine, but give error at runtime as below:

22:05:17.747 [GatlingSystem-akka.actor.default-dispatcher-6] ERROR c.e.e.g.h.action.HttpRequestAction - Action HttpRequestAction crashed, forwarding user to next one

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at SimpleScenario$$anonfun$2.apply(SimpleScenario.scala:46) ~[test/:na]

at SimpleScenario$$anonfun$2.apply(SimpleScenario.scala:46) ~[test/:na]

at com.excilys.ebi.gatling.core.session.Session$$anonfun$evaluatableStringToEvaluatableStringSeq$1.apply(Session.scala:49) ~[gatling-core-1.5.2.jar:na]

at com.excilys.ebi.gatling.core.session.Session$$anonfun$evaluatableStringToEvaluatableStringSeq$1.apply(Session.scala:49) ~[gatling-core-1.5.2.jar:na]

at com.excilys.ebi.gatling.http.util.HttpHelper$$anonfun$httpParamsToFluentMap$1.apply(HttpHelper.scala:44) ~[gatling-http-1.5.2.jar:na]

at com.excilys.ebi.gatling.http.util.HttpHelper$$anonfun$httpParamsToFluentMap$1.apply(HttpHelper.scala:44) ~[gatling-http-1.5.2.jar:na]

at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233) ~[scala-library-2.9.3.jar:na]

ala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233) ~[scala-library-2.9.3.jar:na]

at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) ~[scala-library-2.9.3.jar:na]

at scala.collection.immutable.List.foreach(List.scala:76) ~[scala-library-2.9.3.jar:na]

at scala.collection.TraversableLike$class.map(TraversableLike.scala:233) ~[scala-library-2.9.3.jar:na]

at scala.collection.immutable.List.map(List.scala:76) ~[scala-library-2.9.3.jar:na]

at com.excilys.ebi.gatling.http.util.HttpHelper$.httpParamsToFluentMap(HttpHelper.scala:44) ~[gatling-http-1.5.2.jar:na]

at com.excilys.ebi.gatling.http.request.builder.AbstractHttpRequestBuilder.configureQueryAndCookies(AbstractHttpRequestBuilder.scala:210) ~[gatling-http-1.5.2.jar:na]

at com.excilys.ebi.gatling.http.request.builder.AbstractHttpRequestBuilder.getAHCRequestBuilder(AbstractHttpRequestBuilder.scala:159) ~[gatling-http-1.5.2.jar:na]

at com.excilys.ebi.gatling.http.request.builder.AbstractHttpRequestBuilder.build(AbstractHttpRequestBuilder.scala:173) ~[gatling-http-1.5.2.jar:na]

at com.excilys.ebi.gatling.http.action.HttpRequestAction.execute(HttpRequestAction.scala:62) ~[gatling-http-1.5.2.jar:na]

at com.excilys.ebi.gatling.core.action.Action$$anonfun$receive$1.apply(Action.scala:31) ~[gatling-core-1.5.2.jar:na]

at com.excilys.ebi.gatling.core.action.Action$$anonfun$receive$1.apply(Action.scala:30) ~[gatling-core-1.5.2.jar:na]

at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:76) ~[scala-library-2.9.3.jar:na]

at akka.actor.Actor$class.apply(Actor.scala:318) ~[akka-actor-2.0.4.jar:2.0.4]

at com.excilys.ebi.gatling.http.action.HttpRequestAction.apply(HttpRequestAction.scala:55) ~[gatling-http-1.5.2.jar:na]

at akka.actor.ActorCell.invoke(ActorCell.scala:626) ~[akka-actor-2.0.4.jar:2.0.4]

at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) ~[akka-actor-2.0.4.jar:2.0.4]

at akka.dispatch.Mailbox.run(Mailbox.scala:179) ~[akka-actor-2.0.4.jar:2.0.4]

at akka.dispatch.ForkJoinExecfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:516) [akka-actor-2.0.4.jar:2.0.4]

at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259) [akka-actor-2.0.4.jar:2.0.4]

at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) [akka-actor-2.0.4.jar:2.0.4]

at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479) [akka-actor-2.0.4.jar:2.0.4]

at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104) [akka-actor-2.0.4.jar:2.0.4]

22:05:17.784 [GatlingSystem-akka.actor.default-dispatcher-15] WARN c.e.e.gatling.core.session.ELParser$ - Couldn’t resolve EL ${sample}

Along with that looks like session is cleared?

If I define a feeder with this, it works fine:

def coordinateMap = for(lat ← 24 to 50 ; long ← -67 to 125) yield { Map(“latitude” → lat.toString(), “longitude” → long.toString()) };

.feed(coordinateMap.toArray)

Even
24".toInt + “${latitude}”.toInt
gives below compilation error.

Users/gsetty/Perforce/perforce/gsetty/sandbox/gsetty/tools/gatling-test/src/test/scala/SimpleScenario.scala:46: type mismatch;
found : Int(24)
required: ?{val +(x$1: ?>: Int <: Any): ?}
Note that implicit conversions are not applicable because they are ambiguous:
both method int2long in object Predef of type (x: Int)Long
and method int2float in object Predef of type (x: Int)Float
are possible conversion functions from Int(24) to ?{val +(x$1: ?>: Int <: Any): ?}
.queryParam(“latitude”, (session: Session) => 24 + session.getTypedAttributeString.toInt)
^
one error found

Because now that “latitude” is no longer a value injected from a csv feeder, but a loop index, it’s no longer a String but an Integer, hence the CCE in getTypedAttribute.

What you want now is:

.queryParam(“latitude”, (session: Session) => (24 + session.getTypedAttributeInt).toString)

PS: stop with this “24”.toInt