Blazemeter 中的 Gatling 测试创建 ClassNotFoundException

Gatling Test in Blazemeter creates ClassNotFoundException

我使用 Taurus Gatling 指南创建了一个简单的性能测试并将 yaml 和 scala 文件上传到 blazemeter。当我在 blazemeter 中开始测试时,没有测试结果并且 bzt.log 包含 ClassNotFoundException.

yaml 的验证器说它很好,但我找不到任何东西,所以我迷路了...

我的blazemleter.yaml:

execution:
  - executor: gatling
    scenario: products

    iterations: 15
    concurrency: 3
    ramp-up: 2

scenarios:
  products:
    script: productSimulation.scala
    simulation: test.productSimulation

我的 productSimulation.scala 主要是从他们的文档中复制的:

package test

import io.gatling.core.Predef._
import io.gatling.http.Predef._

class productSimulation extends Simulation {
    // parse load profile from Taurus
    val t_iterations = Integer.getInteger("iterations", 100).toInt
    val t_concurrency = Integer.getInteger("concurrency", 10).toInt
    val t_rampUp = Integer.getInteger("ramp-up", 1).toInt
    val t_holdFor = Integer.getInteger("hold-for", 60).toInt
    val t_throughput = Integer.getInteger("throughput", 100).toInt
    val httpConf = http.baseURL("https://mydomain/")

    val header = Map(
        "Content-Type" -> """application/x-www-form-urlencoded""")

    val sessionHeaders = Map("Authorization" -> "Bearer ${access_token}",
        "Content-Type" -> "application/json")

    // 'forever' means each thread will execute scenario until
    // duration limit is reached
    val loopScenario = scenario("products").forever() {
        // auth
        exec(http("POST OAuth Req")
            .post("https://oauth-provider")
            .formParam("client_secret", "...")
            .formParam("client_id", "...")
            .formParam("grant_type", "client_credentials")
            .headers(header)
            .check(status.is(200))
            .check(jsonPath("$.access_token").exists
                .saveAs("access_token")))
            // read products
            .exec(http("products")
                .get("/products")
                .queryParam("limit", 200)
                .headers(sessionHeaders))
    }

    val execution = loopScenario
        .inject(rampUsers(concurrency) over rampUp) // during for gatling 3.x
        .protocols(httpConf)

    setUp(execution).maxDuration(rampUp + holdFor)
}

在了解到如果我直接单击文件而不是 yaml 可以直接执行 scala 文件作为测试,我得到了更好的异常。

基本上我犯了两个错误:

  1. 我的变量被命名为 t_concurrency, ... 而执行定义使用不同的名称。 up.
  2. 因为 gatling 3.x 注入的关键字是 during,所以正确的代码是:rampUsers(t_concurrency) during t_rampUp

现在一切正常。