From bd8a2fa308a284865f0fb99f5d04a7c30112438c Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 29 Sep 2024 12:35:48 +0200 Subject: [PATCH 1/2] Fix tests --- .../appointments/GatlingSimulation.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java b/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java index 9a4fc94..359e5f5 100644 --- a/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java +++ b/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java @@ -2,19 +2,24 @@ import static io.gatling.javaapi.core.CoreDsl.*; import static io.gatling.javaapi.http.HttpDsl.*; +import static java.util.UUID.randomUUID; import io.gatling.javaapi.core.*; +import java.util.Map; +import java.util.stream.Stream; + public class GatlingSimulation extends Simulation { private ChainBuilder appointmentsCrud = exec( http("Create") .post("/appointments") + .header("Content-Type", "application/json") .body(StringBody(""" { - "users": [], - "startTimestamp": "2024-09-28T21:28:00.419367341", - "endTimestamp": "2024-09-28T21:28:00.4193957" + "id": "#{id}", + "startTimestamp": "2024-09-28T21:28:00", + "endTimestamp": "2024-09-28T21:28:00" } """ )) @@ -33,7 +38,12 @@ public class GatlingSimulation extends Simulation { { var baseUrl = "http://localhost:18080"; var httpProtocol = http.baseUrl(baseUrl); - var users = scenario("Appointments").exec(appointmentsCrud); + var users = scenario("Appointments") + .feed(Stream + .>generate(() -> Map.of("id", randomUUID().toString())) + .iterator() + ) + .exec(appointmentsCrud); setUp(users.injectOpen(rampUsers(10).during(10))).protocols(httpProtocol); } From 4b8fa06f896ef3f9b95812788674f51c89017138 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 29 Sep 2024 12:41:20 +0200 Subject: [PATCH 2/2] Fix tests --- .../appointments/GatlingSimulation.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java b/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java index 359e5f5..74b51bf 100644 --- a/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java +++ b/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java @@ -2,11 +2,11 @@ import static io.gatling.javaapi.core.CoreDsl.*; import static io.gatling.javaapi.http.HttpDsl.*; -import static java.util.UUID.randomUUID; import io.gatling.javaapi.core.*; import java.util.Map; +import java.util.UUID; import java.util.stream.Stream; public class GatlingSimulation extends Simulation { @@ -38,12 +38,13 @@ public class GatlingSimulation extends Simulation { { var baseUrl = "http://localhost:18080"; var httpProtocol = http.baseUrl(baseUrl); - var users = scenario("Appointments") - .feed(Stream - .>generate(() -> Map.of("id", randomUUID().toString())) - .iterator() - ) - .exec(appointmentsCrud); + var feeder = Stream + .generate(UUID::randomUUID) + .map(UUID::toString) + .>map(it -> Map.of("id", it)) + .iterator(); + + var users = scenario("Appointments").feed(feeder).exec(appointmentsCrud); setUp(users.injectOpen(rampUsers(10).during(10))).protocols(httpProtocol); }