Gatling: Random Feeder POST request: not found: value email (Gatling 3.0.0)

1.8k views Asked by At

**Randomized Load Testing with Gatling ** I want to test my built API for higher load, and therefore, I have to generate huge amount of random emails (I know there is currently no email-checking on the server, so I just create random strings). The tool I use is gatling-charts-highcharts-bundle-3.0.0 and I checked out other questions and webpages on how to solve this, and I got the information to use feeders. I tried the following code, but I don't get why there is an value not error always upcoming. Basically: I'm trying to create a randomized string feeder and use it in gatling 3.0.0, but when i do it the following way, I always receive a " not found: value email" error:

package computerdatabase

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import scala.util.Random

class testsimu extends Simulation {


val httpProtocol = http
.baseUrl("http://testurl.com/api") // Here is the root for all    relative URLs
.acceptHeader("application/json") // Here are the common headers
.acceptLanguageHeader("en;q=1.0,de-AT;q=0.9")
.acceptEncodingHeader("gzip;q=1.0,compress;q=0.5")
.userAgentHeader("TestApp/1.3.0(com.test.test;build:1;iOS12.1.0)Alamofire/4.7.0")

val headers_10 = Map("Content-Type" -> "application/json") // Note the  headers specific to a given request

val feeder = Iterator.continually(Map("email" -> (Random.alphanumeric.take(20).mkString)))

val scn = scenario("Login") // A scenario is a chain of requests and pauses
 // Note that Gatling has recorded real time pauses
.feed(feeder)
.exec(http("LoginRequest") // Here's an example of a POST request
  .post("/login")
  .headers(headers_10)
  .body(StringBody(s"""{ "testmail": ${email}, "testmailagain": ${email}, }""")).asJson)

setUp(scn.inject(constantUsersPerSec(10) during(5 seconds) randomized).protocols(httpConf))
}

Here the error message:

GATLING_HOME is set to  /Users/privat/Documents/test/Development/gatling-charts-highcharts-bundle-3.0.0
15:06:12.819 [ERROR] i.g.c.ZincCompiler$ - /Users/privat/Documents/test/Development/gatling-charts-highcharts-bundle-  3.0.0/user-files/simulations/test/test.scala:45:46: not found: value email
  .body(StringBody(s"""{ "testmail": ${email}, "testmailagain": ${email}, }""")).asJson)
                                         ^
15:06:12.821 [ERROR] i.g.c.ZincCompiler$ - /Users/privat/Documents/test/Development/gatling-charts-highcharts-bundle-3.0.0/user-files/simulations/higgs/higgs-sim.scala:45:103: not found: value email
  .body(StringBody(s"""{ "testmail": ${email}, "testmailagain": ${email}, }""")).asJson)
                                                                                                     ^
15:06:12.856 [ERROR] i.g.c.ZincCompiler$ - two errors found
15:06:12.858 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed
sbt.internal.inc.CompileFailed: null
    ...

Why is there an "value not found" error coming?

1

There are 1 answers

0
themysteriousM On BEST ANSWER

I have found the solution: Instead of:

StringBody(s"""{ "testmail": ${email}, "testmailagain": ${email}, }""")).asJson

Use:

StringBody("""{ "testmail": ${email}, "testmailagain": ${email}, }""")).asJson