From 28863da45938044b2d54cc89e2ab6ac515267681 Mon Sep 17 00:00:00 2001 From: Stelios Anastasakis Date: Fri, 17 Jan 2025 13:19:56 +0200 Subject: [PATCH] [SCALA-568] Point gatling to a scala REST API --- scala-gatling/README.md | 8 ++++++-- .../com/baeldung/gatling/PeakLoadSimulation.scala | 10 +++++----- .../scala/com/baeldung/gatling/ScenariosProvider.scala | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scala-gatling/README.md b/scala-gatling/README.md index 00e62d269..2fa9e1f13 100644 --- a/scala-gatling/README.md +++ b/scala-gatling/README.md @@ -2,5 +2,9 @@ - [Testing With Gatling Using Scala]() ### Gatling Executions -compile tests: `sbt test:compile` -then run the simulation: `sbt 'Gatling/testOnly com.baeldung.gatling.PeakLoadSimulation'` +From this module's folder, we first compile tests: `sbt test:compile` + +Then run the simulation: `sbt 'Gatling/testOnly com.baeldung.gatling.PeakLoadSimulation'` + +**Notes**: in order to spin-up the right API this example uses, we also need to start the server: +`sbt resApi/run` from root folder diff --git a/scala-gatling/src/test/scala/com/baeldung/gatling/PeakLoadSimulation.scala b/scala-gatling/src/test/scala/com/baeldung/gatling/PeakLoadSimulation.scala index 186863d1f..506ba463e 100644 --- a/scala-gatling/src/test/scala/com/baeldung/gatling/PeakLoadSimulation.scala +++ b/scala-gatling/src/test/scala/com/baeldung/gatling/PeakLoadSimulation.scala @@ -9,22 +9,22 @@ class PeakLoadSimulation extends Simulation { setUp( getScenario( "getExistingEndpoint", - simpleRequest("request_status_endpoint", "/health/status", 200), + simpleRequest("request_todo_endpoint", "/todo", 200), 50, 10, 60 ), getScenario( "nonExistingEndpoint", - simpleRequest("request_wrong_endpoint", "/health/status1", 200), + simpleRequest("request_wrong_endpoint", "/not-todo", 200), 5, 10, 60 ) ).assertions( - details("request_status_endpoint").successfulRequests.percent.gt(99.99), - details("request_status_endpoint").responseTime.percentile4.lt(20), - details("request_status_endpoint").requestsPerSec.gt(40), + details("request_todo_endpoint").successfulRequests.percent.gt(99.99), + details("request_todo_endpoint").responseTime.percentile4.lt(20), + details("request_todo_endpoint").requestsPerSec.gt(40), details("request_wrong_endpoint").successfulRequests.percent.lt(1), details("request_wrong_endpoint").responseTime.percentile4.lt(20) ) diff --git a/scala-gatling/src/test/scala/com/baeldung/gatling/ScenariosProvider.scala b/scala-gatling/src/test/scala/com/baeldung/gatling/ScenariosProvider.scala index 3a5b9259b..1423f178d 100644 --- a/scala-gatling/src/test/scala/com/baeldung/gatling/ScenariosProvider.scala +++ b/scala-gatling/src/test/scala/com/baeldung/gatling/ScenariosProvider.scala @@ -9,7 +9,7 @@ import scala.language.postfixOps object ScenariosProvider { private val httpProtocol = - http.baseUrl("http://localhost:8080").disableCaching.disableFollowRedirect + http.baseUrl("http://localhost:9000").disableCaching.disableFollowRedirect def getScenario( scenarioName: String,