我在使用 gatling-amqp-plugin 从 gatling 连接到 rabbit q 时遇到问题

I'm having problems connecting from gatling to a rabbit q using gatling-amqp-plugin

我在这里完全被难住了(scala 神秘的 cryptocityness 没有帮助:-))

我正在尝试使用 rabbitmq 设置 gatling 测试(即我想将消息推送到 rabbit q 并计算出现在第二个队列中需要多长时间) 我正在使用 gatling-amqp-plugin 来执行此操作,因为 gatling 本身不支持 amqp。

为了让这个更适合我 "interesting",我不使用 Scala 编写代码,也从未使用过 gatling ....

所以我参加了"getting started"项目gatling-sbt-plugin-demo

一旦我确定示例计算机数据库负载测试有效,我就向项目添加了一个新包并放入了 amqp 项目的示例 PublishExample(以及所需的 Utils class)

我有一只本地兔子 docker 图片 运行ning ... 这是我使用的 docker-compose:

version: '3'

services:
  rabbi:
    image: rabbitmq:3.6-management
    hostname: "rabbi"
    expose:
      - "5672"
    ports:
      - "15672:15672"
      - "5672:5672"
    environment:
      RABBITMQ_DEFAULT_USER: "USER"
      RABBITMQ_DEFAULT_PASS: "PASS"
      RABBITMQ_DEFAULT_VHOST: "VOST"

然后我尝试使用 PublishExample 运行ning gatling

package rabbit

import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import ru.tinkoff.gatling.amqp.Predef._
import Utils._
import ru.tinkoff.gatling.amqp.protocol.AmqpProtocolBuilder

import scala.concurrent.duration._

class PublishExample extends Simulation {

  val amqpConf: AmqpProtocolBuilder = amqp
    .connectionFactory(
      rabbitmq
        .host("localhost")
        .port(5672)
        .username("USER")
        .password("PASS")
        .vhost("VOST")
    )
    .usePersistentDeliveryMode

  val scn: ScenarioBuilder = scenario("AMQP test")
    .feed(idFeeder)
    .exec(
      amqp("publish to exchange").publish
        .directExchange("test_queue", "test_key")
        .textMessage("Hello message - ${id}")
        .messageId("${id}")
        .priority(0)
        .property("testheader", "testvalue")
    )

  setUp(
    scn.inject(rampUsersPerSec(1) to 5 during (60 seconds), constantUsersPerSec(5) during (5 minutes))
  ).protocols(amqpConf)
    .maxDuration(10 minutes)

}

这是我得到的错误

:
sbt:gatling-sbt-plugin-demo> gatling:test
[info] Compiling 1 Scala source to<project_folder>/gatling-sbt-plugin-demo/target/scala-2.12/test-classes ...
[info] Compiling 1 Scala source to<project_folder>/gatling-sbt-plugin-demo/target/scala-2.12/gatling-classes ...
Simulation rabbit.PublishExample started...
Uncaught error from thread [GatlingSystem-akka.actor.default-dispatcher-6]: java.lang.reflect.Field.canAccess(Ljava/lang/Object;)Z, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[GatlingSystem]
java.lang.NoSuchMethodError: java.lang.reflect.Field.canAccess(Ljava/lang/Object;)Z
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.forceModify(AmqpProtocolMessage.scala:23)
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.$anonfun$mergeProperties(AmqpProtocolMessage.scala:18)
        at scala.collection.IndexedSeqOptimized.foldLeft(IndexedSeqOptimized.scala:60)
        at scala.collection.IndexedSeqOptimized.foldLeft$(IndexedSeqOptimized.scala:68)
        at scala.collection.mutable.ArrayOps$ofRef.foldLeft(ArrayOps.scala:198)
  | => gat ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.$anonfun$mergeProperties(AmqpProtocolMessage.scala:18)
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.$anonfun$mergeProperties(AmqpProtocolMessage.scala:14)
        at com.softwaremill.quicklens.package$PathModify.using(package.scala:62)
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.mergeProperties(AmqpProtocolMessage.scala:16)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.$anonfun$sendRequest(AmqpAction.scala:27)
        at io.gatling.commons.validation.Success.map(Validation.scala:45)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.$anonfun$sendRequest(AmqpAction.scala:27)
        at io.gatling.commons.validation.Success.flatMap(Validation.scala:46)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.sendRequest(AmqpAction.scala:24)
        at io.gatling.core.action.RequestAction.$anonfun$execute(Action.scala:100)
        at io.gatling.commons.validation.Success.flatMap(Validation.scala:46)
        at io.gatling.core.action.RequestAction.execute(Action.scala:97)
        at io.gatling.core.action.RequestAction.execute$(Action.scala:96)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.execute(AmqpAction.scala:12)
        at io.gatling.core.action.Action.$bang(Action.scala:38)
        at io.gatling.core.action.Action.$bang$(Action.scala:38)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.io$gatling$core$action$ChainableAction$$super$$bang(AmqpAction.scala:12)
        at io.gatling.core.action.ChainableAction.$bang(Action.scala:63)
        at io.gatling.core.action.ChainableAction.$bang$(Action.scala:61)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.io$gatling$core$action$ExitableAction$$super$$bang(AmqpAction.scala:12)
        at io.gatling.core.action.ExitableAction.$bang(BlockExit.scala:141)
        at io.gatling.core.action.ExitableAction.$bang$(BlockExit.scala:139)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.$bang(AmqpAction.scala:12)
        at io.gatling.core.action.SingletonFeed$$anonfun$receive.applyOrElse(SingletonFeed.scala:71)
        at akka.actor.Actor.aroundReceive(Actor.scala:539)
        at akka.actor.Actor.aroundReceive$(Actor.scala:537)
        at io.gatling.core.akka.BaseActor.aroundReceive(BaseActor.scala:25)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:612)
        at akka.actor.ActorCell.invoke(ActorCell.scala:581)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268)
        at akka.dispatch.Mailbox.run(Mailbox.scala:229)
        at akka.dispatch.Mailbox.exec(Mailbox.scala:241)
        at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
[info] Simulation(s) execution ended.
[error] Error during tests:
[error]         Running java with options -classpath <my system class path> 
sbt.ForkMain 51328 failed with exit code 255
[error] (Gatling / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 3 s, completed 26-Apr-2020 22:06:37
sbt:gatling-sbt-plugin-demo> 

我到底在做什么?我已尝试对 host/vhost/directExchange 配置进行各种更改,但我无法弄清楚我做错了什么!!!

此外,当我 运行 上面的代码时,这些是来自 Rabbit 的日志:

rabbi_1  |
rabbi_1  | =INFO REPORT==== 26-Apr-2020::21:12:13 ===
rabbi_1  | accepting AMQP connection <0.619.0> (172.20.0.1:56118 -> 172.20.0.2:5672)
rabbi_1  |
rabbi_1  | =INFO REPORT==== 26-Apr-2020::21:12:13 ===
rabbi_1  | connection <0.619.0> (172.20.0.1:56118 -> 172.20.0.2:5672): user 'USER' authenticated and granted access to vhost 'VOST'
rabbi_1  |
rabbi_1  | =WARNING REPORT==== 26-Apr-2020::21:12:14 ===
rabbi_1  | closing AMQP connection <0.619.0> (172.20.0.1:56118 -> 172.20.0.2:5672, vhost: 'VOST', user: 'USER'):
rabbi_1  | client unexpectedly closed TCP connection

所以我知道我是 'connecting' 兔子

Stacktrace 是不言自明的:

java.lang.NoSuchMethodError: java.lang.reflect.Field.canAccess(Ljava/lang/Object;)Z
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.forceModify(AmqpProtocolMessage.scala:23)

This method was introduced in Java 9,意味着此第三方插件需要 运行 和 Java 9+(与 3.3 要求 Java 8 的官方 Gatling 组件相反.1).