diff --git a/README.md b/README.md index e5fc028..c9e71f0 100644 --- a/README.md +++ b/README.md @@ -125,3 +125,15 @@ The verification requests can be executed with: `src/test/resources/requests.sh` `PORT=9090 src/test/resources/requests.sh` if you want to run them to a different port. The health check endpoint is: http://localhost:18080/actuator/health + +### Stress Testing (Gatling) +[Gatling settings] can be overridden creating a `gatling.conf` file at the test resources. The +configuration options and their default values can be checked [here][gatlingDefaults]. + +Those parameters can also be overwritten by system properties from the command line. I.e.: +`-D gatling.core.encoding=utf-8` + +To run the Gatling test, execute `./mvnw gatling:test` at the shell. + +[Gatling settings]: https://docs.gatling.io/reference/script/core/configuration +[gatlingDefaults]: https://github.com/gatling/gatling/blob/main/gatling-core/src/main/resources/gatling-defaults.conf diff --git a/src/main/java/com/github/jaguililla/appointments/input/controllers/AppointmentsController.java b/src/main/java/com/github/jaguililla/appointments/input/controllers/AppointmentsController.java index 96fcdb3..21a6a2c 100644 --- a/src/main/java/com/github/jaguililla/appointments/input/controllers/AppointmentsController.java +++ b/src/main/java/com/github/jaguililla/appointments/input/controllers/AppointmentsController.java @@ -36,7 +36,7 @@ public ResponseEntity createAppointment( final var createdAppointment = appointmentsService.create(appointment, users); final var responseAppointment = AppointmentsMapper.appointmentResponse(createdAppointment); - return ResponseEntity.ofNullable(responseAppointment); + return ResponseEntity.status(201).body(responseAppointment); } @Override diff --git a/src/main/java/com/github/jaguililla/appointments/input/controllers/UsersController.java b/src/main/java/com/github/jaguililla/appointments/input/controllers/UsersController.java index 7b5704b..963d017 100644 --- a/src/main/java/com/github/jaguililla/appointments/input/controllers/UsersController.java +++ b/src/main/java/com/github/jaguililla/appointments/input/controllers/UsersController.java @@ -30,6 +30,6 @@ public ResponseEntity createUser(final UserRequest userRequest) { final var createdUser = appointmentsService.create(user); final var responseUser = UsersMapper.userResponse(createdUser); - return ResponseEntity.ofNullable(responseUser); + return ResponseEntity.status(201).body(responseUser); } } diff --git a/src/main/resources/openapi/api.yml b/src/main/resources/openapi/api.yml index 04b7e73..66f9707 100644 --- a/src/main/resources/openapi/api.yml +++ b/src/main/resources/openapi/api.yml @@ -19,7 +19,7 @@ paths: schema: $ref: 'schemas.yml#/components/schemas/UserRequest' responses: - "200": + "201": description: OK content: application/json: @@ -36,7 +36,7 @@ paths: schema: $ref: 'schemas.yml#/components/schemas/AppointmentRequest' responses: - "200": + "201": description: OK content: application/json: diff --git a/src/test/java/com/github/jaguililla/appointments/ApplicationIT.java b/src/test/java/com/github/jaguililla/appointments/ApplicationIT.java index bed38bc..df77bad 100644 --- a/src/test/java/com/github/jaguililla/appointments/ApplicationIT.java +++ b/src/test/java/com/github/jaguililla/appointments/ApplicationIT.java @@ -99,7 +99,7 @@ void appointments_can_be_created_read_and_deleted() { .endTimestamp(LocalDateTime.now()) ); var response = client.getResponseBody(AppointmentResponse.class); - assertEquals(200, client.getResponseStatus().value()); + assertEquals(201, client.getResponseStatus().value()); assertTrue(getLastMessage().startsWith("Appointment created at")); client.get("/appointments/" + response.getId()); assertEquals(200, client.getResponseStatus().value()); diff --git a/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java b/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java index 2f40885..d9643a0 100644 --- a/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java +++ b/src/test/java/com/github/jaguililla/appointments/GatlingSimulation.java @@ -8,12 +8,19 @@ public class GatlingSimulation extends Simulation { private ChainBuilder appointmentsCrud = exec( - http("Create").post("/appointments").check(status().is(201)), + http("Create") + .post("/appointments") + .body(StringBody("")) + .check(status().is(201)) + .check(jmesPath("id").saveAs("id")), pause(1), - http("Read").get("/appointments").check(status().is(200)), + http("Read") + .get("/appointments/#{id}") + .check(status().is(200)), pause(1), - http("Delete").delete("/appointments").check(status().is(200)), - pause(1) + http("Delete") + .delete("/appointments/#{id}") + .check(status().is(200)) ); {