首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >盲表中的Gatling测试创建ClassNotFoundException

盲表中的Gatling测试创建ClassNotFoundException
EN

Stack Overflow用户
提问于 2020-09-30 16:54:17
回答 1查看 122关注 0票数 0

我使用金牛座Gatling指南来创建一个简单的性能测试,并将yaml和scala文件上传到blazemeter。当我在报警器中启动测试时,没有测试结果,而且bzt.log包含一个ClassNotFoundException

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

我的blazemleter.yaml

代码语言:javascript
复制
execution:
  - executor: gatling
    scenario: products

    iterations: 15
    concurrency: 3
    ramp-up: 2

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

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

代码语言:javascript
复制
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)
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-30 17:19:07

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

我犯了两个错误:

  1. 我的变量被命名为t_concurrency ..。而执行定义使用不同的名称。因为gatling 3.x注入的关键字是

,所以正确的代码是:

现在一切都正常了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64142278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档