From 4d960614672657d226ad0c4beb3e09e784246b80 Mon Sep 17 00:00:00 2001 From: John Axe Date: Tue, 25 Jun 2024 19:06:58 -0300 Subject: [PATCH] feat: update gatling 3.11.4 --- project/Dependencies.scala | 2 +- project/build.properties | 2 +- .../actions/KafkaAvro4sRequestAction.scala | 7 ++++--- .../kafka/actions/KafkaRequestAction.scala | 7 ++++--- .../kafka/checks/KafkaMessagePreparer.scala | 2 +- .../gatling/kafka/examples/GatlingRunner.scala | 17 ++++++++++++----- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 21daefb..a27a943 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -3,7 +3,7 @@ import sbt.* object Dependencies { private object Versions { val kafka = "7.6.0-ce" - val gatling = "3.10.5" + val gatling = "3.11.4" val avro4s = "4.1.2" val avro = "1.11.3" } diff --git a/project/build.properties b/project/build.properties index 7d5f1d8..fa8b6a1 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ # suppress inspection "UnusedProperty" -sbt.version=1.9.9 \ No newline at end of file +sbt.version=1.10.0 \ No newline at end of file diff --git a/src/main/scala/org/galaxio/gatling/kafka/actions/KafkaAvro4sRequestAction.scala b/src/main/scala/org/galaxio/gatling/kafka/actions/KafkaAvro4sRequestAction.scala index 050db2c..dfede50 100644 --- a/src/main/scala/org/galaxio/gatling/kafka/actions/KafkaAvro4sRequestAction.scala +++ b/src/main/scala/org/galaxio/gatling/kafka/actions/KafkaAvro4sRequestAction.scala @@ -30,9 +30,10 @@ class KafkaAvro4sRequestAction[K, V]( attr requestName session flatMap { requestName => val outcome = sendRequest(requestName, producer, attr, throttled, session) - outcome.onFailure(errorMessage => - statsEngine.reportUnbuildableRequest(session.scenario, session.groups, requestName, errorMessage), - ) + outcome.onFailure(errorMessage => { + logger.error(errorMessage) + statsEngine.logRequestCrash(session.scenario, session.groups, requestName, s"Failed to build request: $errorMessage") + }) outcome } diff --git a/src/main/scala/org/galaxio/gatling/kafka/actions/KafkaRequestAction.scala b/src/main/scala/org/galaxio/gatling/kafka/actions/KafkaRequestAction.scala index 5f3b009..bba2b06 100644 --- a/src/main/scala/org/galaxio/gatling/kafka/actions/KafkaRequestAction.scala +++ b/src/main/scala/org/galaxio/gatling/kafka/actions/KafkaRequestAction.scala @@ -31,9 +31,10 @@ class KafkaRequestAction[K, V]( val outcome = sendRequest(requestName, producer, attr, throttled, session) - outcome.onFailure(errorMessage => - statsEngine.reportUnbuildableRequest(session.scenario, session.groups, requestName, errorMessage), - ) + outcome.onFailure(errorMessage => { + logger.error(errorMessage) + statsEngine.logRequestCrash(session.scenario, session.groups, requestName, s"Failed to build request: $errorMessage") + }) outcome diff --git a/src/main/scala/org/galaxio/gatling/kafka/checks/KafkaMessagePreparer.scala b/src/main/scala/org/galaxio/gatling/kafka/checks/KafkaMessagePreparer.scala index 56e87e4..1ddd0fb 100644 --- a/src/main/scala/org/galaxio/gatling/kafka/checks/KafkaMessagePreparer.scala +++ b/src/main/scala/org/galaxio/gatling/kafka/checks/KafkaMessagePreparer.scala @@ -42,7 +42,7 @@ object KafkaMessagePreparer { messageCharset(configuration, msg) .flatMap(bodyCharset => if (msg.value.length > CharsParsingThreshold) - jsonParsers.safeParse(new ByteArrayInputStream(msg.value), bodyCharset) + jsonParsers.safeParse(new ByteArrayInputStream(msg.value)) else jsonParsers.safeParse(new String(msg.value, bodyCharset)), ) diff --git a/src/test/scala/org/galaxio/gatling/kafka/examples/GatlingRunner.scala b/src/test/scala/org/galaxio/gatling/kafka/examples/GatlingRunner.scala index 601fbb2..d8913ee 100644 --- a/src/test/scala/org/galaxio/gatling/kafka/examples/GatlingRunner.scala +++ b/src/test/scala/org/galaxio/gatling/kafka/examples/GatlingRunner.scala @@ -1,7 +1,7 @@ package org.galaxio.gatling.kafka.examples import io.gatling.app.Gatling -import io.gatling.core.config.GatlingPropertiesBuilder +import io.gatling.shared.cli.GatlingCliOptions object GatlingRunner { @@ -10,10 +10,17 @@ object GatlingRunner { // this is where you specify the class you want to run val simulationClass = classOf[BasicSimulation].getName - val props = new GatlingPropertiesBuilder - props.simulationClass(simulationClass) - - Gatling.fromMap(props.build) + Gatling.main( + args ++ + Array( + GatlingCliOptions.Simulation.shortOption, + simulationClass, + GatlingCliOptions.ResultsFolder.shortOption, + "results", + GatlingCliOptions.Launcher.shortOption, + "sbt", + ), + ) } }