Closed igorek9191 closed 5 years ago
Hey @igorek9191
the only way you could retrieve a value within a Gatling scenario would be to retrieve it from the session (see here for more details). Using toString
on the result of an exec()
won't work.
Still, I think your wish is a valid feature request and I'll try to implement it soon.
As a workaround for your direct problem you could (ab-)use the JdbcCheck
because a io.gatling.core.check.CheckResult$
can modify the session. It could look like this:
object MyStoringCheck extends JdbcCheck {
override def check(response: List[Map[String, Any]], session: Session)(implicit cache: mutable.Map[Any, Any]): Validation[CheckResult] = {
Success(CheckResult(Some(response.head("technic_root_id")), Some("name")))
}
}
Hello @rbraeunlich , I'm newbie to gatling, and i want to explore more about it. i wanna know how to execute my create table with hive via gatling for testing performance. Do i have to create my own code "gatling-jdbc" just like yours or i have to pass by gatling platform. PS: I used yours with gatling platform : gatling-jdbc/src/test/scala/de/codecentric/gatling/jdbc/CreateTableSimulation.scala and i get this errors "Exception in thread "main" java.lang.NoClassDefFoundError: scalikejdbc/ConnectionPool$"
Thank you for your response Regards Elloumi Nisrine
Hi @ellouminisrine basically, you have three ways to execute Gatling load tests. All are described here. You then have to add Gatling-JDBC as a dependency to your build.sbt or whichever build system you're using. The simulations inside this repository are intended as examples and to test the project itself. Cheers, Ronny
Hello @rbraeunlich , Thank you for response, i checked the links of gatling and i didn't understand how could i generate my own project yet with https://gatling.io/docs/current/extensions/maven_archetype/#maven-archetype Like we already have a generated project ? Thank you for your response Regards Elloumi Nisrine
Thank you for your answer @rbraeunlich .
I don't really see the connection between your answer and the question. My understanding is that gatling is waiting for a test scenario written in scala in a particular directory. So I don't really understand why you are suggesting a solution including maven or sbt. My understanding (again) is that gatling will compile the test case scenario through the gatling.bat or gatling.sh script. those two script are not using maven nor sbt and seem to use zinc to compile the scala tests case scenario.
Thank you for shedding some lights on this matter.
Dear @ellouminisrine and @IndexOutOfRange
if you have problems with executing Gatling scenarios in general, please use the Gatling Google Group, since your questions aren't related to this issue. Still, I wanna answer your question.
One thing you can do to execute Gatling scenarios is using the SBT plugin. This means you create a normal sbt project and configure it as mentioned in the documentation. Using sbt gatling:test
the scenarios will be detected and executed. I have never used the Maven plugin but I'm sure it works similarly.
The other option would be using the Zip bundle. You @IndexOutOfRange basically described how it works. In the zip bundle, Gatling JDBC and it's dependencies are missing. Therefore, you'll have to copy all of them into the lib
directory. I think the Gatling JDBC Jar itself, Scalike JDBC and whatever SQL library you wanna use should be sufficient.
Cheers, Ronny
How to execute usual SQL query to get object ID and put this ID into a method like a parametr? I have write the code for SQL selection
val technic_root_id = exec(jdbc("selection").select("technic_root_id").from("ods_req_car.technic_request").where("id = ${car_request_id}"))
In scenarion I call it through this exec:.exec(Technic.viewTechnicCard(Technic.technic_root_id.toString))
In output log I see the following
GET http://server.host/api/tech/ChainBuilder(List(JdbcSelectionWithWhereActionBuilder(%3Cfunction1%3E,%3Cfunction1%3E,%3Cfunction1%3E,io.gatling.core.session.el.ElCompiler$$$Lambda$338/879423823@6464ef69)))?loadTree=true
Seems like this is not what I want. This is not ID of my object after
tech/
part of URL. How can I execute SQL query during scenario and put the result of query into method ?