Skip to content

Commit

Permalink
41 Configuración y lanzamiento de los test de gatling
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroGlezC committed Jun 6, 2024
1 parent 37a3ecc commit 6b0b037
Show file tree
Hide file tree
Showing 22 changed files with 126 additions and 1 deletion.
Binary file not shown.
Binary file added docs/images/08_api_jacoco_tests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_category_gatling_test_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_category_gatling_test_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_category_gatling_test_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_cypress-tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_cypress_test_running.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_cypress_tool_tests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_java_tests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_jest_unit_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_question_gatling_test_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_question_gatling_test_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_question_gatling_test_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_user_gatling_test_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_user_gatling_test_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/08_user_gatling_test_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ void generate_wikidata_question() {

questionAdapter.generatedQuestions();
List<Question> questionsAfterGenerate = questionAdapter.findAll();
assertEquals(219, IterableUtil.sizeOf(questionsAfterGenerate));
assertEquals(218, IterableUtil.sizeOf(questionsAfterGenerate));
}
}
5 changes: 5 additions & 0 deletions syg-backend/SYG-rest-controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@
<artifactId>SYG-domain</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package simulations;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.*;

import io.gatling.javaapi.core.*;
import io.gatling.javaapi.http.*;

public class CategoryGatlingTests extends Simulation {

private static final String BASE_URL = "http://localhost:8080";

HttpProtocolBuilder httpProtocol = http.baseUrl(BASE_URL).acceptHeader("application/json")
.contentTypeHeader("application/json");

ScenarioBuilder findAllCategories = scenario("Encuentra todas las categorias")
.exec(http("findAllCategories").get("/category").check(status().is(200)));
ScenarioBuilder findCategoryById = scenario("Encuentra una categoria por id")
.exec(http("findCategoryById").get("/category/id?id=1").check(status().is(200)));
{
setUp(findAllCategories.injectOpen(
// Incrementa el número de usuarios rápidamente
incrementUsersPerSec(5).times(12) // Incremento de usuarios por segundo 12 veces (1 minuto)
.eachLevelLasting(5) // Cada nivel dura 5 segundos
.startingFrom(10) // Comienza con 10 usuarios por segundo
), findCategoryById.injectOpen(
incrementUsersPerSec(5).times(12).eachLevelLasting(5).startingFrom(10))).protocols(httpProtocol)
.maxDuration(300);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package simulations;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.*;

import io.gatling.javaapi.core.*;
import io.gatling.javaapi.http.*;

public class QuestionGatlingTests extends Simulation {

private static final String BASE_URL = "http://localhost:8080";

HttpProtocolBuilder httpProtocol = http.baseUrl(BASE_URL).acceptHeader("application/json")
.contentTypeHeader("application/json");

ScenarioBuilder findAllQuestions = scenario("Encuentra todas las preguntas")
.exec(http("findAllQuestions").get("/question").check(status().is(200)));
ScenarioBuilder findQuestionById = scenario("Encuentra una pregunta por su id")
.exec(http("findQuestionById").get("/question/id?id=200").check(status().is(200)));
ScenarioBuilder findQuestionByCategory = scenario("Encuentra una pregunta por su categoria")
.exec(http("findQuestionByCategory").get("/question/category?categoryId=1").check(status().is(200)));
{
setUp(findAllQuestions.injectOpen(incrementUsersPerSec(5).times(12).eachLevelLasting(5).startingFrom(10)),
findQuestionById.injectOpen(incrementUsersPerSec(5).times(12).eachLevelLasting(5).startingFrom(10)),
findQuestionByCategory
.injectOpen(incrementUsersPerSec(5).times(12).eachLevelLasting(5).startingFrom(10)))
.protocols(httpProtocol).maxDuration(300);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package simulations;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.*;

import io.gatling.javaapi.core.*;
import io.gatling.javaapi.http.*;

public class UserGatlingTests extends Simulation {

private static final String BASE_URL = "http://localhost:8080";

HttpProtocolBuilder httpProtocol = http.baseUrl(BASE_URL).acceptHeader("application/json")
.contentTypeHeader("application/json");

ScenarioBuilder findUserById = scenario("Encuentra un usuario por su uuid").exec(
http("findUserById").get("/user/userId?id=4366fdc8-b32d-46bc-9df8-2e8ce68f0743").check(status().is(200)));
ScenarioBuilder findUserByName = scenario("Encuentra un usuario por nombre")
.exec(http("findUserByName").get("/user/name/?userName=alvaro").check(status().is(200)));

{
setUp(findUserById.injectOpen(incrementUsersPerSec(5).times(12).eachLevelLasting(5).startingFrom(10)),
findUserByName.injectOpen(incrementUsersPerSec(5).times(12).eachLevelLasting(5).startingFrom(10)))
.protocols(httpProtocol).maxDuration(300);
}
}
33 changes: 33 additions & 0 deletions syg-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<sonar.coverage.jacoco.xmlReportPaths>SYG-bootstrap/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<sonar.exclusions>SYG-bootstrap/**, SYG-domain/src/main/java/syg/domain/model/** </sonar.exclusions>

<gatling.version>3.11.3</gatling.version>
<gatling-maven-plugin.version>4.9.4</gatling-maven-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<maven-jar-plugin.version>3.4.1</maven-jar-plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -78,6 +83,12 @@
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -187,6 +198,28 @@
<artifactId>sonar-maven-plugin</artifactId>
<version>3.11.0.3922</version>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-maven-plugin.version}</version>
<configuration>
<!-- Enterprise Cloud (https://cloud.gatling.io/) configuration reference: https://gatling.io/docs/gatling/reference/current/extensions/maven_plugin/#working-with-gatling-enterprise-cloud -->
<!-- Enterprise Self-Hosted configuration reference: https://gatling.io/docs/gatling/reference/current/extensions/maven_plugin/#working-with-gatling-enterprise-self-hosted -->
</configuration>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit 6b0b037

Please sign in to comment.