diff --git a/docs/images/tc0_active_users.png b/docs/images/tc0_active_users.png new file mode 100644 index 00000000..fd933569 Binary files /dev/null and b/docs/images/tc0_active_users.png differ diff --git a/docs/images/tc0_requests.png b/docs/images/tc0_requests.png new file mode 100644 index 00000000..9c8217bf Binary files /dev/null and b/docs/images/tc0_requests.png differ diff --git a/docs/images/tc0_response_time_distribution.png b/docs/images/tc0_response_time_distribution.png new file mode 100644 index 00000000..d4064378 Binary files /dev/null and b/docs/images/tc0_response_time_distribution.png differ diff --git a/docs/images/tc0_response_time_percentiles.png b/docs/images/tc0_response_time_percentiles.png new file mode 100644 index 00000000..423f2d34 Binary files /dev/null and b/docs/images/tc0_response_time_percentiles.png differ diff --git a/docs/images/tc0_response_times.png b/docs/images/tc0_response_times.png new file mode 100644 index 00000000..745bd4d5 Binary files /dev/null and b/docs/images/tc0_response_times.png differ diff --git a/docs/images/tc0_responses.png b/docs/images/tc0_responses.png new file mode 100644 index 00000000..9bc9c7c3 Binary files /dev/null and b/docs/images/tc0_responses.png differ diff --git a/docs/images/tc2_active_users.png b/docs/images/tc2_active_users.png new file mode 100644 index 00000000..3ed340f8 Binary files /dev/null and b/docs/images/tc2_active_users.png differ diff --git a/docs/images/tc2_requests.png b/docs/images/tc2_requests.png new file mode 100644 index 00000000..1a9ee628 Binary files /dev/null and b/docs/images/tc2_requests.png differ diff --git a/docs/images/tc2_response_time_distribution.png b/docs/images/tc2_response_time_distribution.png new file mode 100644 index 00000000..74842bab Binary files /dev/null and b/docs/images/tc2_response_time_distribution.png differ diff --git a/docs/images/tc2_response_time_percentiles.png b/docs/images/tc2_response_time_percentiles.png new file mode 100644 index 00000000..91310b0f Binary files /dev/null and b/docs/images/tc2_response_time_percentiles.png differ diff --git a/docs/images/tc2_response_times.png b/docs/images/tc2_response_times.png new file mode 100644 index 00000000..8c0d7e45 Binary files /dev/null and b/docs/images/tc2_response_times.png differ diff --git a/docs/images/tc2_responses.png b/docs/images/tc2_responses.png new file mode 100644 index 00000000..adc0ea18 Binary files /dev/null and b/docs/images/tc2_responses.png differ diff --git a/docs/src/12_testing.adoc b/docs/src/12_testing.adoc index 54712974..9d7e42e5 100644 --- a/docs/src/12_testing.adoc +++ b/docs/src/12_testing.adoc @@ -12,7 +12,21 @@ En nuestro proyecto, los tests unitarios son fundamentales para garantizar la co Buscaremos garantizar que la aplicación sea fácil de usar para proporcionar una experiencia satisfactoria al usuario. Nos centraremos en verificar diversas funcionalidades, desde la jugabilidad hasta acciones como el registro e inicio de sesión. Simularemos interacciones que haría un usuario real para asegurar que la aplicación sea intuitiva y funcione correctamente. === Tests de carga -Hemos realizado pruebas con 120 usuarios llegado a una tasa de 2 usuarios por segundo. La prueba consiste en logearse, jugar una partida, consultar todos los apartados de la barra de navegación, cambiar los ajustes bajando el numero de preguntas y volviendo a jugar una partida. +Hemos realizado inicialmente una prueba con un usuario por segundo durante 60 segundos de tal forma que quedaría en un computo total de 60 usuarios. La prueba consiste en logearse, jugar una partida, consultar todos los apartados de la barra de navegación, cambiar los ajustes bajando el numero de preguntas y volviendo a jugar una partida. + +image::tc0_response_times.png["Tiempos de respuesta"] + +image::tc0_active_users.png["Usuarios activos a lo largo de la simulación"] + +image::tc0_response_time_distribution.png["Distribución de tiempos de respuesta"] + +image::tc0_response_time_percentiles.png["Percentiles de tiempos de respuesta"] + +image::tc0_requests.png["Peticiones por segundo"] + +image::tc0_responses.png["Respuestas por segundo"] + +Posteriormente realizamos siguiendo una tasa de 2 usuarios por segundo durante 60 segundos llegando a un total de 120 usuarios. Cada usuario haría las mismas operaciones que se han descrito antes. image::tc_response_times.png["Tiempos de respuesta"] @@ -20,12 +34,27 @@ image::tc_active_users.png["Usuarios activos a lo largo de la simulación"] image::tc_response_time_distribution.png["Distribución de tiempos de respuesta"] -image::tc_response_time_distribution.png["Percentiles de tiempos de respuesta"] +image::tc_response_time_percentiles.png["Percentiles de tiempos de respuesta"] image::tc_requests.png["Peticiones por segundo"] image::tc_responses.png["Respuestas por segundo"] +Finalmente hemos hecho pruebas metiendo un total de 300 usuarios a una tasa de 5 usuarios por segundo duante un tiempo de 60 segundos. Los cuales probarian las mismas funcionalidades que los anteriores. + +image::tc2_response_times.png["Tiempos de respuesta"] + +image::tc2_active_users.png["Usuarios activos a lo largo de la simulación"] + +image::tc2_response_time_distribution.png["Distribución de tiempos de respuesta"] + +image::tc2_response_time_percentiles.png["Percentiles de tiempos de respuesta"] + +image::tc2_requests.png["Peticiones por segundo"] + +image::tc2_responses.png["Respuestas por segundo"] + + === SonarCloud En la siguiente imagen podemos comprobar todos los analisis realizados por SonarCloud. diff --git a/testscarga/Wiq6bRecordedSimulation.scala b/testscarga/Wiq6bRecordedSimulation.scala new file mode 100644 index 00000000..b205a185 --- /dev/null +++ b/testscarga/Wiq6bRecordedSimulation.scala @@ -0,0 +1,300 @@ + +import scala.concurrent.duration._ + +import io.gatling.core.Predef._ +import io.gatling.http.Predef._ +import io.gatling.jdbc.Predef._ + +class Wiq6bRecordedSimulation extends Simulation { + + private val httpProtocol = http + .baseUrl("http://localhost:8000") + .inferHtmlResources(AllowList(), DenyList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.woff2""", """.*\.(t|o)tf""", """.*\.png""", """.*\.svg""", """.*detectportal\.firefox\.com.*""")) + .acceptHeader("application/json, text/plain, */*") + .acceptEncodingHeader("gzip, deflate") + .acceptLanguageHeader("es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3") + .userAgentHeader("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0") + + private val headers_0 = Map( + "Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", + "If-None-Match" -> """"3c862bbc1ba2a89e451c9d8d3d365a19827dc2ae"""", + "Upgrade-Insecure-Requests" -> "1" + ) + + private val headers_1 = Map( + "Accept" -> "*/*", + "Access-Control-Request-Headers" -> "content-type", + "Access-Control-Request-Method" -> "POST", + "Origin" -> "http://localhost:3000" + ) + + private val headers_2 = Map( + "Content-Type" -> "application/json", + "Origin" -> "http://localhost:3000" + ) + + private val headers_3 = Map( + "If-None-Match" -> """W/"a5c-r9xOtMWbZEzZI2TqL9O6Tdf1bqY"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_6 = Map( + "If-None-Match" -> """W/"34a-FUrjyaJDVQQDWO4HbzuGW49wDMI"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_9 = Map( + "If-None-Match" -> """W/"6c2-i6K5S4RHJ2BcaN1W6mditMzLriA"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_10 = Map( + "If-None-Match" -> """W/"8cf-yHmo8Sw2yNOecfGQBNNcYQsDnjg"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_11 = Map( + "If-None-Match" -> """W/"f7-YI2arCNvYhzAHRVLlO3TB36U2So"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_12 = Map( + "If-None-Match" -> """W/"115-PA+rrpyQFydlm4/0l+EhgSICZuM"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_15 = Map( + "If-None-Match" -> """W/"127-YbiWZMpirJu7Rka184SS84CBlQI"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_17 = Map( + "If-None-Match" -> """W/"100-/EYlHGp0eIVjPTlcmVf1Ls/Brik"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_20 = Map( + "If-None-Match" -> """W/"d9-FI8Dt0Fbnr6hNv/VRMxA+FpCJLc"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_22 = Map( + "If-None-Match" -> """W/"122-GCG8moAuGSQg1s7KtPlOh7xD21w"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_25 = Map( + "If-None-Match" -> """W/"101-FzG5ePEDcv7vr6TMOZS3F8UT958"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_27 = Map( + "If-None-Match" -> """W/"100-CYJ6sQ0+shbhwj5rCWGwSh8rQEE"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_30 = Map( + "If-None-Match" -> """W/"11e-F2Jou1xGkwAYHwp8OpIG3t/3Xas"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_32 = Map( + "If-None-Match" -> """W/"101-lH9XV76sMe2sZBk6gzOT0pyGtIU"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_39 = Map( + "If-None-Match" -> """W/"10f-0GM+TtVx85iXPKtQL1voQu9Tc/0"""", + "Origin" -> "http://localhost:3000" + ) + + private val headers_41 = Map( + "If-None-Match" -> """W/"75e-gx9ZUg6kIR0udbJav7fuPIXztnE"""", + "Origin" -> "http://localhost:3000" + ) + + private val uri1 = "localhost" + + private val scn = scenario("Wiq6bRecordedSimulation") + .exec( + http("request_0") + .get("http://" + uri1 + ":3000/") + .headers(headers_0), + pause(4), + http("request_1") + .options("/login") + .headers(headers_1) + .resources( + http("request_2") + .post("/login") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0002_request.json")), + http("request_3") + .get("/getAllUsers") + .headers(headers_3), + http("request_4") + .options("/createUserRank") + .headers(headers_1), + http("request_5") + .post("/createUserRank") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0005_request.json")), + http("request_6") + .get("/actRanking") + .headers(headers_6), + http("request_7") + .options("/updateAllRanking") + .headers(headers_1), + http("request_8") + .post("/updateAllRanking") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0008_request.json")), + http("request_9") + .get("/getRecords/luismi") + .headers(headers_9) + ), + pause(1), + http("request_10") + .get("/obtainRank") + .headers(headers_10), + pause(6), + http("request_11") + .get("/getRandomQuestionSports") + .headers(headers_11), + pause(3), + http("request_12") + .get("/getRandomQuestionSports") + .headers(headers_12) + .resources( + http("request_13") + .options("/addGeneratedQuestion") + .headers(headers_1), + http("request_14") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0014_request.json")) + ), + pause(3), + http("request_15") + .get("/getRandomQuestionSports") + .headers(headers_15) + .resources( + http("request_16") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0016_request.json")) + ), + pause(3), + http("request_17") + .get("/getRandomQuestionSports") + .headers(headers_17) + .resources( + http("request_18") + .options("/addGeneratedQuestion") + .headers(headers_1), + http("request_19") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0019_request.json")) + ), + pause(3), + http("request_20") + .get("/getRandomQuestionSports") + .headers(headers_20) + .resources( + http("request_21") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0021_request.json")) + ), + pause(3), + http("request_22") + .get("/getRandomQuestionSports") + .headers(headers_22) + .resources( + http("request_23") + .options("/addGeneratedQuestion") + .headers(headers_1), + http("request_24") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0024_request.json")) + ), + pause(3), + http("request_25") + .get("/getRandomQuestionSports") + .headers(headers_25) + .resources( + http("request_26") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0026_request.json")) + ), + pause(3), + http("request_27") + .get("/getRandomQuestionSports") + .headers(headers_27) + .resources( + http("request_28") + .options("/addGeneratedQuestion") + .headers(headers_1), + http("request_29") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0029_request.json")) + ), + pause(3), + http("request_30") + .get("/getRandomQuestionSports") + .headers(headers_30) + .resources( + http("request_31") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0031_request.json")) + ), + pause(3), + http("request_32") + .get("/getRandomQuestionSports") + .headers(headers_32) + .resources( + http("request_33") + .options("/addGeneratedQuestion") + .headers(headers_1), + http("request_34") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0034_request.json")), + http("request_35") + .options("/addRecord") + .headers(headers_1), + http("request_36") + .post("/addRecord") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0036_request.json")), + http("request_37") + .options("/updateRanking") + .headers(headers_1), + http("request_38") + .post("/updateRanking") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0038_request.json")) + ), + pause(3), + http("request_39") + .get("/getRandomQuestionSports") + .headers(headers_39) + .resources( + http("request_40") + .post("/addGeneratedQuestion") + .headers(headers_2) + .body(RawFileBody("wiq6brecordedsimulation/0040_request.json")) + ), + pause(2), + http("request_41") + .get("/getRecords/luismi") + .headers(headers_41) + ) + + setUp(scn.inject(constantUsersPerSec(1).during(30.seconds).randomized).protocols(httpProtocol)) +}