calucifer
calucifer

Reputation: 23

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

I'm totally stumped here (and scala's cryptic cryptocityness isn't helping :-))

I'm trying to setup gatling tests using rabbitmq (ie I want to push messages into a rabbit q and time how long it takes to appear in a second queue) I'm using the gatling-amqp-plugin to do this since gatling doesn't natively support amqp.

To make this more "interesting" for me, I don't code in Scala and have never used gatling ....

So I took the "getting started" project gatling-sbt-plugin-demo

Once I was sure that the sample computerdatabase load tests worked, I added a new package to the project and put in the example PublishExample from the amqp project (as well as the required Utils class)

I have a local rabbit docker image running ... this is the docker-compose I used:

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"

I then tried running gatling using the PublishExample

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)

}

And this is the error I get

:
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$3(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$2(AmqpProtocolMessage.scala:18)
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.$anonfun$mergeProperties$1(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$2(AmqpAction.scala:27)
        at io.gatling.commons.validation.Success.map(Validation.scala:45)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.$anonfun$sendRequest$1(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$1(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$1.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> 

What exatly am I doing wring here? I've tried various changes to the host/vhost/directExchange configs but I cant figure out what I'm doing wrong!!!

Also these are the logs from Rabbit when I run that code above:

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

So I know I am 'connecting' to rabbit

Upvotes: 0

Views: 991

Answers (1)

St&#233;phane LANDELLE
St&#233;phane LANDELLE

Reputation: 6623

Stacktrace is self-explanatory:

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, meaning this third-party plugin needs to run with Java 9+ (on contrary to official Gatling components that require Java 8 as of 3.3.1).

Upvotes: 1

Related Questions