I have a problem with the implementation of Gatling scenario. It's on Scala DSL, maybe somebody already had this issue?
The goal: we need to Inject data in out scenario. Basically, we have - our page http://ourPage.com/ like the root for all relative URLs - the list of URLs in CSV file, these URLs basically are 650000 id from our Oracle database, that in combination (root+Urls) will simulate the number of users that we choose.
How to inject data from CSV file in Gatling?
Include that file exist in the right directory (data) and has right data inside
Hopefully my message understandable I will appreciate any kind of help
Log:
18:42:54.456 [ERROR] i.g.c.ZincCompiler$ - C:\Users\nikol\OneDrive\Desktop\gatling-charts-highcharts-bundle-2.3.1\user-files\simulations\computerdatabase\BasicSimulation.scala:37: not found: value Article_ID
18:42:54.458 [ERROR] i.g.c.ZincCompiler$ - feed(csv(Article_ID.csv))
18:42:54.459 [ERROR] i.g.c.ZincCompiler$ - ^
18:42:54.584 [ERROR] i.g.c.ZincCompiler$ - C:\Users\nikol\OneDrive\Desktop\gatling-charts-highcharts-bundle-2.3.1\user-files\simulations\computerdatabase\BasicSimulation.scala:40: not found: value Article_ID
18:42:54.584 [ERROR] i.g.c.ZincCompiler$ - .get(s"${Article_ID}") // changet value from Article_ID.csv to Article_ID
18:42:54.584 [ERROR] i.g.c.ZincCompiler$ - ^
18:42:54.635 [ERROR] i.g.c.ZincCompiler$ - two errors found
18:42:54.639 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed
package computerdatabase
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import io.gatling.jdbc.Predef._
class BasicSimulation extends Simulation {
val httpConf = http
.baseURL("http://my_link.com") // Here is the root for all relative URLs and this is example, this is not real link;
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
.doNotTrackHeader("1")
.acceptLanguageHeader("en-US,en;q=0.5")
.acceptEncodingHeader("gzip, deflate")
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")
val headers_10 = Map("Content-Type" -> "application/x-www-form-urlencoded") // Note the headers specific to a given request
val scn = scenario("Scenario Name") // A scenario is a chain of requests and pauses
feed(csv(Article_ID.csv))
.exec(http("Request")
.get(s"${Article_ID}") // changet value from Article_ID.csv to Article_ID
.pause(7))
setUp(scn.inject(atOnceUsers(1)).protocols(httpConf))
}
Well that code above produces an empty scenario (and I think it should not compile). Its because feed()
method is not used in scenario builder chain but separately. What you need to do is to call all the steps as chain fe.:
val scn = scenario("Scenario Name")
.feed(csv(Article_ID.csv))
.exec(http("Request"))
.get(s"${Article_ID}")
.pause(7))
If it is not the issue and you just pasted code with error then check if CSV file has proper format. First line of CSV should contain attribute names (I know often people forget about it) fe.:
Article_ID, OtherColumn, AnotherColumn
1, Test, Lorem Ipsum
2, Abc, Dolor Sit Amet
3, Xyz, Consectetur Adipiscing