I'm using gatling in linux terminal. When I pass parameter like described in github I get error:

 value users is not a member of Integer

This is my code:

package mypackage

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import io.gatling.http.Headers.Names._
import scala.concurrent.duration._
import bootstrap._
import assertions._
import util.Random

class MySimulation extends Simulation {

    val usersCount = Integer.getInteger("users", 1)
    val links = csv("links.csv").random

    val httpProtocol = http
        .baseURL("http://mywebsite.com:8080/")
        .acceptCharsetHeader("ISO-8859-1,utf-8;q=0.7,*;q=0.7")
        .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
        .acceptEncodingHeader("gzip, deflate")
        .acceptLanguageHeader("fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3")
        .disableFollowRedirect

    val headers_1 = Map(
        "Keep-Alive" -> "115")
        val headers_3 = Map(
                "Keep-Alive" -> "115",
                "Content-Type" -> "application/x-www-form-urlencoded")

        val scn = scenario("big project benchmark")
        .repeat(50) {
            feed(links)
            .exec(
                    http("request_1")
                            .get("${pageUri}")
                            .headers(headers_1)).pause(1000 millisecond)
        }

    setUp(scn.inject(ramp(usersCount users) over (30 seconds)))
        .protocols(httpProtocol)
        .assertions(global.successfulRequests.percent.is(100), details("request_1").responseTime.max.lessThan(1000))

I start this in terminal using:

JAVA_OPTS="-Dusers=300" ./gatling.sh -s mypackage.mySimulation -on testing -sd test1

Please, be patient, because I'm totally new to scala and gatling. Thanks for any help.

有帮助吗?

解决方案

The problem comes from the usersCount users part of the setUp.

In Scala, this is interpreted as usersCount.users which, in our case does not exist since Integer does not have a users method.

I think (but I'm not sure since I cannot test it right now), that you should make usersCount an Int like so: val usersCount: Int = Integer.getInteger("users", 1).toInt.

Hope this helps!

PS: The reason you should convert Integer to Int is because of implicit conversions. This is a really powerful feature of Scala.

PPS: The wiki documentation was valid for Gatling 1.X, it will be updated accordingly for Gatling 2.X

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top