类路径中缺少符号“type io.gadling.core.check.FindCheckBuilder”

问题描述 投票:0回答:1

我尝试使用 Grpc 实现加特林,如下脚本,作者:phiSgr:

package load

import com.github.phisgr.gatling.grpc.Predef._
import example.myapp.helloworld.grpc.hello_world.{GreeterServiceGrpc, HelloRequest}
import io.gatling.core.Predef.{stringToExpression => _, _}
import io.grpc.Status
import load.Constants.grpcPsgConf
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

import scala.concurrent.duration.DurationInt
import scala.language.postfixOps

class GrpcSimulation extends Simulation {

  val scn = scenario("Make Hello Request and Get Response")
    .exec(grpc("Hello Request")
      .rpc(GreeterServiceGrpc.METHOD_SAY_HELLO)
      .payload(HelloRequest("Gatling Load Test"))
      .extract(_.message.some)(_ saveAs "message")
      .check(statusCode is Status.Code.OK)
    )
    .exec(grpc("Hello Request with parameter from session")
      .rpc(GreeterServiceGrpc.METHOD_SAY_HELLO)
      .payload(session => HelloRequest(session.attributes("message").asInstanceOf[String]))
      .check(statusCode is Status.Code.OK)
    )

  setUp(scn.inject(rampUsersPerSec(1) to (2) during (20 seconds)).protocols(grpcPsgConf.shareChannel))
}

当我运行sbt编译时,它可以成功完成,但是当我使用*sbt“Gattle / testOnly.GrpcSimulation”时,它会返回这两个错误:

[error] C:\Users\TriNP\Desktop\gatlingGrpc\gatling-grpc-tests-sample\src\test\scala\load\BiDiStreamingSimulation.scala:16:23: Symbol 'type io.gatling.core.check.FindCheckBuilder' is missing from the classpath.
[error] This symbol is required by 'value com.github.phisgr.gatling.grpc.check.GrpcCheckSupport.findCheckBuilder'.
[error] Make sure that type FindCheckBuilder is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'GrpcCheckSupport.class' was compiled against an incompatible version of io.gatling.core.check.
[error]   val bidiCall = grpc("BiDi call").bidiStream("bidi")
[error]                       ^
[error] C:\Users\TriNP\Desktop\gatlingGrpc\gatling-grpc-tests-sample\src\test\scala\load\GrpcSimulation.scala:20:28: Symbol 'type io.gatling.core.check.FindCheckBuilder' is missing from the classpath.
[error] This symbol is required by 'value com.github.phisgr.gatling.grpc.request.CallDefinition.ts'.
[error] Make sure that type FindCheckBuilder is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'CallDefinition.class' was compiled against an incompatible version of io.gatling.core.check.
[error]       .payload(HelloRequest("Gatling Load Test"))
[error]                            ^
[error] two errors found
[error] (Test / compileIncremental) Compilation failed
[error] Total time: 1 s, completed 09:20:29, 25 thg 9, 2023
sbt:gatling-grpc-tests-sample> reload
[info] welcome to sbt 1.9.6 (Oracle Corporation Java 17.0.8)
[info] loading settings for project gatling-grpc-tests-sample-build from assembly.sbt,gatling.sbt,plugins.sbt,scalapb.sbt ...
[info] loading project definition from C:\Users\TriNP\Desktop\gatlingGrpc\gatling-grpc-tests-sample\project
[info] compiling 1 Scala source to C:\Users\TriNP\Desktop\gatlingGrpc\gatling-grpc-tests-sample\project\target\scala-2.12\sbt-1.0\classes ...
[error] C:\Users\TriNP\Desktop\gatlingGrpc\gatling-grpc-tests-sample\project\Dependencies.scala:2:11: object gatling is not a member of package sbt.io
[error] import io.gatling.core.Predef._
[error]           ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

我正在使用的build.sbt:

import Dependencies._

name := "gatling-grpc-tests-sample"

version := "0.1"

scalaVersion := "2.13.12"

libraryDependencies ++=  gatlingDependencies ++ loggingDependencies ++ grpcDependencies ++
  Seq(
    "com.github.daddykotex" %% "courier" % "3.0.0-M2a",
    "com.typesafe" % "config" % "1.4.1",
    "com.google.guava" % "guava" % "30.1.1-jre",
    "com.typesafe.akka" %% "akka-actor-typed" % "2.6.10",
    "com.typesafe.akka" %% "akka-protobuf-v3" % "2.6.10",
    "com.typesafe.akka" %% "akka-stream" % "2.6.10"
  )

enablePlugins(GatlingPlugin)

PB.targets in Compile := Seq(
  scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
)

加特林.sbt:

addSbtPlugin("io.gatling" % "gatling-sbt" % "4.5.0")

插件.sbt:

addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "1.1.1")

scalapb.sbt”

addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.0")

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.10.10"

如何解决此问题?有人可以向我解释根本原因吗?任何帮助将不胜感激。

更改 gatling 和 sbt 版本以匹配当前使用。

scala sbt gatling scala-gatling akka-grpc
1个回答
0
投票

这显然是不兼容的依赖版本。

OP在评论中说

但是,我已经声明我使用了 gatling-grpc v.0.16.0 和 gatling 3.9.5,仍然出现此错误”

可能的原因是版本已更改,但构建工具仍然使用旧版本。

在这个错误日志中,我们可以看到原因。

[info] compiling 1 Scala source to C:\Users\TriNP\Desktop\gatlingGrpc\gatling-grpc-tests-sample\project\target\scala-2.12\sbt-1.0\classes ...
[error] C:\Users\TriNP\Desktop\gatlingGrpc\gatling-grpc-tests-sample\project\Dependencies.scala:2:11: object gatling is not a member of package sbt.io
[error] import io.gatling.core.Predef._
[error]           ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

出于某种原因,OP 添加了

import io.gatling.core.Predef._
(测试代码的导入行)到构建脚本的文件 -
project/Dependencies.scala
。这个错误导致 sbt 无法重新加载并获取正确的依赖版本。


再次,正如我在上一个答案中指出的那样,不必使用

sbt
或编写Scala来使用Ga特林。鉴于 OP 的困惑,他们应该坚持使用更主流的工具,如 Gradle/Maven。

© www.soinside.com 2019 - 2024. All rights reserved.